Skip to content

Commit 4aa597e

Browse files
committed
changed error handling, now sensor in general is more performant
1 parent 99bf3e5 commit 4aa597e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sensors/snmptraffic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
logging.error("PySNMP could not be imported. SNMP Sensors won't work.Error: %s" % e)
3030
sys.exit()
3131

32-
33-
3432
class SNMPTraffic(object):
3533

3634
def __init__(self):
@@ -139,6 +137,8 @@ def snmp_get(self, target, countertype, community, port, ifindex):
139137
snmpget = cmdgen.CommandGenerator()
140138
error_indication, error_status, error_index, var_binding = snmpget.getCmd(
141139
cmdgen.CommunityData(community), cmdgen.UdpTransportTarget((target, port)), *data)
140+
if error_indication:
141+
raise Exception(error_indication)
142142
if countertype == "1":
143143
#print var_binding[0][1]
144144
#print var_binding[1][1]
@@ -191,6 +191,7 @@ def get_data(data, out_queue):
191191
data['community'], int(data['port']), data['ifindex'])
192192
logging.info("Running sensor: %s" % snmptraffic.get_kind())
193193
except Exception as get_data_error:
194+
print get_data_error
194195
logging.error("Ooops Something went wrong with '%s' sensor %s. Error: %s" % (snmptraffic.get_kind(),
195196
data['sensorid'],
196197
get_data_error))

0 commit comments

Comments
 (0)