perfsonar-dev - perfsonar: r2302 - trunk/perfsonar/contrib/FlowMP-manager
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: perfsonar: r2302 - trunk/perfsonar/contrib/FlowMP-manager
- Date: Wed, 28 Mar 2007 08:30:32 -0400
Author: gijs
Date: 2007-03-28 08:30:32 -0400 (Wed, 28 Mar 2007)
New Revision: 2302
Modified:
trunk/perfsonar/contrib/FlowMP-manager/common.py
trunk/perfsonar/contrib/FlowMP-manager/manager.py
trunk/perfsonar/contrib/FlowMP-manager/process.py
Log:
changed os.system to os.spawn, so no shell is used + some other small
improvements
Modified: trunk/perfsonar/contrib/FlowMP-manager/common.py
===================================================================
--- trunk/perfsonar/contrib/FlowMP-manager/common.py 2007-03-27 16:18:21
UTC (rev 2301)
+++ trunk/perfsonar/contrib/FlowMP-manager/common.py 2007-03-28 12:30:32
UTC (rev 2302)
@@ -11,10 +11,8 @@
import config
import filter
+#fc = filter.FilterChecker()
-
-fc = filter.FilterChecker()
-
class Client:
def __init__(self, address=None, port=None, routers=[], filter=None, \
netflow=None, transport=None, zebedeePid=None,
@@ -52,10 +50,12 @@
f = root.find('filter').text
# check if there is a filter, and if it is okay
if f and f.strip():
- if fc.check(f):
- client.filter = f.strip()
- else:
- logging.warning("evil filter defined!!!")
+ client.filter = f.strip()
+ ## Filter isn't finished. Bad Filter gives no output now, good
filter is client respons.
+ #if fc.check(f):
+ # client.filter = f.strip()
+ #else:
+ # logging.warning("evil filter defined!!!")
else:
client.filter = None
Modified: trunk/perfsonar/contrib/FlowMP-manager/manager.py
===================================================================
--- trunk/perfsonar/contrib/FlowMP-manager/manager.py 2007-03-27 16:18:21
UTC (rev 2301)
+++ trunk/perfsonar/contrib/FlowMP-manager/manager.py 2007-03-28 12:30:32
UTC (rev 2302)
@@ -5,6 +5,7 @@
start: --start / -s
stop: --stop / -q
+restart: --restart / -r
"""
@@ -81,7 +82,7 @@
def main():
try:
- opts, args = getopt.getopt(sys.argv[1:], "hsq", ["help", "start",
"stop"])
+ opts, args = getopt.getopt(sys.argv[1:], "hsrq", ["help", "start",
"stop", "restart"])
except getopt.GetoptError:
print __doc__
sys.exit(2)
@@ -99,6 +100,12 @@
stop()
sys.exit()
+ if options in ("-r", "--restart"):
+ stop()
+ start()
+ sys.exit()
+
+
print __doc__
sys.exit(2)
Modified: trunk/perfsonar/contrib/FlowMP-manager/process.py
===================================================================
--- trunk/perfsonar/contrib/FlowMP-manager/process.py 2007-03-27 16:18:21
UTC (rev 2301)
+++ trunk/perfsonar/contrib/FlowMP-manager/process.py 2007-03-28 12:30:32
UTC (rev 2302)
@@ -35,38 +35,29 @@
rawFile = os.path.join(config.baseDir, 'flows', exporter, 'raw',
nfcapFile)
if not os.access(rawFile, os.R_OK):
logging.error("can't read nfcapd file! (%s)" % rawFile)
- sys.exit(2)
+ #sys.exit(2)
anonDir = os.path.join(config.baseDir, 'flows', exporter,
'processed')
anonFile = os.path.join(anonDir, self.client.id)
if not os.access(anonDir, os.W_OK):
logging.error("can't write output file (%s)" % anonFile)
- sys.exit(2)
+ #sys.exit(2)
- cmd = ("%s -r %s -K %s -w %s" % (config.nfdump, rawFile, makekey(),
anonFile))
- if self.client.filter: cmd += " \"" + self.client.filter + "\""
- logging.info("running: %s (client %s)" % (cmd, self.client.id))
- if os.system(cmd) != 0: logging.warning("COMMAND FAILED: %s" % cmd)
+ args = ['nfdump', '-r', rawFile, '-K', self.client.key, '-w',
anonFile]
+ if self.client.filter: args += [ self.client.filter ]
+ logging.info("running: %s (client %s)" % (" ".join(args),
self.client.id))
+ errorCode = os.spawnv(os.P_WAIT, config.nfdump, args)
+ if errorCode != 0:
+ logging.warning("COMMAND FAILED: %s (process returned error code
%s)" % (" ".join(args), errorCode) )
- cmd = "%s -p %s -r %s" % (config.nfreplay, self.port, anonFile)
- logging.info("running: %s (client %s)" % (cmd, self.client.id))
- if os.system(cmd) != 0: logging.warning("COMMAND FAILED: %s" % cmd)
+ args = ['nfdump', '-p', str(self.port), '-r', anonFile]
+ logging.info("running: %s (client %s)" % (" ".join(args),
self.client.id))
+ errorCode = os.spawnv(os.P_WAIT, config.nfreplay, args)
+ if errorCode != 0:
+ logging.warning("COMMAND FAILED: %s (process returned error code
%s)" % (" ".join(args), errorCode) )
-def makekey():
- """
- make a random 32 char key.
- we want our flows anonimized, so we make a random key"
-
- """
-
- s = ''
- for i in range(32): s += choice(letters)
- return s
-
-
-
def main():
if len(sys.argv) != 3:
print __doc__
@@ -107,9 +98,12 @@
t.join()
logging.info("removing %s" % rawFile )
- os.unlink(rawFile)
+ try:
+ os.unlink(rawFile)
+ except OSError, errMsg:
+ logging.error('cant delete file (%s). Reason: %s' % (rawFile,
errMsg))
+
-
if __name__ == '__main__':
main()
- perfsonar: r2302 - trunk/perfsonar/contrib/FlowMP-manager, svnlog, 03/28/2007
Archive powered by MHonArc 2.6.16.