summaryrefslogtreecommitdiffstats
path: root/contrib/check_hprsc.pl
diff options
context:
space:
mode:
authorStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>2004-11-25 03:01:23 (GMT)
committerStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>2004-11-25 03:01:23 (GMT)
commitc47662b146f66751af1aca2e76869f1cf858cbb6 (patch)
tree32ec4c7a0f28622143f377c95f2dec3a738d9d20 /contrib/check_hprsc.pl
parent2acbb0a6e7fc9d33ab4d3fd0cb8bf7cffb56298b (diff)
downloadmonitoring-plugins-c47662b146f66751af1aca2e76869f1cf858cbb6.tar.gz
update check_hprsc.pl for Net-SNMP versions >=4
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@937 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/check_hprsc.pl')
-rwxr-xr-xcontrib/check_hprsc.pl42
1 files changed, 24 insertions, 18 deletions
diff --git a/contrib/check_hprsc.pl b/contrib/check_hprsc.pl
index 23e6261..7a85650 100755
--- a/contrib/check_hprsc.pl
+++ b/contrib/check_hprsc.pl
@@ -23,7 +23,7 @@ $ENV{'BASH_ENV'}="";
23if (-e "/usr/bin/snmpwalk") { 23if (-e "/usr/bin/snmpwalk") {
24 $snmpwalk = "/usr/bin/snmpwalk"; 24 $snmpwalk = "/usr/bin/snmpwalk";
25} elsif (-e "/usr/local/bin/snmpwalk") { 25} elsif (-e "/usr/local/bin/snmpwalk") {
26 $snmpwalk = "/usr/local/snmpwalk"; 26 $snmpwalk = "/usr/local/bin/snmpwalk";
27} 27}
28 28
29 29
@@ -45,41 +45,47 @@ GetOptions( "check-filesystem" => \$chk_fs,
45 "community=s" => \$target_community, 45 "community=s" => \$target_community,
46 "filesystemID1=i" => \$fsid1_opt, 46 "filesystemID1=i" => \$fsid1_opt,
47 "filesystem=s" => \$fs_opt, 47 "filesystem=s" => \$fs_opt,
48 "protocol:s" => \$proto_opt,
48 "warning=i" => \$warning_opt, 49 "warning=i" => \$warning_opt,
49 "critical=i" => \$critical_opt); 50 "critical=i" => \$critical_opt);
50 51
52$proto_opt = 1
53 unless $proto_opt == 1 ||
54 $proto_opt == '2c' ||
55 $proto_opt == 3;
56
51if ($chk_fs) { 57if ($chk_fs) {
52 walk_data($snmpwalk, $target_host, $target_community, $mounted_OID ); 58 walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt );
53 walk_data($snmpwalk, $target_host, $target_community, $totalspace_OID ); 59 walk_data($snmpwalk, $target_host, $target_community, $totalspace_OID,$proto_opt );
54 walk_data($snmpwalk, $target_host, $target_community, $freespace_OID ); check_filesystem($fs_opt, $warning_opt, $critical_opt); 60 walk_data($snmpwalk, $target_host, $target_community, $freespace_OID,$proto_opt ); check_filesystem($fs_opt, $warning_opt, $critical_opt);
55} elsif ($show_fs) { 61} elsif ($show_fs) {
56 walk_data($snmpwalk, $target_host, $target_community, $filesystemID1_OID); 62 walk_data($snmpwalk, $target_host, $target_community, $filesystemID1_OID,$proto_opt);
57 walk_data($snmpwalk, $target_host, $target_community, $mounted_OID ); 63 walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt );
58 walk_data($snmpwalk, $target_host, $target_community, $path_OID); 64 walk_data($snmpwalk, $target_host, $target_community, $path_OID,$proto_opt);
59 show_filesystem(); 65 show_filesystem();
60} elsif ($chk_fsid){ 66} elsif ($chk_fsid){
61 $totalspace_fsID_OID = "$totalspace_OID.$fsid1_opt"; 67 $totalspace_fsID_OID = "$totalspace_OID.$fsid1_opt";
62 $freespace_fsID_OID = "$freespace_OID.$fsid1_opt"; 68 $freespace_fsID_OID = "$freespace_OID.$fsid1_opt";
63 walk_data($snmpwalk, $target_host, $target_community, $totalspace_fsID_OID); 69 walk_data($snmpwalk, $target_host, $target_community, $totalspace_fsID_OID,$proto_opt);
64 walk_data($snmpwalk, $target_host, $target_community, $freespace_fsID_OID); 70 walk_data($snmpwalk, $target_host, $target_community, $freespace_fsID_OID,$proto_opt);
65 check_filesystemID1($fsid1_opt, $warning_opt, $critical_opt); 71 check_filesystemID1($fsid1_opt, $warning_opt, $critical_opt);
66} elsif ($chk_cpu) { 72} elsif ($chk_cpu) {
67 get_cpu_load($snmpwalk, $target_host, $target_community, $cpu_5min_OID); 73 get_cpu_load($snmpwalk, $target_host, $target_community, $cpu_5min_OID,$proto_opt);
68 check_cpu_5min($cpu, $warning_opt, $critical_opt); 74 check_cpu_5min($cpu, $warning_opt, $critical_opt);
69} else { 75} else {
70 print "\n\nUsage:\n"; 76 print "\n\nUsage:\n";
71 print "Checking 5-min CPU Load:\n"; 77 print "Checking 5-min CPU Load:\n";
72 print " $0 --check-cpu -warning <threshold> --critical <threshold> --host <yourhost> --community <SNMP community>\n\n"; 78 print " $0 --check-cpu -warning <threshold> --critical <threshold> --host <yourhost> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
73 print "Checking local filesystem mounted on a host:\n"; 79 print "Checking local filesystem mounted on a host:\n";
74 print " $0 --show-filesystems --host <hostname> --community <SNMP community>\n\n"; 80 print " $0 --show-filesystems --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
75 print "Checking by filesystem name:\n"; 81 print "Checking by filesystem name:\n";
76 print " $0 --check-filesystem --filesystem </dev/vg00/lvol1> --warning <% used space> --critical <% used space> --host <hostname> --community <SNMP community>\n\n"; 82 print " $0 --check-filesystem --filesystem </dev/vg00/lvol1> --warning <% used space> --critical <% used space> --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
77 print "Checking by filesystem ID:\n"; 83 print "Checking by filesystem ID:\n";
78 print " $0 --check-filesystemID --filesystemID <filesystemID1> --warning <% used space> --critical <% used space> --host <hostname> --community <SNMP community>\n\n"; 84 print " $0 --check-filesystemID --filesystemID <filesystemID1> --warning <% used space> --critical <% used space> --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
79} 85}
80 86
81sub get_cpu_load { 87sub get_cpu_load {
82 my ($snmpwalk, $target_host, $target_community, $OID) = @_; 88 my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_;
83 die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|")); 89 die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|"));
84 90
85 if ($pid) { # parent 91 if ($pid) { # parent
@@ -89,13 +95,13 @@ sub get_cpu_load {
89 } 95 }
90 close(SNMPWALK) or warn "kid exited $?"; 96 close(SNMPWALK) or warn "kid exited $?";
91 } else { # child 97 } else { # child
92 exec($snmpwalk,$target_host,$target_community,$OID) or die "can't exec program: $!"; 98 exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!";
93 } 99 }
94} 100}
95 101
96sub walk_data { 102sub walk_data {
97#This function queries the SNMP daemon for the specific OID 103#This function queries the SNMP daemon for the specific OID
98 my ($snmpwalk, $target_host, $target_community, $OID) = @_; 104 my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_;
99 105
100 die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|")); 106 die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|"));
101 107
@@ -106,7 +112,7 @@ sub walk_data {
106 } 112 }
107 close(SNMPWALK) or warn "kid exited $?"; 113 close(SNMPWALK) or warn "kid exited $?";
108 } else { # child 114 } else { # child
109 exec($snmpwalk,$target_host,$target_community,$OID) or die "can't exec program: $!"; 115 exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!";
110 } 116 }
111} 117}
112 118