*** empty log message ***

svn path=/trunk/boinc/; revision=4198
This commit is contained in:
David Anderson 2004-09-14 20:45:17 +00:00
parent a6b873fa42
commit a80dd102d0
4 changed files with 142 additions and 11 deletions

View File

@ -17409,3 +17409,19 @@ Rom 14 Sept 2004
MainFrame.h
lib/
gui_rpc_client.C, .h
David 14 Sept 2004
- added a "project status" page showing daemon and DB status
The sample has various SETI@home-specific stuff;
projects will need to customize it.
- added db_init_aux(), which doesn't check stop_web,
generate HTML or exit;
moved db_init() to util.inc; it calls db_init_aux(),
and does the check/HTML/exit stuff
html/
inc/
db.inc
util.inc
user/
sample_status.php (new)

View File

@ -5,11 +5,7 @@ require_once('../inc/util.inc');
// database-related functions.
// Presentation code (HTML) shouldn't be here
function db_init() {
if (project_is_stopped()) {
echo "Project is shut down for maintenance - please try again later\n";
exit();
}
function db_init_aux() {
$config = get_config();
$user = parse_config($config, "<db_user>");
$pass = parse_config($config, "<db_passwd>");
@ -19,15 +15,11 @@ function db_init() {
}
$retval = mysql_pconnect($host, $user, $pass);
if (!$retval) {
echo "Unable to connect to database - please try again later\n";
echo "Error: ", mysql_errno(), mysql_error();
exit();
return 1;
}
$db_name = parse_config($config, "<db_name>");
if(!mysql_select_db($db_name)) {
echo "Unable to select database - please try again later";
echo mysql_error();
exit();
return 2;
}
return 0;

View File

@ -2,6 +2,25 @@
require_once("../project/project.inc");
require_once("../inc/countries.inc");
require_once("../inc/db.inc");
function db_init() {
if (project_is_stopped()) {
echo "Project is shut down for maintenance - please try again later\n";
exit();
}
$retval = db_init_aux();
if ($retval == 1) {
echo "Unable to connect to database - please try again later\n";
echo "Error: ", mysql_errno(), mysql_error();
exit();
}
if ($retval == 2) {
echo "Unable to select database - please try again later";
echo mysql_error();
exit();
}
}
// Sends the authenticator to the given email address
//

104
html/user/sample_status.php Normal file
View File

@ -0,0 +1,104 @@
<?php
require_once("../inc/cache.inc");
require_once("../inc/util.inc");
start_cache(600);
require_once("../inc/db.inc");
function count_estimate($query) {
$result = mysql_query("explain $query");
$x = mysql_fetch_object($result);
return $x->rows;
}
function daemon_status($host, $pidname, $progname) {
$path = "../../pid_$host/$pidname.pid";
$running = false;
if (is_file($path)) {
$pid = file_get_contents($path);
if ($pid) {
$foo = exec("/opt/misc/bin/ssh $host ps w $pid");
if ($foo) {
if (strstr($foo, $progname)) {
$running = true;
}
}
}
}
return $running;
if ($running) {
echo "<br>$pidname is running on $host\n";
} else {
echo "<br>$pidname is not running on $host\n";
}
}
function show_status($host, $function, $running) {
echo "<tr><td>$function</td><td>$host</td>";
if ($running) {
echo "<td bgcolor=00ff00>Running</td>\n";
} else {
echo "<td bgcolor=ff0000>Not running</td>\n";
}
}
function show_daemon_status($host, $pidname, $progname) {
$running = daemon_status($host, $pidname, $progname);
show_status($host, $pidname, $running);
}
page_head("SETI@home status page");
echo "
<h2>Server status</h2>
<table border=2 cellpadding=6>
<tr><th>Program</th><th>Host</th><th>Status</th></tr>
";
$web_running = !file_exists("../../stop_web");
show_status("klaatu", "Data-driven web pages", $web_running);
$sched_running = !file_exists("../../stop_sched");
show_status("klaatu", "Scheduler", $sched_running);
show_daemon_status("kryten", "feeder", "feeder");
show_daemon_status("koloth", "file_deleter", "file_deleter");
show_daemon_status("klaatu", "transitioner1", "transitioner");
show_daemon_status("klaatu", "transitioner2", "transitioner");
show_daemon_status("kryten", "transitioner3", "transitioner");
show_daemon_status("kryten", "transitioner4", "transitioner");
show_daemon_status("klaatu", "sah_validate", "sah_validate");
show_daemon_status("galileo", "sah_assimilator", "sah_assimilator");
show_daemon_status("galileo", "sah_splitter", "sah_splitter");
show_daemon_status("milkyway", "sah_splitter2", "sah_splitter");
show_daemon_status("philmor", "sah_splitter3", "sah_splitter");
echo "
</table>
<h2>Database status</h2>
";
$retval = db_init_aux();
if ($retval) {
echo "The database server is not accessable";
} else {
echo "
<table border=2 cellpadding=6>
<tr><th>State</th><th>Approximate #results</th></tr>
";
$n = count_estimate("select count(*) from result where server_state=2");
echo "
<tr><td>Ready to send</td><td>".number_format($n)."</td></tr>
";
$n = count_estimate("select count(*) from result where server_state=4");
echo "
<tr><td>In progress</td><td>".number_format($n)."</td></tr>
</table>
";
}
page_tail();
end_cache(600);
?>