| 1 |
commit b04bdeb025c77e34fdf8ed9eab2f222240297ca3 |
| 2 |
Author: Stanislav German-Evtushenko <[email protected]> |
| 3 |
Date: Mon Mar 3 08:11:31 2014 +0300 |
| 4 |
|
| 5 |
check_drbd: add check for oos and cosmetic |
| 6 |
|
| 7 |
1) add check for out of sync sectors (report WARNING for non-zero value) |
| 8 |
2) cosmetic: sort device list while processing |
| 9 |
|
| 10 |
Index: pkg-nagios-plugins-contrib/check_drbd/check_drbd |
| 11 |
=================================================================== |
| 12 |
--- pkg-nagios-plugins-contrib.orig/check_drbd/check_drbd |
| 13 |
+++ pkg-nagios-plugins-contrib/check_drbd/check_drbd |
| 14 |
@@ -12,7 +12,7 @@ use Getopt::Long; |
| 15 |
my $drbd_proc='/proc/drbd'; |
| 16 |
my $drbd_devices=0; |
| 17 |
my ($drbd_expect, $drbd_role, $drbd_version, $debug_mode); |
| 18 |
-my (%options, %cs, %st, %ld, %ds, %check, %warning, %critical); |
| 19 |
+my (%options, %cs, %st, %ld, %ds, %oos, %check, %warning, %critical); |
| 20 |
|
| 21 |
my $prog_name=basename($0); |
| 22 |
my $prog_revision='0.5.3'; |
| 23 |
@@ -210,10 +210,17 @@ sub parse_proc { |
| 24 |
} else { |
| 25 |
$input = "STDIN"; |
| 26 |
} |
| 27 |
+ my $devnum; |
| 28 |
while(<$input>) { |
| 29 |
if (/^version: (\d+).(\d+)/) { |
| 30 |
$drbd_version = "$1.$2"; |
| 31 |
} |
| 32 |
+ if (/^\s?(\d+):.*/) { |
| 33 |
+ $devnum = $1; |
| 34 |
+ } |
| 35 |
+ if (defined($devnum) and /\soos:(\d+)/) { |
| 36 |
+ $oos{$devnum} = $1; |
| 37 |
+ } |
| 38 |
if (/^\s?(\d+):.* cs:(\w+)/) { |
| 39 |
$cs{$1} = $2; |
| 40 |
} |
| 41 |
@@ -248,11 +255,11 @@ sub parse_drbd_devices { |
| 42 |
# |
| 43 |
my @devices; |
| 44 |
if ($drbd_devices =~ /^all$/i) { |
| 45 |
- for my $device ( keys %cs ) { |
| 46 |
+ for my $device ( sort keys %cs ) { |
| 47 |
push(@devices,$device); |
| 48 |
} |
| 49 |
} elsif ($drbd_devices =~ /^configured$/i) { |
| 50 |
- for my $device ( keys %cs ) { |
| 51 |
+ for my $device ( sort keys %cs ) { |
| 52 |
next if ($cs{$device} eq "Unconfigured"); |
| 53 |
push(@devices,$device); |
| 54 |
} |
| 55 |
@@ -264,6 +271,9 @@ sub parse_drbd_devices { |
| 56 |
&myexit('UNKNOWN',"Could not find device $device"); |
| 57 |
} |
| 58 |
$check{$device} = 1; |
| 59 |
+ if (defined($oos{$device}) and $oos{$device} > 0) { |
| 60 |
+ &myexit('WARNING',"Out of sync on device $device: $oos{$device} sectors"); |
| 61 |
+ } |
| 62 |
} |
| 63 |
if (int(keys %check) == 0) { |
| 64 |
&myexit('UNKNOWN',"No configured devices found"); |