diff options
author | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-07-16 04:13:21 (GMT) |
---|---|---|
committer | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-07-16 04:13:21 (GMT) |
commit | 43e09d6326c4b4f5beec3d40dc27369a7b6ce64c (patch) | |
tree | cef904e6f8db320d2fdf0ec9f8256b8cdf810d63 | |
parent | 86a2af768544356d2bbdeddb205e1f4f872157a1 (diff) | |
download | monitoring-plugins-43e09d6326c4b4f5beec3d40dc27369a7b6ce64c.tar.gz |
Christoph Maser's plugin to check disk usage via SNMP3
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@65 f882894a-f735-0410-b71e-b25c423dba1c
-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 | |||