Script execution
This commit is contained in:
@@ -3,6 +3,7 @@ import java.sql.ResultSet as ResultSet
|
||||
import java.util.Properties as Properties
|
||||
|
||||
stmt = None
|
||||
STAT_COLUMNS = ["Command","Args","Source","Start","End","Background","Result","Return"]
|
||||
|
||||
def get_stats_connection():
|
||||
global stmt
|
||||
@@ -70,13 +71,16 @@ def get_errors(command = "%", start = None, end = None):
|
||||
|
||||
|
||||
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 = "SELECT * FROM . WHERE Command LIKE '"+ command +"'"
|
||||
sql = _add_sql_time(sql, start, end)
|
||||
sql = sql + " GROUP BY Return ORDER BY count DESC"
|
||||
print sql
|
||||
results = stmt.executeQuery(sql)
|
||||
ret = []
|
||||
while results.next():
|
||||
ret.append((results.getInt("count"), results.getString("Return")))
|
||||
rec={}
|
||||
for col in STAT_COLUMNS:
|
||||
rec[col]= results.getString(col)
|
||||
ret.append(rec)
|
||||
return ret
|
||||
|
||||
def get_commands(commands =None, start = None, end = None):
|
||||
@@ -122,8 +126,16 @@ def print_cmd_stats(command = "%", start = None, end = None):
|
||||
print "%5d %s" % (error[0], error[1])
|
||||
print "-----------------------------------------------------------"
|
||||
|
||||
#def print_cmd_info(command = "%", start = None, end = None):
|
||||
|
||||
def print_cmd_info(command = "%", start = None, end = None):
|
||||
info = get_cmd_info(command, start, end)
|
||||
for col in STAT_COLUMNS:
|
||||
print col,
|
||||
print
|
||||
for cmd in info:
|
||||
for col in STAT_COLUMNS:
|
||||
print cmd[col],
|
||||
print
|
||||
|
||||
|
||||
def print_stats(commands = None, start = None, end = None):
|
||||
print "-----------------------------------------------------------"
|
||||
@@ -160,12 +172,15 @@ conn = get_stats_connection()
|
||||
|
||||
start= "01/03/19"
|
||||
end= "01/04/19"
|
||||
|
||||
|
||||
|
||||
|
||||
print_stats(cmds, start, end)
|
||||
|
||||
for cmd in cmds:
|
||||
print_cmd_stats (cmd, start, end)
|
||||
|
||||
|
||||
print_cmd_info("recover%", start, end)
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user