Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions collectors/python.d.plugin/mount_point_check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Mount Point Availability Monitoring with Netdata

Monitors mount point availability.

Following charts are drawn per host:

1. **Status** boolean

- 1 if directory exists and is a mount point. 0 otherwise.

## Configuration

Edit the `python.d/mount_point_check.conf` configuration file using `edit-config` from the Netdata [config
directory](https://learn.netdata.cloud/docs/configure/nodes), which is typically at `/etc/netdata`.

```bash
cd /etc/netdata # Replace this path with your Netdata config directory, if different
sudo ./edit-config python.d/mount_point_check.conf
```

```yaml
jobs:
- name: _mnt_shared_blob_ # [required] my job name
path: "/mnt/shared/blob/" # [required] path to the mount point

- name: _var_lib_netdata_testmount_ # job name of second job
path: "/var/lib/netdata/testmount/" # path to another mount point
```

## Alarms

Edit the `health.d/mount_point_check.conf` configuration file using `edit-config` from the Netdata [config
directory](https://learn.netdata.cloud/docs/configure/nodes), which is typically at `/etc/netdata`. The following
example will send a critical alert as soon as one of the configured mount points is missing:

```yaml
template: mount_point_missing
on: mountpointcheck.status
class: Errors
type: Other
lookup: max -1s of available
every: 10s
units: boolean
crit: $this <= 0
summary: Check whether the expected mount point is available.
to: sysadmin
```

### Notes

- Filesystem permissions might block Netdata's access to the provided path in the configuration file. In this case the
state will be reported as 0.

---


Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Description: mount point check netdata python.d module

import os

from bases.FrameworkServices.ExecutableService import ExecutableService

MOUNTPOINT_COMMAND = 'mountpoint /'

ORDER = []

CHARTS = {}


class Service(ExecutableService):
def __init__(self, configuration=None, name=None):
ExecutableService.__init__(self, configuration=configuration, name=name)
self.configuration = configuration
self._create_order_and_charts()
self.order = ORDER
self.definitions = CHARTS
self.command = MOUNTPOINT_COMMAND

def _create_order_and_charts(self):
for job in self.configuration.get("jobs"):
if job.get("name") in CHARTS:
continue
ORDER.append(job.get("name"))
CHARTS[job.get("name")] = {
"options": [None, "Mount Point Check Status", "boolean", "status", "mountpointcheck.status", "line"],
"lines": [[f"{job.get('name')}.available", "available"]]}

def _get_data(self):
data = dict()
try:
for job in self.configuration.get("jobs"):
self.command[1] = job.get("path")
if os.path.exists(job.get("path")) and (
self._get_raw_data()[0] == f"{job.get('path')} is a mountpoint\n"):
data[f"{job.get('name')}.available"] = 1
else:
data[f"{job.get('name')}.available"] = 0
return data
except (ValueError, AttributeError):
return None
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# netdata python.d.plugin configuration for mount_point_check
#
# This file is in YaML format. Generally the format is:
#
# name: value
#
# ----------------------------------------------------------------------
# Global Variables
# These variables set the defaults for all JOBs, however each JOB
# may define its own, overriding the defaults.

# update_every sets the default data collection frequency.
# If unset, the python.d.plugin default is used.
# update_every: 10

# priority controls the order of charts at the netdata dashboard.
# Lower numbers move the charts towards the top of the page.
# If unset, the default for python.d.plugin is used.
# priority: 60000

# retries sets the number of retries to be made in case of failures.
# If unset, the default for python.d.plugin is used.
# Attempts to restore the service are made once every update_every
# and only if the module has collected values in the past.
# retries: 60

# autodetection_retry sets the job re-check interval in seconds.
# The job is not deleted if check fails.
# Attempts to start the job are made once every autodetection_retry.
# This feature is disabled by default.
# autodetection_retry: 0
#
# ----------------------------------------------------------------------
# MountPointCheck-specific variables
#
# jobs:
# - name: _mnt_shared_blob_ # [required] my job name
# path: "/mnt/shared/blob/" # [required] path to the mount point

# - name: _var_lib_netdata_testmount_ # job name of second job
# path: "/var/lib/netdata/testmount/" # path to another mount point