monitoringplugin: Cache values as well when using cmdline tools.
This is even more important imho :-)
This commit is contained in:
parent
ba0184341f
commit
0c44bdc599
|
@ -614,6 +614,10 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
|
||||||
cmdline = self.__CMDLINE_get % oid
|
cmdline = self.__CMDLINE_get % oid
|
||||||
self.verbose(2, cmdline)
|
self.verbose(2, cmdline)
|
||||||
|
|
||||||
|
if oid in self.__SNMP_Cache:
|
||||||
|
self.verbose(2, "(CACHED) %s" % (self.__SNMP_Cache[oid]))
|
||||||
|
return self.__SNMP_Cache[oid]
|
||||||
|
|
||||||
cmd = os.popen(cmdline)
|
cmd = os.popen(cmdline)
|
||||||
out = cmd.readline().rstrip().replace('"','')
|
out = cmd.readline().rstrip().replace('"','')
|
||||||
retcode = cmd.close()
|
retcode = cmd.close()
|
||||||
|
@ -628,6 +632,8 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
|
||||||
else:
|
else:
|
||||||
self.back2nagios(3, 'Unknown error code "' + str(retcode) + '" from command line utils')
|
self.back2nagios(3, 'Unknown error code "' + str(retcode) + '" from command line utils')
|
||||||
|
|
||||||
|
self.__SNMP_Cache[oid] = out
|
||||||
|
|
||||||
self.verbose(1, out)
|
self.verbose(1, out)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
@ -639,6 +645,10 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
|
||||||
cmdline = self.__CMDLINE_walk % oid
|
cmdline = self.__CMDLINE_walk % oid
|
||||||
self.verbose(2, cmdline)
|
self.verbose(2, cmdline)
|
||||||
|
|
||||||
|
if oid in self.__SNMP_Cache:
|
||||||
|
self.verbose(2, "(CACHED) %s" % (self.__SNMP_Cache[oid]))
|
||||||
|
return self.__SNMP_Cache[oid]
|
||||||
|
|
||||||
cmd = os.popen(cmdline)
|
cmd = os.popen(cmdline)
|
||||||
out = cmd.readlines()
|
out = cmd.readlines()
|
||||||
retcode = cmd.close()
|
retcode = cmd.close()
|
||||||
|
@ -656,6 +666,8 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
|
||||||
for line in range(0,len(out)):
|
for line in range(0,len(out)):
|
||||||
out[line] = out[line].rstrip().replace('"','')
|
out[line] = out[line].rstrip().replace('"','')
|
||||||
|
|
||||||
|
self.__SNMP_Cache[oid] = out
|
||||||
|
|
||||||
self.verbose(1, str(out))
|
self.verbose(1, str(out))
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue