2to3/manual: check_netconnections.py
This commit is contained in:
parent
9be96f3705
commit
c2336a1cd2
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
||||||
# sv@teamix.net #
|
# sv@teamix.net #
|
||||||
# (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" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
||||||
|
@ -30,19 +30,18 @@ import re
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,16 +102,13 @@ for version in versions:
|
||||||
matcher = v4match
|
matcher = v4match
|
||||||
|
|
||||||
for proto in protos:
|
for proto in protos:
|
||||||
filename = '/proc/net/%s%s' % (proto, version)
|
with open('/proc/net/%s%s' % (proto, version)) as fh:
|
||||||
f = file(filename)
|
for line in fh:
|
||||||
lines = f.readlines()
|
m = matcher.match(line)
|
||||||
|
if m:
|
||||||
for line in lines:
|
port = int(m.group(2), 16)
|
||||||
m = matcher.match(line)
|
if port == plugin.options.port and m.group(3) not in ['00000000','00000000000000000000000000000000']:
|
||||||
if m:
|
count += 1
|
||||||
port = int(m.group(2), 16)
|
|
||||||
if port == plugin.options.port and m.group(3) not in ['00000000','00000000000000000000000000000000']:
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
|
|
||||||
returncode = plugin.value_wc_to_returncode(count, plugin.options.warn, plugin.options.crit)
|
returncode = plugin.value_wc_to_returncode(count, plugin.options.warn, plugin.options.crit)
|
||||||
|
|
Loading…
Reference in a new issue