<s> import libinit <EOL> import probedb . standalone <EOL> import probedb . cluster . models as Cluster <EOL> import probedb . probedata2 . models as Probe <EOL> import probedb . resultdb2 . models as Results <EOL> import os , time , subprocess , datetime <EOL> from optparse import OptionParser <EOL> from django . db import connection , transaction <EOL> """<STR_LIT>""" <EOL> computername = os . environ . get ( '<STR_LIT>' , "<STR_LIT>" ) . lower ( ) <EOL> if computername == "<STR_LIT>" : <EOL> computername = os . environ . get ( '<STR_LIT>' , "<STR_LIT>" ) . lower ( ) <EOL> if computername == "<STR_LIT>" : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> computername = computername . partition ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] <EOL> options_config = OptionParser ( ) <EOL> options_config . add_option ( "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" ) <EOL> options_config . add_option ( "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" ) <EOL> ( options , args ) = options_config . parse_args ( ) <EOL> start = time . clock ( ) <EOL> while True : <EOL> try : <EOL> @ transaction . commit_on_success <EOL> def check_performance ( ) : <EOL> run = Cluster . ClusterRun . objects . filter ( enabled = True ) . order_by ( "<STR_LIT>" , "<STR_LIT>" ) [ <NUM_LIT:0> ] <EOL> print "<STR_LIT>" , run . perform_run_id <EOL> Q = Cluster . ClusterAction . objects . filter ( cluster_run = run ) <EOL> current_time = datetime . datetime . now ( ) <EOL> for node in Cluster . ClusterNode . objects . filter ( active_node = True ) . iterator ( ) : <EOL> delta = datetime . timedelta ( hours = <NUM_LIT> ) <EOL> Q1 = Q . filter ( completed_time__range = ( current_time - delta , current_time ) ) <EOL> node_count_24hour = Q1 . filter ( cluster_node = node ) . count ( ) <EOL> delta = datetime . timedelta ( hours = <NUM_LIT:1> ) <EOL> Q1 = Q . filter ( completed_time__range = ( current_time - delta , current_time ) ) <EOL> node_count_hour = Q1 . filter ( cluster_node = node ) . count ( ) <EOL> delta = datetime . timedelta ( minutes = <NUM_LIT:10> ) <EOL> Q1 = Q . filter ( completed_time__range = ( current_time - delta , current_time ) ) <EOL> node_count_10min = Q1 . filter ( cluster_node = node ) . count ( ) * <NUM_LIT:6> <EOL> delta = datetime . timedelta ( minutes = <NUM_LIT:1> ) <EOL> Q1 = Q . filter ( completed_time__range = ( current_time - delta , current_time ) ) <EOL> node_count_1min = Q1 . filter ( cluster_node = node ) . count ( ) * <NUM_LIT> <EOL> print "<STR_LIT>" % ( node . hostname , node_count_1min , node_count_10min , node_count_hour , node_count_24hour ) <EOL> delta = datetime . timedelta ( hours = <NUM_LIT> ) <EOL> Q1 = Q . filter ( completed_time__range = ( current_time - delta , current_time ) ) <EOL> all_count_24hour = Q1 . count ( ) <EOL> delta = datetime . timedelta ( hours = <NUM_LIT:1> ) <EOL> Q1 = Q . filter ( completed_time__range = ( current_time - delta , current_time ) ) <EOL> all_count_hour = Q1 . count ( ) <EOL> delta = datetime . timedelta ( minutes = <NUM_LIT:10> ) <EOL> Q1 = Q . filter ( completed_time__range = ( current_time - delta , current_time ) ) <EOL> all_count_10min = Q1 . count ( ) * <NUM_LIT:6> <EOL> delta = datetime . timedelta ( minutes = <NUM_LIT:1> ) <EOL> Q1 = Q . filter ( completed_time__range = ( current_time - delta , current_time ) ) <EOL> all_count_1min = Q1 . count ( ) * <NUM_LIT> <EOL> print "<STR_LIT>" % ( "<STR_LIT:U+0020>" , all_count_1min , all_count_10min , all_count_hour , all_count_24hour ) , "<STR_LIT>" , Probe . ProbeQueue . objects . filter ( part_of_run = run . perform_run_id , state = Probe . ProbeQueue . PROBEQ_IDLE ) . count ( ) , "<STR_LIT>" , Probe . ProbeResult . objects . filter ( part_of_run = run . perform_run_id ) . count ( ) , "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> check_performance ( ) <EOL> except : <EOL> pass <EOL> connection . close ( ) <EOL> time . sleep ( <NUM_LIT:30> ) </s>
