@@ -31,7 +31,8 @@
def apc_snmp(command, oid_tail):
# private.enterprises.apc.hardware.rPDU
rpdu = "iso.org.dod.internet.private.enterprises.318.1.1.12"
- common_options = "-OvQ -v 1 -c %(community)s %(host)s" % {
+ common_options = "-T %(timeout)s -OvQ -v 1 -c %(community)s %(host)s" % {
+ "timeout": opt_T,
"community": opt_C,
"host": opt_H,
}
@@ -81,7 +82,7 @@
sys.exit(errors['UNKNOWN']);
def print_usage():
- print "Usage: %(progname)s -H <Hostname> -C <Community> [-w <warn>] [-c <crit>] [-v] [-h]" % {"progname" : progname}
+ print "Usage: %(progname)s -H <Hostname> -C <Community> [-T <timeout>] [-w <warn>] [-c <crit>] [-v] [-h]" % {"progname" : progname}
if opt_h:
pass
else:
@@ -95,6 +96,7 @@
print
print "-H <Hostname> = Hostname or IP-Address."
print "-C <Community> = Community read password."
+ print "-T <timeout> = Timeout in seconds."
print "-v = Verbose Output."
print "-h = This screen."
print
@@ -112,7 +114,7 @@
if __name__ == '__main__':
opt_h = verbose = opt_w = opt_H = opt_C = opt_c = None
- opts, args = getopt(sys.argv[1:], "Vhvw:H:C:c:")
+ opts, args = getopt(sys.argv[1:], "Vhvw:H:C:c:T:")
for o, a in opts:
if o in ("-V", "--version"):
print_revision(progname, progversion)
@@ -131,12 +133,17 @@
opt_C = a
if o in ("-c", "--critical"):
opt_c = a
+ if o in ("-T", "--timeout"):
+ opt_T = a
if opt_H and opt_C:
pass
else:
print_usage()
-
+
+ if not opt_T
+ opt_T = 1
+
apc_info = snmpconnect()
critical = None
|