aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorGravatar Ethan Galstad <egalstad@users.sourceforge.net> 2002-07-16 04:13:21 +0000
committerGravatar Ethan Galstad <egalstad@users.sourceforge.net> 2002-07-16 04:13:21 +0000
commit43e09d6326c4b4f5beec3d40dc27369a7b6ce64c (patch)
treecef904e6f8db320d2fdf0ec9f8256b8cdf810d63 /contrib
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
Diffstat (limited to 'contrib')
-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 @@
+#!/usr/bin/perl
+# cm@financial.com 07/2002
+use strict;
+use Net::SNMP;
+
+if ($#ARGV ne 3) {
+ print "Worng number of Arguments\n";
+ exit 1;
+}
+
+
+my ($host, $device, $warnpercent, $errpercent) = @ARGV;
+if ($warnpercent >= $errpercent) {
+ print "Errorratio must be higher then Warnratio!\n";
+ exit 1;
+}
+
+my ($session, $error) = Net::SNMP->session(
+ -hostname => $host,
+ -nonblocking => 0x0,
+ -username => 'XXXXX',
+ -authpassword => 'XXXXXXXX',
+ -authprotocol => 'md5',
+ -version => '3',
+ );
+
+if ($@) {
+ print "SNMP-Error occured";
+ exit 1;
+}
+my $result=undef;
+
+
+my $deviceSize=".1.3.6.1.2.1.25.2.3.1.5.$device";
+my $deviceUsed=".1.3.6.1.2.1.25.2.3.1.6.$device";
+#my $deviceName=".1.3.6.1.2.1.25.3.7.1.2.1536.$device";
+my $deviceName=".1.3.6.1.2.1.25.2.3.1.3.$device";
+my @OID=($deviceSize, $deviceUsed, $deviceName);
+$result = $session->get_request(
+ -varbindlist => \@OID,
+ );
+
+if (!defined($result)) {
+ printf("ERROR: %s.\n", $session->error);
+ $session->close;
+ exit 1;
+}
+
+my $ratio=$result->{$deviceUsed}*100/$result->{$deviceSize};
+
+if ($ratio > $errpercent){
+ printf("CRITICAL: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
+ exit 2;
+}
+if ($ratio > $warnpercent){
+ printf("WARNING: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
+ exit 1;
+}
+
+printf("OK: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
+exit 0;
+