updated all print calls to use print() method for 2/3

This commit is contained in:
bharnden 2019-05-05 16:52:55 -07:00
parent e58cbe9421
commit feebd8704f
11 changed files with 89 additions and 95 deletions

View file

@ -55,9 +55,9 @@ def example(options):
def main(): def main():
options = parser.parse_options("emane80211") options = parser.parse_options("emane80211")
start = datetime.datetime.now() start = datetime.datetime.now()
print "running emane 80211 example: nodes(%s) time(%s)" % (options.nodes, options.time) print("running emane 80211 example: nodes(%s) time(%s)" % (options.nodes, options.time))
example(options) example(options)
print "elapsed time: %s" % (datetime.datetime.now() - start) print("elapsed time: %s" % (datetime.datetime.now() - start))
if __name__ == "__main__" or __name__ == "__builtin__": if __name__ == "__main__" or __name__ == "__builtin__":

View file

@ -44,10 +44,10 @@ def example(options):
first_node = session.get_node(2) first_node = session.get_node(2)
last_node = session.get_node(options.nodes + 1) last_node = session.get_node(options.nodes + 1)
print "starting iperf server on node: %s" % first_node.name print("starting iperf server on node: %s" % first_node.name)
first_node.cmd(["iperf", "-s", "-D"]) first_node.cmd(["iperf", "-s", "-D"])
first_node_address = prefixes.ip4_address(first_node) first_node_address = prefixes.ip4_address(first_node)
print "node %s connecting to %s" % (last_node.name, first_node_address) print("node %s connecting to %s" % (last_node.name, first_node_address))
last_node.client.icmd(["iperf", "-t", str(options.time), "-c", first_node_address]) last_node.client.icmd(["iperf", "-t", str(options.time), "-c", first_node_address])
first_node.cmd(["killall", "-9", "iperf"]) first_node.cmd(["killall", "-9", "iperf"])
@ -59,9 +59,9 @@ def main():
options = parser.parse_options("switch") options = parser.parse_options("switch")
start = datetime.datetime.now() start = datetime.datetime.now()
print "running switch example: nodes(%s) time(%s)" % (options.nodes, options.time) print("running switch example: nodes(%s) time(%s)" % (options.nodes, options.time))
example(options) example(options)
print "elapsed time: %s" % (datetime.datetime.now() - start) print("elapsed time: %s" % (datetime.datetime.now() - start))
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -48,10 +48,10 @@ def example(options):
first_node = session.get_node(2) first_node = session.get_node(2)
last_node = session.get_node(options.nodes + 1) last_node = session.get_node(options.nodes + 1)
print "starting iperf server on node: %s" % first_node.name print("starting iperf server on node: %s" % first_node.name)
first_node.cmd(["iperf", "-s", "-D"]) first_node.cmd(["iperf", "-s", "-D"])
address = prefixes.ip4_address(first_node) address = prefixes.ip4_address(first_node)
print "node %s connecting to %s" % (last_node.name, address) print("node %s connecting to %s" % (last_node.name, address))
last_node.client.icmd(["iperf", "-t", str(options.time), "-c", address]) last_node.client.icmd(["iperf", "-t", str(options.time), "-c", address])
first_node.cmd(["killall", "-9", "iperf"]) first_node.cmd(["killall", "-9", "iperf"])
@ -63,9 +63,9 @@ def main():
options = parser.parse_options("wlan") options = parser.parse_options("wlan")
start = datetime.datetime.now() start = datetime.datetime.now()
print "running wlan example: nodes(%s) time(%s)" % (options.nodes, options.time) print("running wlan example: nodes(%s) time(%s)" % (options.nodes, options.time))
example(options) example(options)
print "elapsed time: %s" % (datetime.datetime.now() - start) print("elapsed time: %s" % (datetime.datetime.now() - start))
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -65,7 +65,7 @@ def cmd(node, exec_cmd):
msgdata = server.sock.recv(msglen) msgdata = server.sock.recv(msglen)
# If we get the right response return the results # If we get the right response return the results
print "received response message: %s" % MessageTypes(msgtype) print("received response message: %s" % MessageTypes(msgtype))
if msgtype == MessageTypes.EXECUTE.value: if msgtype == MessageTypes.EXECUTE.value:
msg = coreapi.CoreExecMessage(msgflags, msghdr, msgdata) msg = coreapi.CoreExecMessage(msgflags, msghdr, msgdata)
result = msg.get_tlv(ExecuteTlvs.RESULT.value) result = msg.get_tlv(ExecuteTlvs.RESULT.value)
@ -120,7 +120,7 @@ def main():
port = int(daemonport[1]) port = int(daemonport[1])
else: else:
port = CORE_API_PORT port = CORE_API_PORT
print "connecting to daemon at %s:%d" % (daemon, port) print("connecting to daemon at %s:%d" % (daemon, port))
session.broker.addserver(daemon, daemonip, port) session.broker.addserver(daemon, daemonip, port)
# Set the local session id to match the port. # Set the local session id to match the port.
@ -145,7 +145,7 @@ def main():
number_of_nodes = options.numnodes number_of_nodes = options.numnodes
print "creating %d remote nodes with addresses from %s" % (options.numnodes, prefix) print("creating %d remote nodes with addresses from %s" % (options.numnodes, prefix))
# create remote nodes via API # create remote nodes via API
for i in range(1, number_of_nodes + 1): for i in range(1, number_of_nodes + 1):
@ -175,13 +175,11 @@ def main():
session.broker.handlerawmsg(msg) session.broker.handlerawmsg(msg)
# Get the ip or last node and ping it from the first # Get the ip or last node and ping it from the first
print "Pinging from the first to the last node" print("Pinging from the first to the last node")
pingip = cmd(n[-1], "ip -4 -o addr show dev eth0").split()[3].split("/")[0] pingip = cmd(n[-1], "ip -4 -o addr show dev eth0").split()[3].split("/")[0]
print cmd(n[1], "ping -c 5 " + pingip) print(cmd(n[1], "ping -c 5 " + pingip))
print("elapsed time: %s" % (datetime.datetime.now() - start))
print "elapsed time: %s" % (datetime.datetime.now() - start) print("To stop this session, use the core-cleanup script on the remote daemon server.")
print "To stop this session, use the core-cleanup script on the remote daemon server."
raw_input("press enter to exit") raw_input("press enter to exit")

