2to3/manual: check_netconnections.py
This commit is contained in:
parent
9be96f3705
commit
c2336a1cd2
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
#####################################################################
|
||||
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
||||
# sv@teamix.net #
|
||||
# (c) 2016 by Sven Velt, Germany #
|
||||
# (c) 2016- by Sven Velt, Germany #
|
||||
# sven-mymonplugins@velt.biz #
|
||||
# #
|
||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
||||
|
@ -30,19 +30,18 @@ import re
|
|||
import sys
|
||||
|
||||
try:
|
||||
from monitoringplugin import MonitoringPlugin
|
||||
from MyMonPlugin import MonitoringPlugin
|
||||
except ImportError:
|
||||
print '=========================='
|
||||
print 'AIKS! Python import error!'
|
||||
print '==========================\n'
|
||||
print 'Could not find "monitoringplugin.py"!\n'
|
||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
||||
print 'without "monitoringplugin.py"?\n'
|
||||
print 'Please go back to'
|
||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
||||
print 'or even better:'
|
||||
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('==========================')
|
||||
print('AIKS! Python import error!')
|
||||
print('==========================\n')
|
||||
print('Could not find class "MonitoringPlugin"!\n')
|
||||
print('Did you download "%s"' % os.path.basename(sys.argv[0]))
|
||||
print('without "MyMonPlugin/"?\n')
|
||||
print('Please go back to')
|
||||
print('https://gogs.velt.biz/velt.biz/MyMonPlugins and:')
|
||||
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')
|
||||
sys.exit(127)
|
||||
|
||||
|
||||
|
@ -103,11 +102,8 @@ for version in versions:
|
|||
matcher = v4match
|
||||
|
||||
for proto in protos:
|
||||
filename = '/proc/net/%s%s' % (proto, version)
|
||||
f = file(filename)
|
||||
lines = f.readlines()
|
||||
|
||||
for line in lines:
|
||||
with open('/proc/net/%s%s' % (proto, version)) as fh:
|
||||
for line in fh:
|
||||
m = matcher.match(line)
|
||||
if m:
|
||||
port = int(m.group(2), 16)
|
||||
|
|
Loading…
Reference in a new issue