From: Peter Palfrader Date: Mon, 21 Dec 2015 09:41:20 +0000 (+0100) Subject: dsa-check-drbd: Add --ok-no-devices option X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-nagios.git;a=commitdiff_plain;h=56ccfc500c6734b509803fbf577cdd849e7c4a3b dsa-check-drbd: Add --ok-no-devices option --- diff --git a/dsa-nagios-checks/checks/dsa-check-drbd b/dsa-nagios-checks/checks/dsa-check-drbd index 5b06215..f23b950 100755 --- a/dsa-nagios-checks/checks/dsa-check-drbd +++ b/dsa-nagios-checks/checks/dsa-check-drbd @@ -4,6 +4,7 @@ # check_drbd v0.5.3 # # by Brandon Lee Poyner bpoyner / CCAC.edu # #################################################### +## 20151221 Peter Palfrader: add --ok-no-devices use strict; use File::Basename; @@ -13,6 +14,7 @@ my $drbd_proc='/proc/drbd'; my $drbd_devices=0; my ($drbd_expect, $drbd_role, $drbd_version, $debug_mode); my (%options, %cs, %st, %ld, %ds, %check, %warning, %critical); +my $ok_no_devices = 0; my $prog_name=basename($0); my $prog_revision='0.5.3'; @@ -86,7 +88,7 @@ my %state = ( sub print_usage { print <] [-e expect] [-p proc] [-r role] [-o states] [-w states] [-c states] [--debug] +Usage: $prog_name [-d ] [-e expect] [-p proc] [-r role] [-o states] [-w states] [-c states] [--debug] [--ok-no-devices] Options: -d STRING [default: $drbd_devices. Example: 0,1,2 ] -p STRING [default: $drbd_proc. Use '-' for stdin] @@ -137,6 +139,7 @@ sub parse_options { "o|ok=s" => \$ok_string, "w|warning=s" => \$warning_string, "c|critical=s" => \$critical_string, + "ok-no-devices" => \$ok_no_devices, "debug" => \$debug); if (defined($help) && ($help ne "")) { &print_help; @@ -266,7 +269,7 @@ sub parse_drbd_devices { $check{$device} = 1; } if (int(keys %check) == 0) { - &myexit('UNKNOWN',"No configured devices found"); + &myexit($ok_no_devices ? 'OK' : 'UNKNOWN',"No configured devices found"); } if (defined($debug_mode) && ($debug_mode == 1)) { # diff --git a/dsa-nagios-checks/debian/changelog b/dsa-nagios-checks/debian/changelog index 692c2ad..73bb3ae 100644 --- a/dsa-nagios-checks/debian/changelog +++ b/dsa-nagios-checks/debian/changelog @@ -12,6 +12,7 @@ dsa-nagios-checks (108+XXXX) UNRELEASED; urgency=medium [ Peter Palfrader ] * dsa-check-libs: accept -v as short for --verbose. * dsa-check-libs: ignore deleted CWDs. + * dsa-check-drbd: Add --ok-no-devices option. [ Tollef Fog Heen ] * dsa-update-unowned-file-status: ignore fdescfs, used for /dev/fd on @@ -24,7 +25,7 @@ dsa-nagios-checks (108+XXXX) UNRELEASED; urgency=medium * Add dsa-check-hpssacli, replaces hpacucli for new hosts. * dsa-check-hpssacli: accept 12.0Gbps as transfer speed for SAS - -- Peter Palfrader Fri, 11 Sep 2015 10:21:15 +0200 + -- Peter Palfrader Mon, 21 Dec 2015 10:40:57 +0100 dsa-nagios-checks (108) unstable; urgency=medium