Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Directory
dataviruset
bydataviruset, February 4, 2014
Good, good, but I had to modify it to get SNMPv3 access.
These are the modified code parts:
usage_and_exit() unless
GetOptions("h|help" => \$opt_h,
"C|community=s" => \$snmp_community,
"w|warning=s" => \$warn_usage,
"c|critical=s" => \$crit_usage,
"p|port=i" => \$port,
"i|interface=s" => \$iface_descr,
"H|hostname=s" => \$host_address,
"a|authproto=s" => \$snmp_authproto,
"u|username=s" => \$snmp_username,
"x|password=s" => \$snmp_password,
"X|privpasswd=s" => \$snmp_privpasswd,
"P|privproto=s" => \$snmp_privproto,
"v|version=s" => \$snmp_version
);
elsif ( $snmp_version == /3/ ) {
($session, $error) = Net::SNMP->session(
-hostname => $host_address,
-version => $snmp_version,
-username => $snmp_username,
-port => $port,
-authpassword => $snmp_password,
-authprotocol => $snmp_authproto,
-privpassword => $snmp_privpasswd,
-privprotocol => $snmp_privproto,
);
if ( !defined($session) ) {
print("UNKNOWN: $error");
exit STATUS_UNKNOWN;
}
}
print "Check_all_interfaces.pl version " . VERSION . "\n(c) 2008 M. Lievaart\n";
print "Usage: $0 -H host [ options ]\n\n";
print "Options:\n";
print " -H --host STRING or IPADDRESS\n";
print " Check interface on the indicated host.\n";
print " -C --community STRING \n";
print " SNMP Community.\n";
print " -i --interface STRING\n";
print " Regexp matching interfaces to examine, f.i. '^FastEthernet' or '^(Eth|Dot.*0\$)'.\n";
print " -w --warning INTEGER\n";
print " number of necessary errors since last check to result in warning status (default: 1)\n";
print " -c --critical INTEGER\n";
print " number of necessary errors since last check to result in critical status (default: 5)\n";
print " -v --version [1, 2 or 3]\n";
print " SNMP version to use, use '2' for version 2c. (default: version 2c).\n";
print " -a --authproto STRING\n";
print " SNMP auth protocol to use for SNMPv3. (default: md5).\n";
print " -P --privproto STRING\n";
print " SNMP private protocol to use for SNMPv3. (default: des).\n";
print " -X --privpasswd STRING\n";
print " SNMP private password to use for SNMPv3.\n";
print " -u --username STRING\n";
print " SNMP username to use for SNMPv3.\n";
print " -x --password STRING\n";
print " SNMP password to use for SNMPv3.\n";
These are the modified code parts:
usage_and_exit() unless
GetOptions("h|help" => \$opt_h,
"C|community=s" => \$snmp_community,
"w|warning=s" => \$warn_usage,
"c|critical=s" => \$crit_usage,
"p|port=i" => \$port,
"i|interface=s" => \$iface_descr,
"H|hostname=s" => \$host_address,
"a|authproto=s" => \$snmp_authproto,
"u|username=s" => \$snmp_username,
"x|password=s" => \$snmp_password,
"X|privpasswd=s" => \$snmp_privpasswd,
"P|privproto=s" => \$snmp_privproto,
"v|version=s" => \$snmp_version
);
elsif ( $snmp_version == /3/ ) {
($session, $error) = Net::SNMP->session(
-hostname => $host_address,
-version => $snmp_version,
-username => $snmp_username,
-port => $port,
-authpassword => $snmp_password,
-authprotocol => $snmp_authproto,
-privpassword => $snmp_privpasswd,
-privprotocol => $snmp_privproto,
);
if ( !defined($session) ) {
print("UNKNOWN: $error");
exit STATUS_UNKNOWN;
}
}
print "Check_all_interfaces.pl version " . VERSION . "\n(c) 2008 M. Lievaart\n";
print "Usage: $0 -H host [ options ]\n\n";
print "Options:\n";
print " -H --host STRING or IPADDRESS\n";
print " Check interface on the indicated host.\n";
print " -C --community STRING \n";
print " SNMP Community.\n";
print " -i --interface STRING\n";
print " Regexp matching interfaces to examine, f.i. '^FastEthernet' or '^(Eth|Dot.*0\$)'.\n";
print " -w --warning INTEGER\n";
print " number of necessary errors since last check to result in warning status (default: 1)\n";
print " -c --critical INTEGER\n";
print " number of necessary errors since last check to result in critical status (default: 5)\n";
print " -v --version [1, 2 or 3]\n";
print " SNMP version to use, use '2' for version 2c. (default: version 2c).\n";
print " -a --authproto STRING\n";
print " SNMP auth protocol to use for SNMPv3. (default: md5).\n";
print " -P --privproto STRING\n";
print " SNMP private protocol to use for SNMPv3. (default: des).\n";
print " -X --privpasswd STRING\n";
print " SNMP private password to use for SNMPv3.\n";
print " -u --username STRING\n";
print " SNMP username to use for SNMPv3.\n";
print " -x --password STRING\n";
print " SNMP password to use for SNMPv3.\n";