Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
- fixed issue where Cisco 4321 Integrated Services Router reports negative values as temperature thresholds
- changed from SNMP GETNEXT to GETBULK command to improve performance over high-latency connections
  • Loading branch information
m-erhardt committed Jul 21, 2021
1 parent 77bdd50 commit da10818
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions check_cisco_envtemp.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys
from argparse import ArgumentParser
from itertools import chain
from pysnmp.hlapi import nextCmd, SnmpEngine, UsmUserData, \
from pysnmp.hlapi import bulkCmd, SnmpEngine, UsmUserData, \
UdpTransportTarget, \
ObjectType, ObjectIdentity, \
ContextData, usmHMACMD5AuthProtocol, \
Expand Down Expand Up @@ -91,13 +91,14 @@ def get_snmp_table(table_oid, args):
# initialize empty list for return object
table = []

iterator = nextCmd(
iterator = bulkCmd(
SnmpEngine(),
UsmUserData(args.user, args.authkey, args.privkey,
authProtocol=authprot[args.authmode],
privProtocol=privprot[args.privmode]),
UdpTransportTarget((args.host, args.port), timeout=args.timeout),
ContextData(),
0, 50,
ObjectType(ObjectIdentity(table_oid)),
lexicographicMode=False
)
Expand Down Expand Up @@ -276,9 +277,9 @@ def main():
output += ''.join([str(val), "°C, "])

# Calculate return code
if val >= crit:
if val >= crit > 0:
returncode = "2"
elif (val >= warn) and (returncode != "2"):
elif (val >= warn > 0) and (returncode != "2"):
returncode = "1"

# Remove last comma from output string
Expand Down

0 comments on commit da10818

Please sign in to comment.