From 16b0042791611042b85d7db5a1789202f0eb35d2 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 28 Nov 2018 00:04:10 +0400 Subject: [PATCH 1/6] Add btrfs CheckCommand definition Check a btrfs mountpoint health and disk space allocated --- doc/10-icinga-template-library.md | 16 +++++++++++++++ itl/plugins-contrib.d/storage.conf | 32 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/doc/10-icinga-template-library.md b/doc/10-icinga-template-library.md index 103410d2d..de36703a9 100644 --- a/doc/10-icinga-template-library.md +++ b/doc/10-icinga-template-library.md @@ -3106,6 +3106,22 @@ ceph_client_key | **Optional.** Ceph client keyring file. ceph_whitelist | **Optional.** Whitelist regexp for ceph health warnings. ceph_details | **Optional.** Run 'ceph health detail'. +#### btrfs + +The [btrfs plugin](https://github.com/knorrie/python-btrfs/) +is used to check the btrfs storage health on the server. + +[monitoring-plugins-btrfs](https://packages.debian.org/monitoring-plugins-btrfs) provide the necessary binary on debian/ubuntu. + +Custom attributes passed as [command parameters](03-monitoring-basics.md#command-passing-parameters): + +Name | Description +-----------------|--------------------------------------------------------- +btrfs_awg | **Optional.** Exit with WARNING status if less than the specified amount of disk space (in GiB) is unallocated +btrfs_acg | **Optional.** Exit with CRITICAL status if less than the specified amount of disk space (in GiB) is unallocated +btrfs_awp | **Optional.** Exit with WARNING status if more than the specified percent of disk space is allocated +btrfs_acp | **Optional.** Exit with CRITICAL status if more than the specified percent of disk space is allocated +btrfs_mountpoint | **Required.** Path to the BTRFS mountpoint ### Virtualization diff --git a/itl/plugins-contrib.d/storage.conf b/itl/plugins-contrib.d/storage.conf index 3e413e0ab..3d1286b2e 100644 --- a/itl/plugins-contrib.d/storage.conf +++ b/itl/plugins-contrib.d/storage.conf @@ -102,3 +102,35 @@ object CheckCommand "ceph" { } } } + +object CheckCommand "btrfs" { + import "plugin-check-command" + [ "sudo", PluginDir + "/check_btrfs" ] + + arguments = { + "--allocated-warning-gib" = { + value = "$btrfs_awg$" + description = "Exit with WARNING status if less than the specified amount of disk space (in GiB) is unallocated" + } + "--allocated-critical-gib" = { + value = "$btrfs_acg$" + description = "Exit with CRITICAL status if less than the specified amount of disk space (in GiB) is unallocated" + } + "--allocated-warning-percent" = { + value = "$btrfs_awp$" + description = "Exit with WARNING status if more than the specified percent of disk space is allocated" + } + "--allocated-critical-percent" = { + value = "$btrfs_acp$" + description = "Exit with CRITICAL status if more than the specified percent of disk space is allocated" + } + "--mountpoint" = { + value = "$btrfs_mountpoint$" + description = "Path to the BTRFS mountpoint" + required = true + } + } + vars.btrfs_awp = 80 + vars.btrfs_acp = 90 +} + From ef0c68fe79567156e26deafdcfbf3c01b5c7cc2d Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 28 Nov 2018 11:37:49 +0400 Subject: [PATCH 2/6] correct command definition --- itl/plugins-contrib.d/storage.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itl/plugins-contrib.d/storage.conf b/itl/plugins-contrib.d/storage.conf index 3d1286b2e..c14bf6856 100644 --- a/itl/plugins-contrib.d/storage.conf +++ b/itl/plugins-contrib.d/storage.conf @@ -105,7 +105,7 @@ object CheckCommand "ceph" { object CheckCommand "btrfs" { import "plugin-check-command" - [ "sudo", PluginDir + "/check_btrfs" ] + command = [ "sudo", PluginDir + "/check_btrfs" ] arguments = { "--allocated-warning-gib" = { From b6e97a9eff56d4201cc943c979702d17f7ed8a72 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 28 Nov 2018 13:39:51 +0400 Subject: [PATCH 3/6] Add documentation for sudoers configuration --- doc/10-icinga-template-library.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/10-icinga-template-library.md b/doc/10-icinga-template-library.md index de36703a9..5b705a9b6 100644 --- a/doc/10-icinga-template-library.md +++ b/doc/10-icinga-template-library.md @@ -3111,6 +3111,18 @@ ceph_details | **Optional.** Run 'ceph health detail'. The [btrfs plugin](https://github.com/knorrie/python-btrfs/) is used to check the btrfs storage health on the server. +The plugin requires `sudo` permissions. +You can add a sudoers file to allow your monitoring user to use the plugin, i.e. edit /etc/sudoers.d/nagios and add: +``` +nagios ALL=(root) NOPASSWD:/usr/lib/nagios/plugins/check_btrfs +``` + +and set the correct permissions: +```bash +chown -c root: /etc/sudoers.d/nagios +chmod -c 0440 /etc/sudoers.d/nagios +``` + [monitoring-plugins-btrfs](https://packages.debian.org/monitoring-plugins-btrfs) provide the necessary binary on debian/ubuntu. Custom attributes passed as [command parameters](03-monitoring-basics.md#command-passing-parameters): From 4afbf2f987b7285aaf4f893b76e2772c36c42073 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Fri, 30 Nov 2018 00:40:05 +0400 Subject: [PATCH 4/6] Documentation: use icinga user instead of nagios --- doc/10-icinga-template-library.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/10-icinga-template-library.md b/doc/10-icinga-template-library.md index 5b705a9b6..5d57d3275 100644 --- a/doc/10-icinga-template-library.md +++ b/doc/10-icinga-template-library.md @@ -3114,13 +3114,13 @@ is used to check the btrfs storage health on the server. The plugin requires `sudo` permissions. You can add a sudoers file to allow your monitoring user to use the plugin, i.e. edit /etc/sudoers.d/nagios and add: ``` -nagios ALL=(root) NOPASSWD:/usr/lib/nagios/plugins/check_btrfs +icinga ALL=(root) NOPASSWD:/usr/lib/nagios/plugins/check_btrfs ``` and set the correct permissions: ```bash -chown -c root: /etc/sudoers.d/nagios -chmod -c 0440 /etc/sudoers.d/nagios +chown -c root: /etc/sudoers.d/icinga +chmod -c 0440 /etc/sudoers.d/icinga ``` [monitoring-plugins-btrfs](https://packages.debian.org/monitoring-plugins-btrfs) provide the necessary binary on debian/ubuntu. From 4944800d0953c2f1a43f6439d22a4e9515545754 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Fri, 30 Nov 2018 00:41:27 +0400 Subject: [PATCH 5/6] Indentation: space to tab --- itl/plugins-contrib.d/storage.conf | 54 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/itl/plugins-contrib.d/storage.conf b/itl/plugins-contrib.d/storage.conf index c14bf6856..1d1822ea0 100644 --- a/itl/plugins-contrib.d/storage.conf +++ b/itl/plugins-contrib.d/storage.conf @@ -104,33 +104,33 @@ object CheckCommand "ceph" { } object CheckCommand "btrfs" { - import "plugin-check-command" - command = [ "sudo", PluginDir + "/check_btrfs" ] + import "plugin-check-command" + command = [ "sudo", PluginDir + "/check_btrfs" ] - arguments = { - "--allocated-warning-gib" = { - value = "$btrfs_awg$" - description = "Exit with WARNING status if less than the specified amount of disk space (in GiB) is unallocated" - } - "--allocated-critical-gib" = { - value = "$btrfs_acg$" - description = "Exit with CRITICAL status if less than the specified amount of disk space (in GiB) is unallocated" - } - "--allocated-warning-percent" = { - value = "$btrfs_awp$" - description = "Exit with WARNING status if more than the specified percent of disk space is allocated" - } - "--allocated-critical-percent" = { - value = "$btrfs_acp$" - description = "Exit with CRITICAL status if more than the specified percent of disk space is allocated" - } - "--mountpoint" = { - value = "$btrfs_mountpoint$" - description = "Path to the BTRFS mountpoint" - required = true - } - } - vars.btrfs_awp = 80 - vars.btrfs_acp = 90 + arguments = { + "--allocated-warning-gib" = { + value = "$btrfs_awg$" + description = "Exit with WARNING status if less than the specified amount of disk space (in GiB) is unallocated" + } + "--allocated-critical-gib" = { + value = "$btrfs_acg$" + description = "Exit with CRITICAL status if less than the specified amount of disk space (in GiB) is unallocated" + } + "--allocated-warning-percent" = { + value = "$btrfs_awp$" + description = "Exit with WARNING status if more than the specified percent of disk space is allocated" + } + "--allocated-critical-percent" = { + value = "$btrfs_acp$" + description = "Exit with CRITICAL status if more than the specified percent of disk space is allocated" + } + "--mountpoint" = { + value = "$btrfs_mountpoint$" + description = "Path to the BTRFS mountpoint" + required = true + } + } + vars.btrfs_awp = 80 + vars.btrfs_acp = 90 } From fe42c091a4ce7a88be1cf87ab97102058f5e9f2b Mon Sep 17 00:00:00 2001 From: BarbUk Date: Fri, 30 Nov 2018 01:32:20 +0400 Subject: [PATCH 6/6] Documentation: fix sudoers file name --- doc/10-icinga-template-library.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/10-icinga-template-library.md b/doc/10-icinga-template-library.md index 5d57d3275..b2e00fe55 100644 --- a/doc/10-icinga-template-library.md +++ b/doc/10-icinga-template-library.md @@ -3112,7 +3112,7 @@ The [btrfs plugin](https://github.com/knorrie/python-btrfs/) is used to check the btrfs storage health on the server. The plugin requires `sudo` permissions. -You can add a sudoers file to allow your monitoring user to use the plugin, i.e. edit /etc/sudoers.d/nagios and add: +You can add a sudoers file to allow your monitoring user to use the plugin, i.e. edit /etc/sudoers.d/icinga and add: ``` icinga ALL=(root) NOPASSWD:/usr/lib/nagios/plugins/check_btrfs ```