summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Galstad <egalstad@users.sourceforge.net>2002-07-16 04:13:21 (GMT)
committerEthan Galstad <egalstad@users.sourceforge.net>2002-07-16 04:13:21 (GMT)
commit43e09d6326c4b4f5beec3d40dc27369a7b6ce64c (patch)
treecef904e6f8db320d2fdf0ec9f8256b8cdf810d63
parent86a2af768544356d2bbdeddb205e1f4f872157a1 (diff)
downloadmonitoring-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.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 0000000..96862e1
--- /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