diff options
-rw-r--r-- | contrib/check_disk_snmp.pl | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/contrib/check_disk_snmp.pl b/contrib/check_disk_snmp.pl new file mode 100644 index 0000000..96862e1 --- /dev/null +++ b/contrib/check_disk_snmp.pl | |||
@@ -0,0 +1,62 @@ | |||
1 | #!/usr/bin/perl | ||
2 | # cm@financial.com 07/2002 | ||
3 | use strict; | ||
4 | use Net::SNMP; | ||
5 | |||
6 | if ($#ARGV ne 3) { | ||
7 | print "Worng number of Arguments\n"; | ||
8 | exit 1; | ||
9 | } | ||
10 | |||
11 | |||
12 | my ($host, $device, $warnpercent, $errpercent) = @ARGV; | ||
13 | if ($warnpercent >= $errpercent) { | ||
14 | print "Errorratio must be higher then Warnratio!\n"; | ||
15 | exit 1; | ||
16 | } | ||
17 | |||
18 | my ($session, $error) = Net::SNMP->session( | ||
19 | -hostname => $host, | ||
20 | -nonblocking => 0x0, | ||
21 | -username => 'XXXXX', | ||
22 | -authpassword => 'XXXXXXXX', | ||
23 | -authprotocol => 'md5', | ||
24 | -version => '3', | ||
25 | ); | ||
26 | |||
27 | if ($@) { | ||
28 | print "SNMP-Error occured"; | ||
29 | exit 1; | ||
30 | } | ||
31 | my $result=undef; | ||
32 | |||
33 | |||
34 | my $deviceSize=".1.3.6.1.2.1.25.2.3.1.5.$device"; | ||
35 | my $deviceUsed=".1.3.6.1.2.1.25.2.3.1.6.$device"; | ||
36 | #my $deviceName=".1.3.6.1.2.1.25.3.7.1.2.1536.$device"; | ||
37 | my $deviceName=".1.3.6.1.2.1.25.2.3.1.3.$device"; | ||
38 | my @OID=($deviceSize, $deviceUsed, $deviceName); | ||
39 | $result = $session->get_request( | ||
40 | -varbindlist => \@OID, | ||
41 | ); | ||
42 | |||
43 | if (!defined($result)) { | ||
44 | printf("ERROR: %s.\n", $session->error); | ||
45 | $session->close; | ||
46 | exit 1; | ||
47 | } | ||
48 | |||
49 | my $ratio=$result->{$deviceUsed}*100/$result->{$deviceSize}; | ||
50 | |||
51 | if ($ratio > $errpercent){ | ||
52 | printf("CRITICAL: %s usage %.2f%%\n", $result->{$deviceName}, $ratio); | ||
53 | exit 2; | ||
54 | } | ||
55 | if ($ratio > $warnpercent){ | ||
56 | printf("WARNING: %s usage %.2f%%\n", $result->{$deviceName}, $ratio); | ||
57 | exit 1; | ||
58 | } | ||
59 | |||
60 | printf("OK: %s usage %.2f%%\n", $result->{$deviceName}, $ratio); | ||
61 | exit 0; | ||
62 | |||