[Nagiosplug-checkins] CVS: nagiosplug/contrib check_disk_snmp.pl,1.1,1.2
Ethan Galstad
egalstad at users.sourceforge.net
Mon Aug 12 16:10:02 CEST 2002
Update of /cvsroot/nagiosplug/nagiosplug/contrib
In directory usw-pr-cvs1:/tmp/cvs-serv8935/contrib
Modified Files:
check_disk_snmp.pl
Log Message:
Updated to use getopt (Christoph Maser)
Index: check_disk_snmp.pl
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/contrib/check_disk_snmp.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** check_disk_snmp.pl 16 Jul 2002 04:13:21 -0000 1.1
--- check_disk_snmp.pl 12 Aug 2002 23:09:48 -0000 1.2
***************
*** 3,15 ****
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;
--- 3,29 ----
use strict;
use Net::SNMP;
+ use Getopt::Std;
! my %opts =(
! u => 'nobody', # snmp user
! l => 'authNoPriv', # snmp security level
! a => 'MD5', # snmp authentication protocol
! A => 'nopass', # authentication protocol pass phrase.
! x => 'DES', # privacy protocol
! m => 'localhost', # host
! d => 1, # devicenumber
! w => 70, # warnratio
! c => 85, # critical ratio
! h => 0,
! );
!
! getopts('m:u:l:a:A:x:d:w:c:h',\%opts);
!
! if ( $opts{'h'} ) {
! print "Usage: $0 [ -u <username> ] [ -l <snmp security level>] [ -a <snmp authentication protocol> ] [ -A <authentication protocol pass phrase> ] [ -x <snmp privacy protocol> ] [ -m <hostname>] [ -d <devicenumber> ] [ -w <warning ratio> ] [ -c <critical ratio ]\n";
exit 1;
}
! if ($opts{'w'} >= $opts{'c'}) {
print "Errorratio must be higher then Warnratio!\n";
exit 1;
***************
*** 17,25 ****
my ($session, $error) = Net::SNMP->session(
! -hostname => $host,
-nonblocking => 0x0,
! -username => 'XXXXX',
! -authpassword => 'XXXXXXXX',
! -authprotocol => 'md5',
-version => '3',
);
--- 31,39 ----
my ($session, $error) = Net::SNMP->session(
! -hostname => $opts{'m'},
-nonblocking => 0x0,
! -username => $opts{'u'},
! -authpassword => $opts{'A'},
! -authprotocol => $opts{'a'},
-version => '3',
);
***************
*** 32,39 ****
! 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(
--- 46,52 ----
! my $deviceSize=".1.3.6.1.2.1.25.2.3.1.5.$opts{'d'}";
! my $deviceUsed=".1.3.6.1.2.1.25.2.3.1.6.$opts{'d'}";
! my $deviceName=".1.3.6.1.2.1.25.2.3.1.3.$opts{'d'}";
my @OID=($deviceSize, $deviceUsed, $deviceName);
$result = $session->get_request(
***************
*** 49,57 ****
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;
--- 62,70 ----
my $ratio=$result->{$deviceUsed}*100/$result->{$deviceSize};
! if ($ratio > $opts{'c'}){
printf("CRITICAL: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
exit 2;
}
! if ($ratio > $opts{'w'}){
printf("WARNING: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
exit 1;
***************
*** 60,62 ****
printf("OK: %s usage %.2f%%\n", $result->{$deviceName}, $ratio);
exit 0;
-
--- 73,74 ----
More information about the Commits
mailing list