mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=8121
This commit is contained in:
parent
e39863b8b0
commit
c6bd005ed6
|
@ -11902,6 +11902,22 @@ Charlie 19 Sept 2005
|
|||
lib/
|
||||
mac_backtrace.C, .h
|
||||
|
||||
Matt 20 Sept 2005
|
||||
- added new file server_status.php to html/user which is a generic server
|
||||
status page, which can be run as a regular php page or as a standalone
|
||||
program (which can output static .html as well as .xml). Instructions
|
||||
for use are in the comments at the top.
|
||||
- fixed the function parse_element so that it returns *all* the text
|
||||
between open/close tags, not just the text between the opening tag
|
||||
and the next "<" sign.
|
||||
- made a new function parse_next_element which gives the user a cursor so
|
||||
that they can iterate through multiple similar tags (like <daemon>).
|
||||
|
||||
html/user/
|
||||
server_status.php
|
||||
html/inc/
|
||||
util.inc
|
||||
|
||||
David 20 Sept 2005
|
||||
- code cleanup
|
||||
|
||||
|
|
|
@ -313,11 +313,12 @@ function print_login_form() {
|
|||
//
|
||||
function parse_element($xml, $tag) {
|
||||
$element = null;
|
||||
$closetag = "</" . substr($tag,1);
|
||||
$x = strstr($xml, $tag);
|
||||
if ($x) {
|
||||
if (strstr($tag, "/>")) return $tag;
|
||||
$y = substr($x, strlen($tag));
|
||||
$n = strpos($y, "<");
|
||||
$n = strpos($y, $closetag);
|
||||
if ($n) {
|
||||
$element = substr($y, 0, $n);
|
||||
}
|
||||
|
@ -325,6 +326,23 @@ function parse_element($xml, $tag) {
|
|||
return $element;
|
||||
}
|
||||
|
||||
function parse_next_element($xml, $tag, $cursor) {
|
||||
$element = null;
|
||||
$closetag = "</" . substr($tag,1);
|
||||
$pos = substr($xml,$cursor);
|
||||
$x = strstr($pos, $tag);
|
||||
if ($x) {
|
||||
if (strstr($tag, "/>")) return $tag;
|
||||
$y = substr($x, strlen($tag));
|
||||
$n = strpos($y, $closetag);
|
||||
if ($n) {
|
||||
$element = substr($y, 0, $n);
|
||||
}
|
||||
$cursor = (strlen($xml) - strlen($x)) + strlen($tag) + strlen($closetag) + strlen($element);
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
if (!function_exists("file_get_contents")) {
|
||||
function file_get_contents($path) {
|
||||
$x = "";
|
||||
|
@ -423,10 +441,8 @@ function user_links($user) {
|
|||
if ($user->has_profile) {
|
||||
$x .= " <a href=view_profile.php?userid=$user->id><img border=0 src=head_20.png></a>";
|
||||
}
|
||||
// Does this project accept donations?
|
||||
// If so, do you want to have a link next to user
|
||||
// name as it appears on the web site?
|
||||
//
|
||||
# Does this project accept donations?
|
||||
# If so, do you want to have a link next to user name as it appears on the web site?
|
||||
if ($user->donated == 1) {
|
||||
require_once("../project/donations.inc");
|
||||
$x .= DONATION_LINK;
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
<?php
|
||||
|
||||
# server_status.php [-f xml_output_filename]
|
||||
#
|
||||
# outputs general information about BOINC server status gathered from
|
||||
# config.xml or mysql database queries.
|
||||
#
|
||||
# Daemons in config.xml are checked to see if they are running by ssh'ing
|
||||
# into the respective hosts and searching for active pids. Passwordless
|
||||
# logins must # be in effect.
|
||||
#
|
||||
# The database queries are rather slow. You might consider running these
|
||||
# queries elsewhere via cronjob, outputing numbers into a readable file,
|
||||
# and then getting the # latest values with a `/bin/tail -1 data_file`
|
||||
#
|
||||
# If running as a standalone program there is an optional -f flag where
|
||||
# you can generate xml server status output to the filename you provide.
|
||||
#
|
||||
# It is highly recommended that you run this program every 10 minutes and
|
||||
# send its stdout to an .html file every 10 minutes, rather than having
|
||||
# the values get regenerated every time the page is accessed.
|
||||
#
|
||||
# You should edit the following variables below to suit your needs:
|
||||
|
||||
# What is the server hosting the WWW site?
|
||||
$web_host = "WWW host name";
|
||||
|
||||
# The machine acting as upload/download server?
|
||||
$uldl_host = "UL/DL host name";
|
||||
|
||||
# Where is the ul/dl apache server pid file?
|
||||
$uldl_pid = "/apache/var/log/httpd.pid";
|
||||
|
||||
# The machine acting as scheduling server?
|
||||
$sched_host = "Scheduler host name";
|
||||
|
||||
# Where is the scheduling apache server pid file?
|
||||
$sched_pid = "/apache/var/log/httpd.pid";
|
||||
|
||||
# Where is ssh?
|
||||
$ssh_exe = "/usr/local/bin/ssh";
|
||||
|
||||
# where is ps (a version that supports the "w" flag)
|
||||
$ps_exe = "/usr/ucb/ps";
|
||||
|
||||
###########################################################
|
||||
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/db.inc");
|
||||
|
||||
$xmlout = "";
|
||||
if ($argv[1] == "-f") { $xmlout = $argv[2]; }
|
||||
$xmloutfile = fopen($xmlout,"w+");
|
||||
|
||||
# daemon status outputs: 1 (running) 0 (not running) or -1 (disabled)
|
||||
function daemon_status($host, $pidname, $progname, $disabled) {
|
||||
$path = "../../pid_$host/$pidname.pid";
|
||||
$running = 0;
|
||||
if (is_file($path)) {
|
||||
$pid = file_get_contents($path);
|
||||
if ($pid) {
|
||||
$foo = exec("$ssh_exe $host ps w $pid");
|
||||
if ($foo) {
|
||||
if (strstr($foo, $progname)) { $running = 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($disabled == 1 ) { $running = -1; }
|
||||
return $running;
|
||||
}
|
||||
|
||||
function show_status($host, $function, $running) {
|
||||
global $xmlout, $xmloutfile;
|
||||
if ($xmlout) {
|
||||
fwrite($xmloutfile," <daemon>\n");
|
||||
fwrite($xmloutfile," <host>$host</host>\n");
|
||||
fwrite($xmloutfile," <command>$function</command>\n");
|
||||
}
|
||||
echo "<tr><td>$function</td><td>$host</td>";
|
||||
if ($running == 1) {
|
||||
echo "<td bgcolor=00ff00>Running</td>\n";
|
||||
if ($xmlout) { fwrite($xmloutfile," <status>running</status>\n"); }
|
||||
} elseif ($running == 0) {
|
||||
echo "<td bgcolor=ff0000>Not Running</td>\n";
|
||||
if ($xmlout) { fwrite($xmloutfile," <status>not running</status>\n"); }
|
||||
} else {
|
||||
echo "<td bgcolor=ff8800>Disabled</td>\n";
|
||||
if ($xmlout) { fwrite($xmloutfile," <status>disabled</status>\n"); }
|
||||
}
|
||||
echo "</tr>";
|
||||
if ($xmlout) {
|
||||
fwrite($xmloutfile," </daemon>\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 "<tr><td>$key</td><td>$formattedvalue</td></tr>";
|
||||
if ($xmlout) {
|
||||
fwrite($xmloutfile," <$xmlkey>$value</$xmlkey>\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 "<p>";
|
||||
|
||||
echo "
|
||||
[As of ", time_str(time()), "]
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<td width=40% valign=top>
|
||||
<h2>Server status</h2>
|
||||
<table border=0 cellpadding=4>
|
||||
<tr><th>Program</th><th>Host</th><th>Status</th></tr>
|
||||
";
|
||||
|
||||
if ($xmlout) {
|
||||
fwrite($xmloutfile,"<server_status>\n");
|
||||
fwrite($xmloutfile," <update_time>" . time() . "</update_time>\n");
|
||||
fwrite($xmloutfile," <daemon_status>\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,"<daemon>",&$cursor))) {
|
||||
$thisxml = trim(parse_next_element($config_xml,"<daemon>",&$cursor));
|
||||
$host = parse_element($thisxml,"<host>");
|
||||
$cmd = parse_element($thisxml,"<cmd>");
|
||||
list($ncmd) = explode(" ",$cmd);
|
||||
$log = parse_element($thisxml,"<output>");
|
||||
if (!$log) { $log = $ncmd . ".log"; }
|
||||
list($nlog) = explode(".log",$log);
|
||||
$pid = parse_element($thisxml,"<pid_file>");
|
||||
if (!$pid) { $pid = $ncmd . ".pid"; }
|
||||
$disabled = parse_element($thisxml,"<disabled>");
|
||||
show_daemon_status($host,$nlog,$ncmd,$disabled);
|
||||
# }
|
||||
|
||||
if ($xmlout) {
|
||||
fwrite($xmloutfile," </daemon_status>\n <database_file_states>\n");
|
||||
}
|
||||
|
||||
echo "
|
||||
<tr><td align=right><b>Running:</b></td>
|
||||
<td colspan=2>Program is operating normally</td></tr>
|
||||
<tr><td align=right><b>Not Running:</b></td>
|
||||
<td colspan=2>Program failed or ran out of work<br>
|
||||
(or the project is down)</td></tr>
|
||||
<tr><td align=right><b>Disabled:</b></td>
|
||||
<td colspan=2>Program has been disabled by staff<br>
|
||||
(for debugging/maintenance)</td></tr>
|
||||
</table>
|
||||
</td>
|
||||
<td width=40% valign=top>
|
||||
<h2>Database/file status</h2>
|
||||
";
|
||||
|
||||
$retval = db_init_aux();
|
||||
if ($retval) {
|
||||
echo "The database server is not accessible";
|
||||
} else {
|
||||
echo "
|
||||
<table border=0 cellpadding=4>
|
||||
<tr><th>State</th><th>#</th></tr>
|
||||
";
|
||||
|
||||
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 "</table>";
|
||||
}
|
||||
|
||||
if ($xmlout) {
|
||||
fwrite($xmloutfile," </database_file_states>\n");
|
||||
fwrite($xmloutfile,"</server_status>\n");
|
||||
}
|
||||
|
||||
echo "
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
";
|
||||
|
||||
page_tail();
|
||||
|
||||
?>
|
Loading…
Reference in New Issue