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 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
@ -302,7 +302,7 @@ class MonitoringPlugin(object):
|
||||||
|
|
||||||
|
|
||||||
def seconds_to_timedelta(self, seconds):
|
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=['',]):
|
def human_to_number(self, value, total=None, unit=['',]):
|
||||||
|
@ -365,12 +365,12 @@ class MonitoringPlugin(object):
|
||||||
bol = 'V' + str(level) + ':' + ' ' * level
|
bol = 'V' + str(level) + ':' + ' ' * level
|
||||||
if prefix:
|
if prefix:
|
||||||
bol += '%s' % prefix
|
bol += '%s' % prefix
|
||||||
if type(output) in [str, unicode, ]:
|
if type(output) in [str, str, ]:
|
||||||
print(bol + output)
|
print((bol + output))
|
||||||
elif type(output) in [list, ]:
|
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:
|
else:
|
||||||
print('%s%s' % (bol, output) )
|
print(('%s%s' % (bol, output) ))
|
||||||
|
|
||||||
|
|
||||||
def max_returncode(self, returncodes):
|
def max_returncode(self, returncodes):
|
||||||
|
@ -423,7 +423,7 @@ class MonitoringPlugin(object):
|
||||||
|
|
||||||
# Exit program or return output line(s)
|
# Exit program or return output line(s)
|
||||||
if exit:
|
if exit:
|
||||||
print out
|
print(out)
|
||||||
sys.exit(returncode)
|
sys.exit(returncode)
|
||||||
else:
|
else:
|
||||||
return (returncode, out)
|
return (returncode, out)
|
||||||
|
@ -556,18 +556,18 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
|
||||||
idx = ''
|
idx = ''
|
||||||
|
|
||||||
if self.options.snmpversion in [1, '1']:
|
if self.options.snmpversion in [1, '1']:
|
||||||
value_low = long(self.SNMPGET_wrapper(baseoid[1] + idx, exitonerror=exitonerror))
|
value_low = int(self.SNMPGET_wrapper(baseoid[1] + idx, exitonerror=exitonerror))
|
||||||
if value_low < 0L:
|
if value_low < 0:
|
||||||
value_low += 2 ** 32
|
value_low += 2 ** 32
|
||||||
|
|
||||||
value_hi = long(self.SNMPGET_wrapper(baseoid[2] + idx, exitonerror=exitonerror))
|
value_hi = int(self.SNMPGET_wrapper(baseoid[2] + idx, exitonerror=exitonerror))
|
||||||
if value_hi < 0L:
|
if value_hi < 0:
|
||||||
value_hi += 2 ** 32
|
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']:
|
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:
|
elif type(baseoid) in (str, ) and idx != None:
|
||||||
return self.SNMPGET_wrapper(baseoid + '.' + str(idx), exitonerror=exitonerror)
|
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) )
|
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)
|
ret = myplugin.back2nagios(0, 'Nr. 20: Plugin with string-based multiline output', 'Line 2\nLine 3\nLine4', exit=False)
|
||||||
print ret[1]
|
print(ret[1])
|
||||||
print 'Returncode: ' + str(ret[0])
|
print('Returncode: ' + str(ret[0]))
|
||||||
ret = myplugin.back2nagios(0, 'Nr. 21: Plugin with list-based multiline output', ['Line 2', 'Line 3', 'Line4'], exit=False)
|
ret = myplugin.back2nagios(0, 'Nr. 21: Plugin with list-based multiline output', ['Line 2', 'Line 3', 'Line4'], exit=False)
|
||||||
print ret[1]
|
print(ret[1])
|
||||||
print 'Returncode: ' + str(ret[0])
|
print('Returncode: ' + str(ret[0]))
|
||||||
ret = myplugin.back2nagios(0, 'Nr. 22: Plugin with tuple-based multiline output', ('Line 2', 'Line 3', 'Line4'), exit=False)
|
ret = myplugin.back2nagios(0, 'Nr. 22: Plugin with tuple-based multiline output', ('Line 2', 'Line 3', 'Line4'), exit=False)
|
||||||
print ret[1]
|
print(ret[1])
|
||||||
print 'Returncode: ' + str(ret[0])
|
print('Returncode: ' + str(ret[0]))
|
||||||
|
|
||||||
myplugin.add_performancedata('Val1', 42, '')
|
myplugin.add_performancedata('Val1', 42, '')
|
||||||
myplugin.add_performancedata('Val2', 23, 'c', warn=10, crit=20, min=0, max=100)
|
myplugin.add_performancedata('Val2', 23, 'c', warn=10, crit=20, min=0, max=100)
|
||||||
|
|
Loading…
Reference in a new issue