summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/check_disk_snmp.pl62
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 00000000..96862e1c
--- /dev/null
+++ b/contrib/check_disk_snmp.pl
@@ -0,0 +1,62 @@
1#!/usr/bin/perl
2# cm@financial.com 07/2002
3use strict;
4use Net::SNMP;
5
6if ($#ARGV ne 3) {
7 print "Worng number of Arguments\n";
8 exit 1;
9}
10
11
12my ($host, $device, $warnpercent, $errpercent) = @ARGV;
13if ($warnpercent >= $errpercent) {
14 print "Errorratio must be higher then Warnratio!\n";
15 exit 1;
16}
17
18my ($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
27if ($@) {
28 print "SNMP-Error occured";
29 exit 1;
30}
31my $result=undef;
32
33
34my $deviceSize=".1.3.6.1.2.1.25.2.3.1.5.$device";
35my $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";
37my $deviceName=".1.3.6.1.2.1.25.2.3.1.3.$device";
38my @OID=($deviceSize, $deviceUsed, $deviceName);
39$result = $session->get_request(
40 -varbindlist => \@OID,
41 );
42
43if (!defined($result)) {
44 printf("ERROR: %s.\n", $session->error);
45 $session->close;
46 exit 1;
47}
48
49my $ratio=$result->{$deviceUsed}*100/$result->{$deviceSize};
50
51if ($ratio > $errpercent){
52 printf("CRITICAL: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
53 exit 2;
54}
55if ($ratio > $warnpercent){
56 printf("WARNING: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
57 exit 1;
58}
59
60printf("OK: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
61exit 0;
62