From c4b2546f0aa6d156cbe79b8a7e6b006b06dc348f Mon Sep 17 00:00:00 2001 From: Nicolai Buchwitz Date: Tue, 25 Sep 2018 11:41:58 +0200 Subject: [PATCH] Add support for ignoring disks in health check --- check_pve.py | 9 ++++++++- icinga2/command.conf | 5 +++++ icinga2/service.conf | 12 ++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/check_pve.py b/check_pve.py index 529cbfe..ac4663f 100755 --- a/check_pve.py +++ b/check_pve.py @@ -206,7 +206,11 @@ def checkDisks(self): disks = self.request(url + '/list') for disk in disks: name = disk['devpath'].replace('/dev/', '') - if disk['health'] != 'PASSED': + + if name in self.options.ignore_disks: + continue + + if disk['health'] not in ('PASSED', 'OK'): self.checkResult = NagiosState.WARNING failed.append({"serial": disk["serial"], "device": disk['devpath']}) @@ -504,6 +508,9 @@ def parseOptions(self): check_opts.add_argument('--ignore-service', dest='ignore_services', action='append', metavar='NAME', help='Ignore service NAME in checks', default=[]) + check_opts.add_argument('--ignore-disk', dest='ignore_disks', action='append', metavar='NAME', + help='Ignore disk NAME in health check', default=[]) + check_opts.add_argument('-w', '--warning', dest='treshold_warning', type=float, help='Warning treshold for check value') check_opts.add_argument('-c', '--critical', dest='treshold_critical', type=float, diff --git a/icinga2/command.conf b/icinga2/command.conf index 105ef24..29307a2 100644 --- a/icinga2/command.conf +++ b/icinga2/command.conf @@ -45,6 +45,11 @@ object CheckCommand "pve" { value = "$pve_ignore_services$" description = "Ignore services in check" } + "--ignore-disks" = { + repeat_key = true + value = "$pve_ignore_services$" + description = "Ignore disks in check" + } "--ignore-vm-status" = { set_if = "$pve_ignore_vm_status$" description = "Ignore VM status in check" diff --git a/icinga2/service.conf b/icinga2/service.conf index 97be44d..66e8886 100644 --- a/icinga2/service.conf +++ b/icinga2/service.conf @@ -31,6 +31,9 @@ object Host "proxmox-host.domain.example" { pve_warning = 80 pve_critical = 90 } + + // Ignore these disks in health check (USB sticks, SD cards, etc.) + vars.pve_ignore_disks = [ "sdn", "sdg" ] } template Service "pve-service" { @@ -52,6 +55,7 @@ apply Service "services" { vars.pve_mode = "services" + // Ignore cluster status on single nodes if (!host.vars.pve_cluster) { vars.pve_ignore_services = host.vars.pve_ignore_services || [] vars.pve_ignore_services.add("corosync") @@ -72,6 +76,14 @@ apply Service "updates" { assign where host.vars.pve_host } +apply Service "disk-health" { + import "pve-service" + + vars.pve_mode = "disk-health" + + assign where host.vars.pve_host +} + apply Service "io_wait" { import "pve-service"