2to3: monitoringplugin.py (WIP)
No more changes made
This commit is contained in:
parent
95aad74ded
commit
684be87f62
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
#####################################################################
|
||||
|
@ -302,7 +302,7 @@ class MonitoringPlugin(object):
|
|||
|
||||
|
||||
def seconds_to_timedelta(self, seconds):
|
||||
return datetime.timedelta(seconds=long(seconds))
|
||||
return datetime.timedelta(seconds=int(seconds))
|
||||
|
||||
|
||||
def human_to_number(self, value, total=None, unit=['',]):
|
||||
|
@ -365,12 +365,12 @@ class MonitoringPlugin(object):
|
|||
bol = 'V' + str(level) + ':' + ' ' * level
|
||||
if prefix:
|
||||
bol += '%s' % prefix
|
||||
if type(output) in [str, unicode, ]:
|
||||
print(bol + output)
|
||||
if type(output) in [str, str, ]:
|
||||
print((bol + output))
|
||||
elif type(output) in [list, ]:
|
||||
print('\n'.join( ['%s%s' % (bol, l) for l in output] ) )
|
||||
print(('\n'.join( ['%s%s' % (bol, l) for l in output] ) ))
|
||||
else:
|
||||
print('%s%s' % (bol, output) )
|
||||
print(('%s%s' % (bol, output) ))
|
||||
|
||||
|
||||
def max_returncode(self, returncodes):
|
||||
|
@ -423,7 +423,7 @@ class MonitoringPlugin(object):
|
|||
|
||||
# Exit program or return output line(s)
|
||||
if exit:
|
||||
print out
|
||||
print(out)
|
||||
sys.exit(returncode)
|
||||
else:
|
||||
return (returncode, out)
|
||||
|
@ -556,18 +556,18 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
|
|||
idx = ''
|
||||
|
||||
if self.options.snmpversion in [1, '1']:
|
||||
value_low = long(self.SNMPGET_wrapper(baseoid[1] + idx, exitonerror=exitonerror))
|
||||
if value_low < 0L:
|
||||
value_low = int(self.SNMPGET_wrapper(baseoid[1] + idx, exitonerror=exitonerror))
|
||||
if value_low < 0:
|
||||
value_low += 2 ** 32
|
||||
|
||||
value_hi = long(self.SNMPGET_wrapper(baseoid[2] + idx, exitonerror=exitonerror))
|
||||
if value_hi < 0L:
|
||||
value_hi = int(self.SNMPGET_wrapper(baseoid[2] + idx, exitonerror=exitonerror))
|
||||
if value_hi < 0:
|
||||
value_hi += 2 ** 32
|
||||
|
||||
return value_hi * 2L ** 32L + value_low
|
||||
return value_hi * 2 ** 32 + value_low
|
||||
|
||||
elif self.options.snmpversion in [2, 3, '2', '2c', '3']:
|
||||
return long(self.SNMPGET_wrapper(baseoid[0] + idx, exitonerror=exitonerror))
|
||||
return int(self.SNMPGET_wrapper(baseoid[0] + idx, exitonerror=exitonerror))
|
||||
|
||||
elif type(baseoid) in (str, ) and idx != None:
|
||||
return self.SNMPGET_wrapper(baseoid + '.' + str(idx), exitonerror=exitonerror)
|
||||
|
@ -703,14 +703,14 @@ def main():
|
|||
pprint(myplugin.back2nagios(3, 'Nr. 13: Exit Code UNKNOWN', exit=False) )
|
||||
|
||||
ret = myplugin.back2nagios(0, 'Nr. 20: Plugin with string-based multiline output', 'Line 2\nLine 3\nLine4', exit=False)
|
||||
print ret[1]
|
||||
print 'Returncode: ' + str(ret[0])
|
||||
print(ret[1])
|
||||
print('Returncode: ' + str(ret[0]))
|
||||
ret = myplugin.back2nagios(0, 'Nr. 21: Plugin with list-based multiline output', ['Line 2', 'Line 3', 'Line4'], exit=False)
|
||||
print ret[1]
|
||||
print 'Returncode: ' + str(ret[0])
|
||||
print(ret[1])
|
||||
print('Returncode: ' + str(ret[0]))
|
||||
ret = myplugin.back2nagios(0, 'Nr. 22: Plugin with tuple-based multiline output', ('Line 2', 'Line 3', 'Line4'), exit=False)
|
||||
print ret[1]
|
||||
print 'Returncode: ' + str(ret[0])
|
||||
print(ret[1])
|
||||
print('Returncode: ' + str(ret[0]))
|
||||
|
||||
myplugin.add_performancedata('Val1', 42, '')
|
||||
myplugin.add_performancedata('Val2', 23, 'c', warn=10, crit=20, min=0, max=100)
|
||||
|
|
Loading…
Reference in a new issue