Skip to content

Commit

Permalink
Add support for ignoring disks in health check
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolai Buchwitz committed Sep 25, 2018
1 parent b5dc30c commit c4b2546
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion check_pve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']})

Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions icinga2/command.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions icinga2/service.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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")
Expand All @@ -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"

Expand Down

0 comments on commit c4b2546

Please sign in to comment.