--- a/check_drbd.pl Thu Aug 25 16:50:49 2011 +0200
+++ b/check_drbd.pl Fri Aug 08 13:34:57 2014 +0200
@@ -62,16 +62,21 @@
open( FH, $file )
or print "$NAME CRITICAL: $file $!\n" and exit $ERRORS{CRITICAL};
+ my $r;
while (<FH>) {
chomp;
-/^.*(?<line>(?<resource>\d+):\s+cs:(?<connection_state>\S+)\s+(?:st|ro):(?<roles>\S+)\s+(?:ds|ld):(?<disk_states>\S+))/
- or next;
- $drbd{ $+{resource} } = {
- line => $+{line},
- connection_state => $+{connection_state},
- roles => $+{roles},
- disk_states => $+{disk_states}
- };
+ if (/^.*(?<line>(?<resource>\d+):\s+cs:(?<connection_state>\S+)\s+(?:st|ro):(?<roles>\S+)\s+(?:ds|ld):(?<disk_states>\S+))/) {
+ $r = $+{resource};
+ $drbd{$r} = {
+ line => $+{line},
+ connection_state => $+{connection_state},
+ roles => $+{roles},
+ disk_states => $+{disk_states}
+ };
+ } elsif (defined $r and /oos:(?<out_of_sync>\d+)/) {
+ $drbd{$r}->{out_of_sync} = $+{out_of_sync};
+ $drbd{$r}->{line} .= " oos: $+{out_of_sync}";
+ }
}
close(FH);
@@ -89,6 +94,9 @@
if ( $dev->{disk_states} ne "UpToDate/UpToDate" )
and ( $dev->{disk_states} ne "Consistent" );
+ $dev->{state} = "CRITICAL", next
+ if ( $dev->{out_of_sync} != 0 );
+
$dev->{state} = "WARNING", next
if $dev->{connection_state} ne "Connected";