View file

@ -68,7 +68,7 @@ def main():
port = int(slaveport[1]) port = int(slaveport[1])
else: else:
port = CORE_API_PORT port = CORE_API_PORT
print "connecting to slave at %s:%d" % (slave, port) print("connecting to slave at %s:%d" % (slave, port))
session.broker.addserver(slave, slave, port) session.broker.addserver(slave, slave, port)
session.broker.setupserver(slave) session.broker.setupserver(slave)
session.set_state(EventTypes.CONFIGURATION_STATE) session.set_state(EventTypes.CONFIGURATION_STATE)
@ -79,8 +79,8 @@ def main():
switch.setposition(x=80, y=50) switch.setposition(x=80, y=50)
num_local = options.numnodes / 2 num_local = options.numnodes / 2
num_remote = options.numnodes / 2 + options.numnodes % 2 num_remote = options.numnodes / 2 + options.numnodes % 2
print "creating %d (%d local / %d remote) nodes with addresses from %s" % \ print("creating %d (%d local / %d remote) nodes with addresses from %s" % \
(options.numnodes, num_local, num_remote, prefix) (options.numnodes, num_local, num_remote, prefix))
for i in range(1, num_local + 1): for i in range(1, num_local + 1):
node = session.create_node(cls=core.nodes.base.CoreNode, name="n%d" % i, _id=i) node = session.create_node(cls=core.nodes.base.CoreNode, name="n%d" % i, _id=i)
node.newnetif(switch, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)]) node.newnetif(switch, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
@ -120,9 +120,9 @@ def main():
# start a shell on node 1 # start a shell on node 1
n[1].client.term("bash") n[1].client.term("bash")
print "elapsed time: %s" % (datetime.datetime.now() - start) print("elapsed time: %s" % (datetime.datetime.now() - start))
print "To stop this session, use the 'core-cleanup' script on this server" print("To stop this session, use the 'core-cleanup' script on this server")
print "and on the remote slave server." print("and on the remote slave server.")
if __name__ == "__main__" or __name__ == "__builtin__": if __name__ == "__main__" or __name__ == "__builtin__":

View file

@ -115,16 +115,16 @@ def main():
start = datetime.datetime.now() start = datetime.datetime.now()
prefix = ipaddress.Ipv4Prefix("10.83.0.0/16") prefix = ipaddress.Ipv4Prefix("10.83.0.0/16")
print "Testing how many network namespace nodes this machine can create." print("Testing how many network namespace nodes this machine can create.")
print " - %s" % linuxversion() print(" - %s" % linuxversion())
mem = memfree() mem = memfree()
print " - %.02f GB total memory (%.02f GB swap)" % (mem["total"] / GBD, mem["stotal"] / GBD) print(" - %.02f GB total memory (%.02f GB swap)" % (mem["total"] / GBD, mem["stotal"] / GBD))
print " - using IPv4 network prefix %s" % prefix print(" - using IPv4 network prefix %s" % prefix)
print " - using wait time of %s" % options.waittime print(" - using wait time of %s" % options.waittime)
print " - using %d nodes per bridge" % options.bridges print(" - using %d nodes per bridge" % options.bridges)
print " - will retry %d times on failure" % options.retries print(" - will retry %d times on failure" % options.retries)
print " - adding these services to each node: %s" % options.services print(" - adding these services to each node: %s" % options.services)
print " " print(" ")
lfp = None lfp = None
if options.logfile is not None: if options.logfile is not None:
@ -138,7 +138,7 @@ def main():
session = Session(1) session = Session(1)
switch = session.create_node(cls=core.nodes.network.SwitchNode) switch = session.create_node(cls=core.nodes.network.SwitchNode)
switchlist.append(switch) switchlist.append(switch)
print "Added bridge %s (%d)." % (switch.brname, len(switchlist)) print("Added bridge %s (%d)." % (switch.brname, len(switchlist)))
i = 0 i = 0
retry_count = options.retries retry_count = options.retries
@ -149,9 +149,9 @@ def main():
if 0 < options.bridges <= switch.numnetif(): if 0 < options.bridges <= switch.numnetif():
switch = session.create_node(cls=core.nodes.network.SwitchNode) switch = session.create_node(cls=core.nodes.network.SwitchNode)
switchlist.append(switch) switchlist.append(switch)
print "\nAdded bridge %s (%d) for node %d." % (switch.brname, len(switchlist), i) print("\nAdded bridge %s (%d) for node %d." % (switch.brname, len(switchlist), i))
except Exception, e: except Exception, e:
print "At %d bridges (%d nodes) caught exception:\n%s\n" % (len(switchlist), i - 1, e) print("At %d bridges (%d nodes) caught exception:\n%s\n" % (len(switchlist), i - 1, e))
break break
# create a node # create a node
@ -164,11 +164,11 @@ def main():
session.services.boot_services(n) session.services.boot_services(n)
nodelist.append(n) nodelist.append(n)
if i % 25 == 0: if i % 25 == 0:
print "\n%s nodes created " % i, print("\n%s nodes created " % i,)
mem = memfree() mem = memfree()
free = mem["free"] + mem["buff"] + mem["cached"] free = mem["free"] + mem["buff"] + mem["cached"]
swap = mem["stotal"] - mem["sfree"] swap = mem["stotal"] - mem["sfree"]
print "(%.02f/%.02f GB free/swap)" % (free / GBD, swap / GBD), print("(%.02f/%.02f GB free/swap)" % (free / GBD, swap / GBD),)
if lfp: if lfp:
lfp.write("%d," % i) lfp.write("%d," % i)
lfp.write("%s\n" % ",".join(str(mem[x]) for x in MEMKEYS)) lfp.write("%s\n" % ",".join(str(mem[x]) for x in MEMKEYS))
@ -178,20 +178,20 @@ def main():
sys.stdout.flush() sys.stdout.flush()
time.sleep(options.waittime) time.sleep(options.waittime)
except Exception, e: except Exception, e:
print "At %d nodes caught exception:\n" % i, e print("At %d nodes caught exception:\n" % i, e)
if retry_count > 0: if retry_count > 0:
print "\nWill retry creating node %d." % i print("\nWill retry creating node %d." % i)
shutil.rmtree(n.nodedir, ignore_errors=True) shutil.rmtree(n.nodedir, ignore_errors=True)
retry_count -= 1 retry_count -= 1
i -= 1 i -= 1
time.sleep(options.waittime) time.sleep(options.waittime)
continue continue
else: else:
print "Stopping at %d nodes!" % i print("Stopping at %d nodes!" % i)
break break
if i == options.numnodes: if i == options.numnodes:
print "Stopping at %d nodes due to numnodes option." % i print("Stopping at %d nodes due to numnodes option." % i)
break break
# node creation was successful at this point # node creation was successful at this point
retry_count = options.retries retry_count = options.retries
@ -200,8 +200,8 @@ def main():
lfp.flush() lfp.flush()
lfp.close() lfp.close()
print "elapsed time: %s" % (datetime.datetime.now() - start) print("elapsed time: %s" % (datetime.datetime.now() - start))
print "Use the core-cleanup script to remove nodes and bridges." print("Use the core-cleanup script to remove nodes and bridges.")
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -171,13 +171,13 @@ class ManetExperiment(object):
def info(self, msg): def info(self, msg):
''' Utility method for writing output to stdout. ''' ''' Utility method for writing output to stdout. '''
print msg print(msg)
sys.stdout.flush() sys.stdout.flush()
self.log(msg) self.log(msg)
def warn(self, msg): def warn(self, msg):
''' Utility method for writing output to stderr. ''' ''' Utility method for writing output to stderr. '''
print >> sys.stderr, msg sys.stderr.write(msg)
sys.stderr.flush() sys.stderr.flush()
self.log(msg) self.log(msg)
@ -204,7 +204,7 @@ class ManetExperiment(object):
""" Write to the log file, if any. """ """ Write to the log file, if any. """
if not self.logfp: if not self.logfp:
return return
print >> self.logfp, msg self.logfp.write(msg)
def logdata(self, nbrs, mdrs, lsdbs, krs, zrs): def logdata(self, nbrs, mdrs, lsdbs, krs, zrs):
""" Dump experiment parameters and data to the log file. """ """ Dump experiment parameters and data to the log file. """
@ -368,12 +368,12 @@ class Cmd:
def info(self, msg): def info(self, msg):
''' Utility method for writing output to stdout.''' ''' Utility method for writing output to stdout.'''
print msg print(msg)
sys.stdout.flush() sys.stdout.flush()
def warn(self, msg): def warn(self, msg):
''' Utility method for writing output to stderr. ''' ''' Utility method for writing output to stderr. '''
print >> sys.stderr, "XXX %s:" % self.node.routerid, msg sys.stderr.write("XXX %s:" % self.node.routerid, msg)
sys.stderr.flush() sys.stderr.flush()
def run(self): def run(self):

View file

@ -114,12 +114,12 @@ class Cmd(object):
def info(self, msg): def info(self, msg):
""" Utility method for writing output to stdout.""" """ Utility method for writing output to stdout."""
print msg print(msg)
sys.stdout.flush() sys.stdout.flush()
def warn(self, msg): def warn(self, msg):
""" Utility method for writing output to stderr. """ """ Utility method for writing output to stderr. """
print >> sys.stderr, "XXX %s:" % self.node.name, msg sys.stderr.write("XXX %s:" % self.node.name, msg)
sys.stderr.flush() sys.stderr.flush()
def run(self): def run(self):
@ -358,13 +358,13 @@ class Experiment(object):
def info(self, msg): def info(self, msg):
""" Utility method for writing output to stdout. """ """ Utility method for writing output to stdout. """
print msg print(msg)
sys.stdout.flush() sys.stdout.flush()
self.log(msg) self.log(msg)
def warn(self, msg): def warn(self, msg):
""" Utility method for writing output to stderr. """ """ Utility method for writing output to stderr. """
print >> sys.stderr, msg sys.stderr.write(msg)
sys.stderr.flush() sys.stderr.flush()
self.log(msg) self.log(msg)
@ -394,7 +394,7 @@ class Experiment(object):
""" Write to the log file, if any. """ """ Write to the log file, if any. """
if not self.logfp: if not self.logfp:
return return
print >> self.logfp, msg self.logfp.write(msg)
def reset(self): def reset(self):
""" Prepare for another experiment run. """ Prepare for another experiment run.

View file

@ -40,7 +40,7 @@ def main():
data = sock.recv(msglen) data = sock.recv(msglen)
message = coreapi.CoreMessage(msgflags, hdr, data) message = coreapi.CoreMessage(msgflags, hdr, data)
sessions = message.get_tlv(coreapi.SessionTlvs.NUMBER.value) sessions = message.get_tlv(coreapi.SessionTlvs.NUMBER.value)
print "sessions:", sessions print("sessions: {}".format(sessions))
sock.close() sock.close()

View file

@ -90,7 +90,7 @@ def run_cmd(node, exec_cmd):
message_data = server.sock.recv(message_length) message_data = server.sock.recv(message_length)
# If we get the right response return the results # If we get the right response return the results
print "received response message: %s" % message_type print("received response message: %s" % message_type)
if message_type == MessageTypes.EXECUTE.value: if message_type == MessageTypes.EXECUTE.value:
message = coreapi.CoreExecMessage(message_flags, message_header, message_data) message = coreapi.CoreExecMessage(message_flags, message_header, message_data)
result = message.get_tlv(ExecuteTlvs.RESULT.value) result = message.get_tlv(ExecuteTlvs.RESULT.value)

View file

@ -23,8 +23,8 @@ def readfile(fname):
f = open(fname, "r") f = open(fname, "r")
except IOError: except IOError:
if options.timestamp == True: if options.timestamp == True:
print str(time.time()), print(str(time.time()),)
print "ERROR: failed to open file %s\n" % fname print("ERROR: failed to open file %s\n" % fname)
else: else:
lines = f.readlines() lines = f.readlines()
f.close() f.close()
@ -42,8 +42,7 @@ def numcpus():
def handler(signum, frame): def handler(signum, frame):
print "stop timestamp:", str( print("stop timestamp:", str(time.time()) + ", cyclecount=", cyclecount, ", caught signal", signum)
time.time()) + ", cyclecount=", cyclecount, ", caught signal", signum
sys.exit(0) sys.exit(0)
@ -120,15 +119,15 @@ def checkserverthreshold(metricval):
alarm = ["server", os.uname()[1], str(ind) + key, alarm = ["server", os.uname()[1], str(ind) + key,
"%.2f" % pcpus[ind], ">", serverthresholds.getvalue(key)] "%.2f" % pcpus[ind], ">", serverthresholds.getvalue(key)]
if options.timestamp: if options.timestamp:
print str(time.time()) + ",", print(str(time.time()) + ",",)
print ", ".join(str(x) for x in alarm) print(", ".join(str(x) for x in alarm))
else: else:
if metricval.getvalue(key) > serverthresholds.getvalue(key): if metricval.getvalue(key) > serverthresholds.getvalue(key):
alarm = ["server", os.uname()[1], key, alarm = ["server", os.uname()[1], key,
"%.2f" % metricval.getvalue(key), ">", serverthresholds.getvalue(key)] "%.2f" % metricval.getvalue(key), ">", serverthresholds.getvalue(key)]
if options.timestamp: if options.timestamp:
print str(time.time()) + ",", print(str(time.time()) + ",",)
print ", ".join(str(x) for x in alarm) print(", ".join(str(x) for x in alarm))
def collectservercputimes(): def collectservercputimes():
@ -310,8 +309,8 @@ class LogSession(object):
for nname in self.pids: for nname in self.pids:
if self.pids[nname] == "": if self.pids[nname] == "":
if options.timestamp == True: if options.timestamp == True:
print str(time.time()), print(str(time.time()),)
print "ERROR: null vnoded pid of node: %s" % nname print("ERROR: null vnoded pid of node: %s" % nname)
else: else:
childprocs = [] childprocs = []
ppid = self.pids[nname] ppid = self.pids[nname]
@ -331,13 +330,13 @@ class LogSession(object):
if self.pids[pp] != []: if self.pids[pp] != []:
for ap in range(len(self.pids[pp]) - 1): for ap in range(len(self.pids[pp]) - 1):
# ap pid # ap pid
print ", " + self.pids[pp][ap][0], print(", " + self.pids[pp][ap][0],)
# ap cmd # ap cmd
print ", " + self.pids[pp][ap][1], print(", " + self.pids[pp][ap][1],)
procmetrics = [str(x) for x in self.pids[pp][ap][-1]] procmetrics = [str(x) for x in self.pids[pp][ap][-1]]
print ", " + ", ".join(procmetrics), print(", " + ", ".join(procmetrics),)
nodemetrics = [str(x) for x in self.pids[pp][-1]] nodemetrics = [str(x) for x in self.pids[pp][-1]]
print ", " + ", ".join(nodemetrics) print(", " + ", ".join(nodemetrics))
def getprocessmetrics(self, pid): def getprocessmetrics(self, pid):
""" """
@ -401,9 +400,9 @@ class LogSession(object):
procm = self.getprocessmetrics(self.pids[nod][ap][0]) procm = self.getprocessmetrics(self.pids[nod][ap][0])
if procm == []: if procm == []:
if options.timestamp == True: if options.timestamp == True:
print str(time.time()), print(str(time.time()),)
print "WARNING: transient process", self.pids[nod][ap][1], \ print("WARNING: transient process", self.pids[nod][ap][1],
"/", self.pids[nod][ap][0], "on node %s" % nod "/", self.pids[nod][ap][0], "on node %s" % nod)
else: else:
nodeapps[ap] = procm nodeapps[ap] = procm
self.pids[nod][ap].append(nodeapps[ap]) self.pids[nod][ap].append(nodeapps[ap])
@ -436,8 +435,8 @@ class LogSession(object):
for k in self.nodemetricsC: for k in self.nodemetricsC:
if options.timestamp: if options.timestamp:
print str(time.time()) + ",", print(str(time.time()) + ",",)
print k, ",", mm[k].tocsv() print(k, ",", mm[k].tocsv())
def readnodethresholds(self, filename): def readnodethresholds(self, filename):
if filename is None: if filename is None:
@ -458,8 +457,8 @@ class LogSession(object):
alarm = ["node", nname + "/" + self.pids[nname][0][0], keyname, alarm = ["node", nname + "/" + self.pids[nname][0][0], keyname,
calcm.getvalue(keyname), ">", self.nodethresholds.getvalue(keyname)] calcm.getvalue(keyname), ">", self.nodethresholds.getvalue(keyname)]
if options.timestamp: if options.timestamp:
print str(time.time()) + ",", print(str(time.time()) + ",",)
print ", ".join(str(x) for x in alarm) print(", ".join(str(x) for x in alarm))
def calcnodemetrics(self, cputimea, cputimeb, mems): def calcnodemetrics(self, cputimea, cputimeb, mems):
""" """
@ -472,10 +471,10 @@ class LogSession(object):
hostusedcpu = p[0] + p[1] hostusedcpu = p[0] + p[1]
hostusedmem = mems[0] - mems[1] hostusedmem = mems[0] - mems[1]
if hostusedcpu == 0: if hostusedcpu == 0:
print "WARNING: host used cpu = 0, ", p[0], p[1] print("WARNING: host used cpu = 0, ", p[0], p[1])
hostusedcpu = 1 hostusedcpu = 1
if hostusedmem == 0: if hostusedmem == 0:
print "WARNING: host used mem = 0, ", mems[0], mems[1] print("WARNING: host used mem = 0, ", mems[0], mems[1])
hostusedmem = 1 hostusedmem = 1
nodesa = self.nodemetricsA nodesa = self.nodemetricsA
@ -490,8 +489,8 @@ class LogSession(object):
(False == isinstance(nodesb[nod], NodeMetrics)) | \ (False == isinstance(nodesb[nod], NodeMetrics)) | \
(False == isinstance(nodesa[nod], NodeMetrics)): (False == isinstance(nodesa[nod], NodeMetrics)):
if options.timestamp == True: if options.timestamp == True:
print str(time.time()), print(str(time.time()),)
print "Warning: nodes %s is not fully instanciated" % nod print("Warning: nodes %s is not fully instanciated" % nod)
else: else:
# calc throughput kbps # calc throughput kbps
calcm.setvalue("nodethroughput", "%.2f" % (8 * (nodesb[nod].getvalue("nodethroughput") calcm.setvalue("nodethroughput", "%.2f" % (8 * (nodesb[nod].getvalue("nodethroughput")
@ -519,7 +518,7 @@ class LogSession(object):
except IndexError: except IndexError:
pass pass
else: else:
print "Warning: transient node %s " % nod print("Warning: transient node %s " % nod)
return nodesb return nodesb
@ -531,21 +530,18 @@ def main():
configfile="/etc/core/perflogserver.conf", configfile="/etc/core/perflogserver.conf",
alarm=True, session=None) alarm=True, session=None)
parser.add_option("-i", "--interval", dest="interval", type=int, parser.add_option("-i", "--interval", dest="interval", type=int,
help="seconds to wait between samples; default=%s" % help="seconds to wait between samples; default=%s" % parser.defaults["interval"])
parser.defaults["interval"])
parser.add_option("-t", "--timestamp", action="store_true", parser.add_option("-t", "--timestamp", action="store_true",
dest="timestamp", dest="timestamp",
help="include timestamp on each line") help="include timestamp on each line")
parser.add_option("-c", "--configfile", dest="configfile", parser.add_option("-c", "--configfile", dest="configfile",
type="string", type="string",
help="read threshold values from the specified file;\ help="read threshold values from the specified file;default=%s" % parser.defaults["configfile"])
default=%s" % parser.defaults["configfile"])
parser.add_option("-a", "--alarm", action="store_true", parser.add_option("-a", "--alarm", action="store_true",
dest="alarm", dest="alarm",
help="generate alarms based threshold check on each cycle") help="generate alarms based threshold check on each cycle")
parser.add_option("-s", "--session", dest="session", type=int, parser.add_option("-s", "--session", dest="session", type=int,
help="CORE session id; default=%s" % help="CORE session id; default=%s" % parser.defaults["session"])
parser.defaults["session"])
global options global options
global ncpus global ncpus
global serverthresholds global serverthresholds
@ -573,12 +569,12 @@ def main():
logsession = LogSession() logsession = LogSession()
# mark host log baseline # mark host log baseline
print "server: ", ", ".join(str(x) for x in os.uname()), ",", ncpus, "CPU cores" print("server: ", ", ".join(str(x) for x in os.uname()), ",", ncpus, "CPU cores")
print "start timestamp:", time.time(), ", baseline data: " print("start timestamp:", time.time(), ", baseline data: ")
print csvserverbaseline() print(csvserverbaseline())
print "server metrics: ", ", ".join(str(x) for x in serverthresholds.getkeys()) print("server metrics: ", ", ".join(str(x) for x in serverthresholds.getkeys()))
if options.session is not None: if options.session is not None:
print "node metrics: nodename, ", ", ".join(str(x) for x in logsession.nodethresholds.getkeys()) print("node metrics: nodename, ", ", ".join(str(x) for x in logsession.nodethresholds.getkeys()))
cyclecount = 0 cyclecount = 0
while True: while True:
@ -591,7 +587,7 @@ def main():
calccputime = calcservercputimes(cputimea, cputimeb) calccputime = calcservercputimes(cputimea, cputimeb)
m = csvservermetrics(collectservermetrics( m = csvservermetrics(collectservermetrics(
calccputime, mems, options.alarm)) calccputime, mems, options.alarm))
print m print(m)
if options.session is not None: if options.session is not None:
nodesb = logsession.getnodemetrics('b') nodesb = logsession.getnodemetrics('b')