2to3/manual: check_livestatus_latency.py
This commit is contained in:
parent
a49297eda7
commit
97d6a3669e
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
# (c) 2016- by Sven Velt, Germany #
|
||||||
# sven-mymonplugins@velt.biz #
|
# sven-mymonplugins@velt.biz #
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "velt.biz - My Monitoring Plugins" #
|
||||||
|
@ -29,19 +29,18 @@ import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from monitoringplugin import MonitoringPlugin
|
from MyMonPlugin import MonitoringPlugin
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print '=========================='
|
print('==========================')
|
||||||
print 'AIKS! Python import error!'
|
print('AIKS! Python import error!')
|
||||||
print '==========================\n'
|
print('==========================\n')
|
||||||
print 'Could not find "monitoringplugin.py"!\n'
|
print('Could not find class "MonitoringPlugin"!\n')
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
print('Did you download "%s"' % os.path.basename(sys.argv[0]))
|
||||||
print 'without "monitoringplugin.py"?\n'
|
print('without "MyMonPlugin/"?\n')
|
||||||
print 'Please go back to'
|
print('Please go back to')
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
print('https://gogs.velt.biz/velt.biz/MyMonPlugins and:')
|
||||||
print 'or even better:'
|
print('- get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases')
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
print('- or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n')
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
sys.exit(127)
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +82,7 @@ if not os.access(plugin.options.socket, os.W_OK):
|
||||||
plugin.back2nagios(3, 'Could not read from socket "%s"' % plugin.options.socket)
|
plugin.back2nagios(3, 'Could not read from socket "%s"' % plugin.options.socket)
|
||||||
# FIXME: End
|
# FIXME: End
|
||||||
|
|
||||||
cmd_svc='''GET services
|
cmd_svc=b'''GET services
|
||||||
OutputFormat: csv
|
OutputFormat: csv
|
||||||
Stats: min latency
|
Stats: min latency
|
||||||
Stats: max latency
|
Stats: max latency
|
||||||
|
@ -93,7 +92,7 @@ Stats: max execution_time
|
||||||
Stats: avg execution_time
|
Stats: avg execution_time
|
||||||
'''
|
'''
|
||||||
|
|
||||||
cmd_hst='''GET hosts
|
cmd_hst=b'''GET hosts
|
||||||
OutputFormat: csv
|
OutputFormat: csv
|
||||||
Stats: min latency
|
Stats: min latency
|
||||||
Stats: max latency
|
Stats: max latency
|
||||||
|
@ -116,7 +115,7 @@ try:
|
||||||
s.settimeout(10)
|
s.settimeout(10)
|
||||||
data = s.recv(32768)
|
data = s.recv(32768)
|
||||||
if data:
|
if data:
|
||||||
answer += data
|
answer += data.decode('utf-8')
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
|
@ -142,7 +141,7 @@ try:
|
||||||
s.settimeout(10)
|
s.settimeout(10)
|
||||||
data = s.recv(32768)
|
data = s.recv(32768)
|
||||||
if data:
|
if data:
|
||||||
answer += data
|
answer += data.decode('utf-8')
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
|
|
Loading…
Reference in a new issue