\n"); fwrite($xmloutfile," $host\n"); fwrite($xmloutfile," $function\n"); } echo "$function$host"; if ($running == 1) { echo "Running\n"; if ($xmlout) { fwrite($xmloutfile," running\n"); } } elseif ($running == 0) { echo "Not Running\n"; if ($xmlout) { fwrite($xmloutfile," not running\n"); } } else { echo "Disabled\n"; if ($xmlout) { fwrite($xmloutfile," disabled\n"); } } echo ""; if ($xmlout) { fwrite($xmloutfile," \n"); } } function show_daemon_status($host, $pidname, $progname, $disabled) { $running = daemon_status($host, $pidname, $progname, $disabled); show_status($host, $pidname, $running); } function show_counts($key, $xmlkey, $value) { global $xmlout, $xmloutfile; $formattedvalue = number_format($value); echo "$key$formattedvalue"; if ($xmlout) { fwrite($xmloutfile," <$xmlkey>$value\n"); } } function get_mysql_count ($query) { $result = mysql_query("select count(*) as count from " . $query); $count = mysql_fetch_object($result); mysql_free_result($result); return $count->count; } page_head("Server status page"); echo "

"; echo " [As of ", time_str(time()), "]

Server status

"; if ($xmlout) { fwrite($xmloutfile,"\n"); fwrite($xmloutfile," " . time() . "\n"); fwrite($xmloutfile," \n"); } # Are the data-driven web sites running? Check for existence # of stop_web. If it is there, set $web_running to -1 for # "disabled," otherwise it will be already set to 1 for "enabled." # Set $web_host to the name of server hosting WWW site. $web_running = !file_exists("../../stop_web"); if ($web_running == 0) { $web_running = -1; } show_status($web_host, "data-driven web pages", $web_running); # Check for httpd.pid file of upload/download server. $uldl_running = file_exists($uldl_pid); if ($uldl_running == 0) { $uldl_running = -1; } show_status($uldl_host, "upload/download server", $uldl_running); # $sched_running = !file_exists("../../stop_sched"); $sched_running = file_exists($sched_pid); if ($sched_running == 0) { $sched_running = -1; } show_status($sched_host, "scheduler", $sched_running); # parse through config.xml to get all daemons running $config_xml = get_config(); $cursor = 0; # while ($thisxml = trim(parse_next_element($config_xml,"",&$cursor))) { $thisxml = trim(parse_next_element($config_xml,"",&$cursor)); $host = parse_element($thisxml,""); $cmd = parse_element($thisxml,""); list($ncmd) = explode(" ",$cmd); $log = parse_element($thisxml,""); if (!$log) { $log = $ncmd . ".log"; } list($nlog) = explode(".log",$log); $pid = parse_element($thisxml,""); if (!$pid) { $pid = $ncmd . ".pid"; } $disabled = parse_element($thisxml,""); show_daemon_status($host,$nlog,$ncmd,$disabled); # } if ($xmlout) { fwrite($xmloutfile," \n \n"); } echo "
ProgramHostStatus
Running: Program is operating normally
Not Running: Program failed or ran out of work
(or the project is down)
Disabled: Program has been disabled by staff
(for debugging/maintenance)

Database/file status

"; $retval = db_init_aux(); if ($retval) { echo "The database server is not accessible"; } else { echo " "; show_counts("Results ready to send","results_ready_to_send",get_mysql_count("result where server_state = 2")); show_counts("Results in progress","results_in_progress",get_mysql_count("result where server_state = 4")); show_counts("Workunits waiting for validation","workunits_waiting_for_validation",get_mysql_count("workunit where need_validate=1")); show_counts("Workunits waiting for assimilation","workunits_waiting_for_assimilation",get_mysql_count("workunit where assimilate_state=1")); show_counts("Workunits waiting for deletion","workunits_waiting_for_deletion",get_mysql_count("workunit where file_delete_state=1")); show_counts("Results waiting for deletion","results_waiting_for_deletion",get_mysql_count("result where file_delete_state=1")); $result = mysql_query("select MIN(transition_time) as min from workunit"); $min = mysql_fetch_object($result); mysql_free_result($result); $gap = (time() - $min->min)/3600; if ($gap < 0) { $gap = 0; } show_counts("Transitioner backlog (hours)","transitioner_backlog_hours",$gap); echo "
State#
"; } if ($xmlout) { fwrite($xmloutfile," \n"); fwrite($xmloutfile,"\n"); } echo "
 
"; page_tail(); ?>