Script execution

This commit is contained in:
2019-04-02 15:13:03 +02:00
parent f32731e775
commit 9ffe9fa4bf

View File

@@ -68,6 +68,17 @@ def get_errors(command = "%", start = None, end = None):
ret.append((results.getInt("count"), results.getString("Return")))
return ret
def get_cmd_info(command = "%", start = None, end = None):
sql = "SELECT Command,Args,Source,Start,End,Background,Result,Return FROM . WHERE Command LIKE '"+ command +"' AND Result='error'"
sql = _add_sql_time(sql, start, end)
sql = sql + " GROUP BY Return ORDER BY count DESC"
results = stmt.executeQuery(sql)
ret = []
while results.next():
ret.append((results.getInt("count"), results.getString("Return")))
return ret
def get_commands(commands =None, start = None, end = None):
ret = []
if (commands is None) or (len(commands)==0):
@@ -110,6 +121,9 @@ def print_cmd_stats(command = "%", start = None, end = None):
for error in errors:
print "%5d %s" % (error[0], error[1])
print "-----------------------------------------------------------"
#def print_cmd_info(command = "%", start = None, end = None):
def print_stats(commands = None, start = None, end = None):
print "-----------------------------------------------------------"
@@ -119,7 +133,10 @@ def print_stats(commands = None, start = None, end = None):
for cmd in cmds:
(s,a,e) = get_cmd_stats(cmd, start, end)
t=s+a+e
print "%-20s %-5d %7.2f%% %7.2f%% %7.2f%%" % (cmd, t, (float(s)/t) * 100, (float(a)/t) * 100, (float(e)/t) * 100)
if t>0:
print "%-20s %-5d %7.2f%% %7.2f%% %7.2f%%" % (cmd, t, (float(s)/t) * 100, (float(a)/t) * 100, (float(e)/t) * 100)
else:
print "%-20s %-5d" % (cmd, t)
print "-----------------------------------------------------------"
@@ -139,11 +156,15 @@ if __name__=='__main__':
cmds = ["mount%", "unmount%", "dry%", "recover%", "trash%", "robot_recover%", "scan%", "homing%"]
conn = get_stats_connection()
#print_stats()
#c=get_commands(cmds)
print_stats(cmds)
#c=get_commands(cmds)
start= "01/03/19"
end= "01/04/19"
print_stats(cmds, start, end)
for cmd in cmds:
print_cmd_stats (cmd)
print_cmd_stats (cmd, start, end)
conn.close()