\n")
out.write('\n')
- out.write("\n")
# General
+ out.write("\n")
out.write("General | Value | \n")
out.write("Up time | " + str(elapsed) + ' | \n')
out.write("Reachable | " + str(self.reachable) + ' | \n')
out.write(" \n")
out.write('\n')
- out.write("\n")
# Routing
+ out.write("\n")
out.write("Routing Table | Value | \n")
out.write("Number of nodes | " + str(self.nodes) + ' | \n')
out.write("Total number of users | " + str(self.users) + ' | \n')
out.write(" \n")
out.write('\n')
- out.write("\n")
# Database
+ out.write("\n")
out.write("Database | Value | \n")
out.write("Keys | " + str(self.keys) + ' | \n')
out.write("Values | " + str(self.values) + ' | \n')
out.write(" \n")
out.write("\n")
+
+ # Transport
out.write("\n")
- out.write("Transport | Packets | Bytes | Bytes/second | \n")
+ out.write("Transport | Packets | Bytes | Speed | \n")
out.write("Downloaded | ")
out.write('' + str(self.downPackets) + ' | ')
- out.write('' + str(self.downBytes) + ' | ')
- out.write('%0.2f | \n' % (self.downBytes / (elapsed.days*86400.0 + elapsed.seconds), ))
+ out.write('' + byte_format(self.downBytes) + ' | ')
+ out.write('' + byte_format(self.downBytes / (elapsed.days*86400.0 + elapsed.seconds)) + '/sec | \n')
out.write("Uploaded | ")
out.write('' + str(self.upPackets) + ' | ')
- out.write('' + str(self.upBytes) + ' | ')
- out.write('%0.2f | \n' % (self.upBytes / (elapsed.days*86400.0 + elapsed.seconds), ))
+ out.write('' + byte_format(self.upBytes) + ' | ')
+ out.write('' + byte_format(self.upBytes / (elapsed.days*86400.0 + elapsed.seconds)) + '/sec | \n')
out.write(" \n")
out.write(" | \n")
- out.write("\n")
# Actions
- out.write("Actions | Started | Sent | OK | Failed | Received | Error | \n")
+ out.write("\n")
+ out.write("Actions | Started | Sent | ")
+ out.write("Successful | Failed | Completed | Received | Error | ")
+ out.write("Successful Delay | Failed Delay | Total Delay | \n")
actions = self.actions.keys()
actions.sort()
for action in actions:
out.write("" + action + " | ")
- for i in xrange(6):
+ for i in xrange(7):
out.write("" + str(self.actions[action][i]) + " | ")
+ for i in xrange(3):
+ count = self.actions[action][i+2]
+ if count > 0:
+ total_delay = self.actions[action][i+7]
+ avg_delay = total_delay / count
+ avg_delay_sec = avg_delay.days*86400.0 + avg_delay.seconds + avg_delay.microseconds/1000000.0
+ else:
+ avg_delay_sec = 0.0
+ out.write("%0.2f | " % avg_delay_sec)
out.write(' \n')
out.write(" \n")
out.write("\n")
@@ -161,7 +172,7 @@ class StatsLogger:
@param action: the name of the action
"""
- act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0])
+ act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0, 0, timedelta(), timedelta(), timedelta()])
act[0] += 1
#{ Called by the transport
@@ -170,47 +181,61 @@ class StatsLogger:
@param action: the name of the action
"""
- act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0])
+ act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0, 0, timedelta(), timedelta(), timedelta()])
act[1] += 1
- def responseAction(self, response, action):
+ def responseAction(self, response, action, start):
"""Record that a response to an action was received.
@param response: the response
@param action: the name of the action
+ @param start: the time the action was started
@return: the response (for use in deferreds)
"""
- act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0])
+ act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0, 0, timedelta(), timedelta(), timedelta()])
act[2] += 1
+ act[7] += datetime.now() - start
return response
- def failedAction(self, response, action):
+ def failedAction(self, response, action, start):
"""Record that a failed response to an action was received.
@param response: the response
@param action: the name of the action
+ @param start: the time the action was started
@return: the response (for use in deferreds)
"""
- act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0])
+ act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0, 0, timedelta(), timedelta(), timedelta()])
act[3] += 1
+ act[8] += datetime.now() - start
return response
+ def completedAction(self, action, start):
+ """Record that an action was completed.
+
+ @param action: the name of the action
+ @param start: the time the action was started
+ """
+ act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0, 0, timedelta(), timedelta(), timedelta()])
+ act[4] += 1
+ act[9] += datetime.now() - start
+
def receivedAction(self, action):
"""Record that an action was received.
@param action: the name of the action
"""
self.reachable = True
- act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0])
- act[4] += 1
+ act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0, 0, timedelta(), timedelta(), timedelta()])
+ act[5] += 1
def errorAction(self, action):
"""Record that a received action resulted in an error.
@param action: the name of the action
"""
- act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0])
- act[5] += 1
+ act = self.actions.setdefault(action, [0, 0, 0, 0, 0, 0, 0, timedelta(), timedelta(), timedelta()])
+ act[6] += 1
def sentBytes(self, bytes):
"""Record that a single packet of some bytes was sent.
| | | |