Script execution
This commit is contained in:
@@ -57,14 +57,32 @@ def get_count(command= "%%", start = None, end = None, result= "%%"):
|
||||
sql = _add_sql_time(sql, start, end)
|
||||
return _get_count(sql)
|
||||
|
||||
def get_return_count(command= "%%", start = None, end = None, ret= "%%"):
|
||||
sql = "Command LIKE '"+ command +"' AND Return = '"+ ret +"'"
|
||||
sql = _add_sql_time(sql, start, end)
|
||||
return _get_count(sql)
|
||||
|
||||
def get_cmd_stats(command = "%", start = None, end = None):
|
||||
s = get_count(command, start, end, "success")
|
||||
a = get_count(command, start, end, "abort")
|
||||
e = get_count(command, start, end, "error")
|
||||
return (s,a,e)
|
||||
|
||||
def get_errors(command = "%", start = None, end = None):
|
||||
sql = "SELECT Return, Count(Return) as count 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 print_cmd_stats(command = "%", start = None, end = None):
|
||||
print "Statistics for: " , command , " from ", start , " to ", end
|
||||
print "-----------------------------------------------------------"
|
||||
print "Statistics from ", start , " to ", end
|
||||
print "Command: " , command
|
||||
(s,a,e) = get_cmd_stats(command, start, end)
|
||||
t=s+a+e #get_count(command, start, end, "%")
|
||||
if t==0:
|
||||
@@ -73,6 +91,14 @@ def print_cmd_stats(command = "%", start = None, end = None):
|
||||
print "Success: ", ("%1.2f%% of %d" % ((float(s)/t) * 100, t))
|
||||
print "Error: ", ("%1.2f%% of %d" % ((float(e)/t) * 100, t))
|
||||
print "Abort: ", ("%1.2f%% of %d" % ((float(a)/t) * 100, t))
|
||||
|
||||
print "\nErrors:"
|
||||
print "%5s %s" % ("Count", "Error")
|
||||
errors = get_errors(command, start, end)
|
||||
for error in errors:
|
||||
print "%5d %s" % (error[0], error[1])
|
||||
|
||||
print "-----------------------------------------------------------"
|
||||
|
||||
def get_commands(start = None, end = None):
|
||||
sql = "SELECT * FROM . WHERE Command != ''"
|
||||
@@ -80,19 +106,28 @@ def get_commands(start = None, end = None):
|
||||
sql = sql + " GROUP BY Command"
|
||||
results = stmt.executeQuery(sql)
|
||||
ret = []
|
||||
while results.next():
|
||||
ret.append(results.getString("command"))
|
||||
|
||||
def get_stats(start = None, end = None):
|
||||
cmds = get_commands()
|
||||
while results.next():
|
||||
cmd = results.getString("Command")
|
||||
if cmd and not " " in cmd:
|
||||
ret.append(cmd)
|
||||
return ret
|
||||
|
||||
def print_stats(start = None, end = None):
|
||||
print "-----------------------------------------------------------"
|
||||
print "Statistics from ", start , " to ", end
|
||||
print "%-20s %-5s %8s %8s %8s" % ("Command", "Total", "Success", "Abort", "Error")
|
||||
cmds = get_commands()
|
||||
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)
|
||||
print "-----------------------------------------------------------"
|
||||
|
||||
|
||||
start= "06/02/19" #"06/02/19 13:27:56.124"
|
||||
end= "16/03/19" #"29/04/19 13:27:56.124"
|
||||
|
||||
|
||||
print_cmd_stats ("%test1.py", start, end)
|
||||
print_stats(start, end)
|
||||
|
||||
|
||||
|
||||
print_cmd_stats ("%test1.py", start, end)
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user