diff options
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/check_linux_raid.pl | 20 | ||||
| -rw-r--r-- | contrib/check_nmap.py | 7 |
2 files changed, 18 insertions, 9 deletions
diff --git a/contrib/check_linux_raid.pl b/contrib/check_linux_raid.pl index c24b0cd2..6650a42b 100644 --- a/contrib/check_linux_raid.pl +++ b/contrib/check_linux_raid.pl | |||
| @@ -28,8 +28,8 @@ use utils qw(%ERRORS); | |||
| 28 | 28 | ||
| 29 | # die with an error if we're not on Linux | 29 | # die with an error if we're not on Linux |
| 30 | if ($^O ne 'linux') { | 30 | if ($^O ne 'linux') { |
| 31 | print "This plugin only applicable on Linux.\n"; | 31 | print "This plugin only applicable on Linux.\n"; |
| 32 | exit $ERRORS{'UNKNOWN'}; | 32 | exit $ERRORS{'UNKNOWN'}; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | sub max_state($$){ | 35 | sub max_state($$){ |
| @@ -50,6 +50,7 @@ my $code = "UNKNOWN"; | |||
| 50 | my $msg = ""; | 50 | my $msg = ""; |
| 51 | my %status; | 51 | my %status; |
| 52 | my %recovery; | 52 | my %recovery; |
| 53 | my %resyncing; | ||
| 53 | my %finish; | 54 | my %finish; |
| 54 | my %active; | 55 | my %active; |
| 55 | my %devices; | 56 | my %devices; |
| @@ -65,6 +66,10 @@ while(defined $nextdev){ | |||
| 65 | $recovery{$device} = $1; | 66 | $recovery{$device} = $1; |
| 66 | ($finish{$device}) = /finish=(.*?min)/; | 67 | ($finish{$device}) = /finish=(.*?min)/; |
| 67 | $device=undef; | 68 | $device=undef; |
| 69 | } elsif (/resync =\s+(.*?)\s/) { | ||
| 70 | $resyncing{$device} = $1; | ||
| 71 | ($finish{$device}) = /finish=(.*?min)/; | ||
| 72 | $device=undef; | ||
| 68 | } elsif (/^\s*$/) { | 73 | } elsif (/^\s*$/) { |
| 69 | $device=undef; | 74 | $device=undef; |
| 70 | } | 75 | } |
| @@ -95,8 +100,14 @@ foreach my $k (sort keys %devices){ | |||
| 95 | $code = max_state($code, "CRITICAL"); | 100 | $code = max_state($code, "CRITICAL"); |
| 96 | } | 101 | } |
| 97 | } elsif ($status{$k} =~ /U+/) { | 102 | } elsif ($status{$k} =~ /U+/) { |
| 98 | $msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k}; | 103 | if (defined $resyncing{$k}) { |
| 99 | $code = max_state($code, "OK"); | 104 | $msg .= sprintf " %s status=%s, resync=%s, finish=%s.", |
| 105 | $devices{$k}, $status{$k}, $resyncing{$k}, $finish{$k}; | ||
| 106 | $code = max_state($code, "WARNING"); | ||
| 107 | } else { | ||
| 108 | $msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k}; | ||
| 109 | $code = max_state($code, "OK"); | ||
| 110 | } | ||
| 100 | } else { | 111 | } else { |
| 101 | if ($active{$k}) { | 112 | if ($active{$k}) { |
| 102 | $msg .= sprintf " %s active with no status information.", | 113 | $msg .= sprintf " %s active with no status information.", |
| @@ -112,4 +123,3 @@ foreach my $k (sort keys %devices){ | |||
| 112 | 123 | ||
| 113 | print $code, $msg, "\n"; | 124 | print $code, $msg, "\n"; |
| 114 | exit ($ERRORS{$code}); | 125 | exit ($ERRORS{$code}); |
| 115 | |||
diff --git a/contrib/check_nmap.py b/contrib/check_nmap.py index 07f6d7fa..481a62bf 100644 --- a/contrib/check_nmap.py +++ b/contrib/check_nmap.py | |||
| @@ -43,7 +43,7 @@ _version_ = '1.21' | |||
| 43 | # 0.20 2000-07-10 jaclu Initial release | 43 | # 0.20 2000-07-10 jaclu Initial release |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | import sys, os, string, whrandom | 46 | import sys, os, string, random |
| 47 | 47 | ||
| 48 | import tempfile | 48 | import tempfile |
| 49 | from getopt import getopt | 49 | from getopt import getopt |
| @@ -207,8 +207,7 @@ class CheckNmap: | |||
| 207 | # _if_ two processes in deed get the same tmp-file | 207 | # _if_ two processes in deed get the same tmp-file |
| 208 | # the only result is a normal error message to nagios | 208 | # the only result is a normal error message to nagios |
| 209 | # | 209 | # |
| 210 | r=whrandom.whrandom() | 210 | self.tmp_file=tempfile.mktemp('.%s') % random.randint(0,100000) |
| 211 | self.tmp_file=tempfile.mktemp('.%s')%r.randint(0,100000) | ||
| 212 | if self.debug: | 211 | if self.debug: |
| 213 | print 'Tmpfile is: %s'%self.tmp_file | 212 | print 'Tmpfile is: %s'%self.tmp_file |
| 214 | # | 213 | # |
| @@ -388,7 +387,7 @@ Version: %s""" % _version_ | |||
| 388 | 387 | ||
| 389 | def doc_syntax(): | 388 | def doc_syntax(): |
| 390 | print """ | 389 | print """ |
| 391 | Usage: check_ports [-v|--debug] [-H|--host host] [-V|--version] [-h|--help] | 390 | Usage: check_nmap.py [-v|--debug] [-H|--host host] [-V|--version] [-h|--help] |
| 392 | [-o|--optional port1,port2,port3 ...] [-r|--range range] | 391 | [-o|--optional port1,port2,port3 ...] [-r|--range range] |
| 393 | [-p|--port port1,port2,port3 ...] [-t|--timeout timeout]""" | 392 | [-p|--port port1,port2,port3 ...] [-t|--timeout timeout]""" |
| 394 | 393 | ||
