2005-09-20 22:48:35 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2010-11-04 18:20:57 +00:00
|
|
|
// server_status.php
|
2005-09-26 18:11:14 +00:00
|
|
|
// (or server_status.php?xml=1)
|
2005-09-22 22:07:30 +00:00
|
|
|
//
|
|
|
|
// outputs general information about BOINC server status gathered from
|
2005-09-26 18:11:14 +00:00
|
|
|
// config.xml or mysql database queries. If you are running all your
|
|
|
|
// services on one machine, and the database isn't so large, this should
|
|
|
|
// work right out of the box. Otherwise see configureables below.
|
2005-09-22 22:07:30 +00:00
|
|
|
//
|
|
|
|
// 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
|
2005-09-26 18:11:14 +00:00
|
|
|
// logins must be in effect if there are multiple hosts involved.
|
2005-09-22 22:07:30 +00:00
|
|
|
//
|
2005-09-26 18:11:14 +00:00
|
|
|
// The database queries may be very slow. You might consider running these
|
2005-09-22 22:07:30 +00:00
|
|
|
// queries elsewhere via cronjob, outputing numbers into a readable file,
|
2005-09-26 18:11:14 +00:00
|
|
|
// and then getting the latest values with a `/bin/tail -1 data_file`.
|
|
|
|
// See commented example in the code.
|
|
|
|
//
|
|
|
|
// You can get an xml version of the stats via the web when the url has the
|
2010-11-04 18:20:57 +00:00
|
|
|
// optional "?xml=1" tag at the end, i.e
|
2005-09-26 18:11:14 +00:00
|
|
|
// http://yourboincproject.edu/server_status.php?xml=1
|
2005-09-22 22:07:30 +00:00
|
|
|
//
|
|
|
|
// You should edit the following variables in config.xml to suit your needs:
|
|
|
|
//
|
|
|
|
// <www_host> hostname of web server (default: same as <host>)
|
|
|
|
// <sched_host> hostname of scheduling server (default: same as <host>)
|
|
|
|
// <uldl_host> hostname of upload/download server (default: same as <host>)
|
|
|
|
// <uldl_pid> pid file of upload/download server httpd.conf
|
2014-11-02 05:56:47 +00:00
|
|
|
// (default: /var/run/httpd/httpd.pid)
|
2005-09-22 22:07:30 +00:00
|
|
|
// <ssh_exe> path to ssh (default: /usr/bin/ssh)
|
|
|
|
// <ps_exe> path to ps (which supports "w" flag) (default: /bin/ps)
|
|
|
|
|
2005-09-22 23:51:52 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2010-09-17 03:45:39 +00:00
|
|
|
require_once("../inc/util.inc");
|
2005-09-22 23:51:52 +00:00
|
|
|
require_once("../inc/xml.inc");
|
|
|
|
require_once("../inc/cache.inc");
|
2010-09-15 22:06:45 +00:00
|
|
|
require_once("../inc/translation.inc");
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2011-02-09 22:11:34 +00:00
|
|
|
check_get_args(array("xml"));
|
|
|
|
|
2005-09-22 23:51:52 +00:00
|
|
|
$xml = get_int("xml", true);
|
|
|
|
|
2014-08-14 16:23:13 +00:00
|
|
|
if (!defined('STATUS_PAGE_TTL')) {
|
|
|
|
define('STATUS_PAGE_TTL', 3600);
|
|
|
|
}
|
|
|
|
|
2014-11-02 05:56:47 +00:00
|
|
|
function remote_file_exists($host, $path) {
|
|
|
|
global $project_host;
|
|
|
|
if ($host == $project_host) {
|
|
|
|
return file_exists($path);
|
|
|
|
}
|
|
|
|
$cmd = "/usr/bin/ssh $host 'ls $path' 2>&1";
|
|
|
|
//echo $cmd;
|
|
|
|
exec($cmd, $out, $retval);
|
|
|
|
//echo "retval: $retval";
|
|
|
|
return ($retval == 0);
|
|
|
|
}
|
|
|
|
|
2005-09-22 22:07:30 +00:00
|
|
|
// daemon status outputs: 1 (running) 0 (not running) or -1 (disabled)
|
2005-09-22 23:51:52 +00:00
|
|
|
//
|
2005-09-20 22:48:35 +00:00
|
|
|
function daemon_status($host, $pidname, $progname, $disabled) {
|
2012-12-14 09:05:49 +00:00
|
|
|
global $ssh_exe, $ps_exe, $project_host, $project_dir;
|
|
|
|
if ($disabled == 1) return -1;
|
|
|
|
$path = "$project_dir/pid_$host/$pidname";
|
|
|
|
if ($host != $project_host) {
|
|
|
|
$command = "$ssh_exe $host $project_dir/bin/pshelper $path";
|
|
|
|
$foo = exec($command);
|
|
|
|
$running = 1;
|
|
|
|
if ($foo) {
|
|
|
|
if (strstr($foo, "false")) $running = 0;
|
|
|
|
} else $running = 0;
|
|
|
|
return $running;
|
|
|
|
}
|
2005-09-20 22:48:35 +00:00
|
|
|
$running = 0;
|
|
|
|
if (is_file($path)) {
|
|
|
|
$pid = file_get_contents($path);
|
|
|
|
if ($pid) {
|
2007-05-05 03:11:35 +00:00
|
|
|
$pid = trim($pid);
|
2005-10-06 20:22:21 +00:00
|
|
|
$command = "$ps_exe ww $pid";
|
2005-09-22 22:07:30 +00:00
|
|
|
$foo = exec($command);
|
2005-09-20 22:48:35 +00:00
|
|
|
if ($foo) {
|
2007-05-05 03:11:35 +00:00
|
|
|
if (strstr($foo, (string)$pid)) $running = 1;
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $running;
|
|
|
|
}
|
|
|
|
|
2014-11-02 05:56:47 +00:00
|
|
|
// $running: 1 running, 0 not running, -1 disabled
|
|
|
|
//
|
2011-01-06 23:09:13 +00:00
|
|
|
function show_status($host, $progname, $running) {
|
2010-09-15 22:06:45 +00:00
|
|
|
global $xml;
|
2011-01-06 23:09:13 +00:00
|
|
|
$xmlstring = " <daemon>\n <host>$host</host>\n <command>$progname</command>\n";
|
|
|
|
$htmlstring = "<tr><td>$progname</td><td>$host</td>";
|
2014-11-02 05:56:47 +00:00
|
|
|
switch ($running) {
|
|
|
|
case 1:
|
2005-09-26 18:11:14 +00:00
|
|
|
$xmlstring .= " <status>running</status>\n";
|
2010-09-15 22:06:45 +00:00
|
|
|
$htmlstring .= "<td class=\"running\">".tra("Running")."</td>\n";
|
2014-11-02 05:56:47 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
2005-09-26 18:11:14 +00:00
|
|
|
$xmlstring .= " <status>not running</status>\n";
|
2010-09-15 22:06:45 +00:00
|
|
|
$htmlstring .= "<td class=\"notrunning\">".tra("Not Running")."</td>\n";
|
2014-11-02 05:56:47 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-09-26 18:11:14 +00:00
|
|
|
$xmlstring .= " <status>disabled</status>\n";
|
2010-09-15 22:06:45 +00:00
|
|
|
$htmlstring .= "<td class=\"disabled\">".tra("Disabled")."</td>\n";
|
2007-06-13 21:16:27 +00:00
|
|
|
}
|
2005-09-26 18:11:14 +00:00
|
|
|
$xmlstring .= " </daemon>\n";
|
|
|
|
$htmlstring .= "</tr>\n";
|
2007-06-13 21:16:27 +00:00
|
|
|
if ($xml) {
|
2010-09-15 22:06:45 +00:00
|
|
|
echo $xmlstring;
|
|
|
|
} else {
|
|
|
|
echo $htmlstring;
|
2007-06-13 21:16:27 +00:00
|
|
|
}
|
2005-09-26 18:11:14 +00:00
|
|
|
return 0;
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_daemon_status($host, $pidname, $progname, $disabled) {
|
|
|
|
$running = daemon_status($host, $pidname, $progname, $disabled);
|
2011-01-06 23:09:13 +00:00
|
|
|
show_status($host, $progname, $running);
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_counts($key, $xmlkey, $value) {
|
2010-09-15 22:06:45 +00:00
|
|
|
global $xml;
|
2005-09-20 22:48:35 +00:00
|
|
|
$formattedvalue = number_format($value);
|
2005-09-26 18:11:14 +00:00
|
|
|
$xmlstring = " <$xmlkey>$value</$xmlkey>\n";
|
2007-06-13 21:16:27 +00:00
|
|
|
if ($xml) {
|
|
|
|
echo $xmlstring;
|
2010-09-15 22:06:45 +00:00
|
|
|
} else {
|
|
|
|
echo "<tr><td>$key</td><td>$formattedvalue</td></tr>";
|
2007-06-13 21:16:27 +00:00
|
|
|
}
|
2005-09-26 18:11:14 +00:00
|
|
|
return 0;
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
2014-01-07 21:13:44 +00:00
|
|
|
function get_mysql_count($table, $query) {
|
2014-08-14 16:23:13 +00:00
|
|
|
$count = unserialize(get_cached_data(STATUS_PAGE_TTL, "get_mysql_count".$table.$query));
|
2011-03-13 20:05:25 +00:00
|
|
|
if ($count == false) {
|
2014-08-14 16:23:13 +00:00
|
|
|
$count = BoincDB::get()->count($table, $query);
|
|
|
|
set_cached_data(STATUS_PAGE_TTL, serialize($count), "get_mysql_count".$table.$query);
|
2011-03-13 20:05:25 +00:00
|
|
|
}
|
|
|
|
return $count;
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
2014-08-14 16:23:13 +00:00
|
|
|
function get_mysql_sum($table, $field, $clause="") {
|
|
|
|
$value = unserialize(get_cached_data(STATUS_PAGE_TTL, "get_mysql_sum".$table.$field.$clause));
|
2011-03-13 20:05:25 +00:00
|
|
|
if ($value == false) {
|
2014-08-14 16:23:13 +00:00
|
|
|
$value = BoincDB::get()->sum($table, $field, $clause);
|
|
|
|
set_cached_data(STATUS_PAGE_TTL, serialize($value), "get_mysql_sum".$table.$field.$clause);
|
2011-03-13 20:05:25 +00:00
|
|
|
}
|
|
|
|
return $value;
|
2010-09-15 22:06:45 +00:00
|
|
|
}
|
|
|
|
|
2014-01-07 21:13:44 +00:00
|
|
|
function get_cached_apps() {
|
2014-08-14 16:23:13 +00:00
|
|
|
$apps = unserialize(get_cached_data(STATUS_PAGE_TTL, "get_cached_apps"));
|
2014-01-07 21:13:44 +00:00
|
|
|
if ($apps == false) {
|
|
|
|
$apps = BoincApp::enum("deprecated=0");
|
2014-08-14 16:23:13 +00:00
|
|
|
set_cached_data(STATUS_PAGE_TTL, serialize($apps), "get_cached_apps");
|
2010-09-15 22:06:45 +00:00
|
|
|
}
|
2014-01-07 21:13:44 +00:00
|
|
|
return $apps;
|
2010-09-15 22:06:45 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 07:35:54 +00:00
|
|
|
function get_runtime_info($appid) {
|
2014-08-14 16:23:13 +00:00
|
|
|
$info = unserialize(get_cached_data(STATUS_PAGE_TTL, "get_runtime_info".$appid));
|
2012-06-22 07:35:54 +00:00
|
|
|
if ($info == false) {
|
2014-01-07 21:13:44 +00:00
|
|
|
$info = BoincDB::get()->lookup_fields("result", "stdClass",
|
2014-01-09 01:17:07 +00:00
|
|
|
"ceil(avg(elapsed_time)/3600*100)/100 as avg,
|
|
|
|
ceil(min(elapsed_time)/3600*100)/100 as min,
|
|
|
|
ceil(max(elapsed_time)/3600*100)/100 as max,
|
|
|
|
count(distinct userid) as users",
|
2014-08-14 16:23:13 +00:00
|
|
|
"appid = $appid
|
|
|
|
AND validate_state=1
|
|
|
|
AND received_time > (unix_timestamp()-(3600*24))
|
2014-01-09 01:17:07 +00:00
|
|
|
"
|
|
|
|
);
|
2014-01-07 21:13:44 +00:00
|
|
|
if (!$info){
|
2014-08-14 16:23:13 +00:00
|
|
|
// No recent jobs found
|
2014-01-07 21:13:44 +00:00
|
|
|
$info = new stdClass;
|
|
|
|
$info->avg = $info->min = $info->max = $info->users = 0;
|
|
|
|
}
|
2014-08-14 16:23:13 +00:00
|
|
|
set_cached_data(STATUS_PAGE_TTL, serialize($info), "get_runtime_info".$appid);
|
2011-03-13 20:05:25 +00:00
|
|
|
}
|
2012-06-22 07:35:54 +00:00
|
|
|
return $info;
|
2010-09-15 22:06:45 +00:00
|
|
|
}
|
|
|
|
|
2005-09-22 22:07:30 +00:00
|
|
|
$config_xml = get_config();
|
|
|
|
$config_vars = parse_element($config_xml,"<config>");
|
|
|
|
$project_host = parse_element($config_vars,"<host>");
|
|
|
|
$www_host = parse_element($config_vars,"<www_host>");
|
2005-12-18 02:00:15 +00:00
|
|
|
if ($www_host == "") {
|
|
|
|
$www_host = $project_host;
|
|
|
|
}
|
2005-09-22 22:07:30 +00:00
|
|
|
$sched_host = parse_element($config_vars,"<sched_host>");
|
2005-12-18 02:00:15 +00:00
|
|
|
if ($sched_host == "") {
|
|
|
|
$sched_host = $project_host;
|
|
|
|
}
|
2005-09-26 19:56:32 +00:00
|
|
|
$uldl_pid = parse_element($config_vars,"<uldl_pid>");
|
2005-12-18 02:00:15 +00:00
|
|
|
if ($uldl_pid == "") {
|
2014-11-02 05:56:47 +00:00
|
|
|
$uldl_pid = "/var/run/httpd/httpd.pid";
|
2005-12-18 02:00:15 +00:00
|
|
|
}
|
2005-09-22 22:07:30 +00:00
|
|
|
$uldl_host = parse_element($config_vars,"<uldl_host>");
|
2005-12-18 02:00:15 +00:00
|
|
|
if ($uldl_host == "") {
|
|
|
|
$uldl_host = $project_host;
|
|
|
|
}
|
2012-12-14 09:05:49 +00:00
|
|
|
$project_dir = parse_element($config_vars,"<project_dir>");
|
|
|
|
if ($project_dir == "") {
|
|
|
|
$project_dir = "../..";
|
|
|
|
}
|
2005-09-22 22:07:30 +00:00
|
|
|
$ssh_exe = parse_element($config_vars,"<ssh_exe>");
|
2005-12-18 02:00:15 +00:00
|
|
|
if ($ssh_exe == "") {
|
|
|
|
$ssh_exe = "/usr/bin/ssh";
|
2010-11-04 18:20:57 +00:00
|
|
|
}
|
2005-09-22 22:07:30 +00:00
|
|
|
$ps_exe = parse_element($config_vars,"<ps_exe>");
|
2005-12-18 02:00:15 +00:00
|
|
|
if ($ps_exe == "") {
|
|
|
|
$ps_exe = "/bin/ps";
|
|
|
|
}
|
2005-09-22 22:07:30 +00:00
|
|
|
|
2007-05-05 03:11:35 +00:00
|
|
|
$version = null;
|
|
|
|
if (file_exists("../../local.revision")) {
|
|
|
|
$version = trim(file_get_contents("../../local.revision"));
|
|
|
|
}
|
2014-08-14 16:23:13 +00:00
|
|
|
|
|
|
|
// we cache the current time to show via XML or on the page itself
|
|
|
|
// assuming that every cached element on this page is generated at the same time!
|
|
|
|
// To reset this, set STATUS_PAGE_TTL to 0 in project/cache_parameters.inc open
|
|
|
|
// this page in a browser and then set it back to 3600
|
|
|
|
//
|
|
|
|
$last_update = unserialize(get_cached_data(STATUS_PAGE_TTL, "server_status_last_update"));
|
|
|
|
if ($last_update == false) {
|
|
|
|
$last_update = time();
|
|
|
|
set_cached_data(STATUS_PAGE_TTL, serialize($last_update), "server_status_last_update");
|
|
|
|
}
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2007-05-05 03:11:35 +00:00
|
|
|
$xmlstring = "<server_status>
|
2014-08-14 16:23:13 +00:00
|
|
|
<update_time>$last_update</update_time>
|
2007-05-05 03:11:35 +00:00
|
|
|
";
|
|
|
|
if ($version) {
|
|
|
|
$xmlstring .= "<software_version>$version</software_version>\n";
|
|
|
|
}
|
|
|
|
$xmlstring .= " <daemon_status>\n";
|
2005-09-22 23:51:52 +00:00
|
|
|
if ($xml) {
|
|
|
|
xml_header();
|
2005-09-26 18:11:14 +00:00
|
|
|
echo $xmlstring;
|
2005-09-22 23:51:52 +00:00
|
|
|
} else {
|
2010-09-15 22:28:33 +00:00
|
|
|
page_head(tra("Project status"));
|
2007-05-05 03:11:35 +00:00
|
|
|
if ($version) {
|
2010-09-15 22:06:45 +00:00
|
|
|
echo tra("Server software version: %1", $version) . " / ";
|
2007-05-05 03:11:35 +00:00
|
|
|
}
|
2014-08-14 16:23:13 +00:00
|
|
|
echo time_str($last_update), "
|
2005-09-22 23:51:52 +00:00
|
|
|
<table width=100%>
|
|
|
|
<tr>
|
|
|
|
<td width=40% valign=top>
|
2010-09-15 22:06:45 +00:00
|
|
|
<h2>".tra("Server status")."</h2>
|
2005-09-22 23:51:52 +00:00
|
|
|
<table border=0 cellpadding=4>
|
2010-09-15 22:06:45 +00:00
|
|
|
<tr><th>".tra("Program")."</th><th>".tra("Host")."</th><th>".tra("Status")."</th></tr>
|
2005-09-22 23:51:52 +00:00
|
|
|
";
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
2007-05-05 03:11:35 +00:00
|
|
|
// 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."
|
2005-09-22 22:07:30 +00:00
|
|
|
// Set $www_host to the name of server hosting WWW site.
|
2005-09-22 23:51:52 +00:00
|
|
|
//
|
2005-09-20 22:48:35 +00:00
|
|
|
$web_running = !file_exists("../../stop_web");
|
2005-09-22 23:51:52 +00:00
|
|
|
if ($web_running == 0) $web_running = -1;
|
2010-09-15 22:06:45 +00:00
|
|
|
show_status($www_host, tra("data-driven web pages"), $web_running);
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2005-09-22 22:07:30 +00:00
|
|
|
// Check for httpd.pid file of upload/download server.
|
2005-09-22 23:51:52 +00:00
|
|
|
//
|
2014-11-02 05:56:47 +00:00
|
|
|
$uldl_running = remote_file_exists($uldl_host, $uldl_pid);
|
|
|
|
show_status($uldl_host, tra("upload/download server"), $uldl_running?1:0);
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2007-06-13 21:16:27 +00:00
|
|
|
$sched_running = !file_exists("../../stop_sched");
|
2010-09-15 22:06:45 +00:00
|
|
|
show_status($sched_host, tra("scheduler"), $sched_running);
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2005-09-22 22:07:30 +00:00
|
|
|
// parse through config.xml to get all daemons running
|
2005-09-22 23:51:52 +00:00
|
|
|
//
|
2005-09-20 22:48:35 +00:00
|
|
|
$cursor = 0;
|
2006-12-17 17:19:29 +00:00
|
|
|
while ($thisxml = trim(parse_next_element($config_xml,"<daemon>",$cursor))) {
|
2005-09-22 23:51:52 +00:00
|
|
|
$host = parse_element($thisxml,"<host>");
|
2007-12-24 21:34:21 +00:00
|
|
|
if ($host == "") {
|
|
|
|
$host = $project_host;
|
|
|
|
}
|
2005-09-22 23:51:52 +00:00
|
|
|
$cmd = parse_element($thisxml,"<cmd>");
|
2011-01-06 23:09:13 +00:00
|
|
|
list($cmd) = explode(" ", $cmd);
|
2005-09-22 23:51:52 +00:00
|
|
|
$log = parse_element($thisxml,"<output>");
|
2007-12-24 21:34:21 +00:00
|
|
|
if (!$log) {
|
2011-01-06 23:09:13 +00:00
|
|
|
$log = $cmd . ".log";
|
2007-12-24 21:34:21 +00:00
|
|
|
}
|
2011-01-06 23:09:13 +00:00
|
|
|
list($log) = explode(".log", $log);
|
2005-09-22 23:51:52 +00:00
|
|
|
$pid = parse_element($thisxml,"<pid_file>");
|
2007-12-24 21:34:21 +00:00
|
|
|
if (!$pid) {
|
2011-01-06 23:09:13 +00:00
|
|
|
$pid = $cmd . ".pid";
|
2007-12-24 21:34:21 +00:00
|
|
|
}
|
2005-09-22 23:51:52 +00:00
|
|
|
$disabled = parse_element($thisxml,"<disabled>");
|
2011-01-06 23:09:13 +00:00
|
|
|
|
|
|
|
// surrogate for command
|
|
|
|
list($c) = explode(".", $log);
|
|
|
|
show_daemon_status($host, $pid, $c, $disabled);
|
2005-09-22 22:07:30 +00:00
|
|
|
}
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2005-09-26 18:11:14 +00:00
|
|
|
$xmlstring = " </daemon_status>\n <database_file_states>\n";
|
2005-12-18 02:00:15 +00:00
|
|
|
if ($xml) {
|
|
|
|
echo $xmlstring;
|
|
|
|
} else {
|
2005-09-22 23:51:52 +00:00
|
|
|
echo "
|
2010-09-15 22:06:45 +00:00
|
|
|
<tr><td align=right><b>".tra("Running:")."</b></td>
|
|
|
|
<td colspan=2>".tra("Program is operating normally")."</td></tr>
|
|
|
|
<tr><td align=right><b>".tra("Not Running:")."</b></td>
|
2010-09-15 22:28:33 +00:00
|
|
|
<td colspan=2>".tra("Program failed or the project is down")."</td></tr>
|
2010-09-15 22:06:45 +00:00
|
|
|
<tr><td align=right><b>".tra("Disabled:")."</b></td>
|
2010-09-15 22:28:33 +00:00
|
|
|
<td colspan=2>".tra("Program is disabled")."</td></tr>
|
2005-09-22 23:51:52 +00:00
|
|
|
</table>
|
|
|
|
</td>
|
2010-09-15 22:06:45 +00:00
|
|
|
<td valign=top>
|
2010-09-15 22:28:33 +00:00
|
|
|
<h2>".tra("Computing status")."</h2>
|
2005-09-22 23:51:52 +00:00
|
|
|
";
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
2014-08-20 16:41:01 +00:00
|
|
|
if (BoincDB::get_aux(true) == null) {
|
2010-09-15 22:06:45 +00:00
|
|
|
echo tra("The database server is not accessible");
|
2005-09-20 22:48:35 +00:00
|
|
|
} else {
|
2005-09-22 23:51:52 +00:00
|
|
|
if (!$xml) {
|
2010-09-15 22:06:45 +00:00
|
|
|
echo "<table border=0 cellpadding=0 cellspacing=0><tr><td>
|
2005-09-22 23:51:52 +00:00
|
|
|
<table border=0 cellpadding=4>
|
2010-09-15 22:28:33 +00:00
|
|
|
<tr><th>".tra("Work")."</th><th>#</th></tr>
|
2005-09-22 23:51:52 +00:00
|
|
|
";
|
|
|
|
}
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2005-09-26 18:11:14 +00:00
|
|
|
// If you are reading these values from a file rather than
|
|
|
|
// making live queries to the database, do something like this:
|
|
|
|
//
|
|
|
|
// $sendfile = "/home/boincadm/server_status_data/count_results_unsent.out";
|
|
|
|
// $n = `/bin/tail -1 $sendfile`;
|
2010-03-05 21:13:53 +00:00
|
|
|
// show_counts("Tasks ready to send","results_ready_to_send",$n);
|
2005-09-26 18:11:14 +00:00
|
|
|
|
2005-12-18 02:00:15 +00:00
|
|
|
show_counts(
|
2010-09-15 22:06:45 +00:00
|
|
|
tra("Tasks ready to send"),
|
2005-12-18 02:00:15 +00:00
|
|
|
"results_ready_to_send",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("result", "server_state = 2")
|
2005-12-18 02:00:15 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
2010-09-15 22:06:45 +00:00
|
|
|
tra("Tasks in progress"),
|
2005-12-18 02:00:15 +00:00
|
|
|
"results_in_progress",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("result", "server_state = 4")
|
2005-12-18 02:00:15 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
2010-09-15 22:06:45 +00:00
|
|
|
tra("Workunits waiting for validation"),
|
2005-12-18 02:00:15 +00:00
|
|
|
"workunits_waiting_for_validation",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("workunit", "need_validate=1")
|
2005-12-18 02:00:15 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
2010-09-15 22:06:45 +00:00
|
|
|
tra("Workunits waiting for assimilation"),
|
2005-12-18 02:00:15 +00:00
|
|
|
"workunits_waiting_for_assimilation",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("workunit", "assimilate_state=1")
|
2005-12-18 02:00:15 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
2010-09-15 22:06:45 +00:00
|
|
|
tra("Workunits waiting for file deletion"),
|
2005-12-18 02:00:15 +00:00
|
|
|
"workunits_waiting_for_deletion",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("workunit", "file_delete_state=1")
|
2005-12-18 02:00:15 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
2010-09-15 22:06:45 +00:00
|
|
|
tra("Tasks waiting for file deletion"),
|
2005-12-18 02:00:15 +00:00
|
|
|
"results_waiting_for_deletion",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("result", "file_delete_state=1")
|
2005-12-18 02:00:15 +00:00
|
|
|
);
|
2005-09-20 22:48:35 +00:00
|
|
|
|
2014-08-14 16:23:13 +00:00
|
|
|
$gap = unserialize(get_cached_data(STATUS_PAGE_TTL, "transitioner_backlog"));
|
2011-03-13 20:05:25 +00:00
|
|
|
if ($gap === false) {
|
2014-01-07 21:13:44 +00:00
|
|
|
$min = BoincDB::get()->lookup_fields("workunit", "stdClass", "MIN(transition_time) as min", "TRUE");
|
2011-03-13 20:05:25 +00:00
|
|
|
$gap = (time() - $min->min)/3600;
|
|
|
|
if (($gap < 0) || ($min->min == 0)) {
|
|
|
|
$gap = 0;
|
|
|
|
}
|
2014-08-14 16:23:13 +00:00
|
|
|
set_cached_data(STATUS_PAGE_TTL, serialize($gap), "transitioner_backlog");
|
2005-12-18 02:00:15 +00:00
|
|
|
}
|
|
|
|
show_counts(
|
2010-09-15 22:06:45 +00:00
|
|
|
tra("Transitioner backlog (hours)"),
|
2005-12-18 02:00:15 +00:00
|
|
|
"transitioner_backlog_hours",
|
|
|
|
$gap
|
|
|
|
);
|
2005-09-22 23:51:52 +00:00
|
|
|
if (!$xml) {
|
2010-09-15 22:06:45 +00:00
|
|
|
echo "</table></td><td>";
|
2013-09-28 15:53:42 +00:00
|
|
|
echo "<table>";
|
|
|
|
echo "<tr><th>".tra("Users")."</th><th>#</th></tr>";
|
|
|
|
}
|
2010-11-04 18:20:57 +00:00
|
|
|
show_counts(
|
|
|
|
tra("with recent credit"),
|
|
|
|
"users_with_recent_credit",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("user", "expavg_credit>1")
|
2010-11-04 18:20:57 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
|
|
|
tra("with credit"),
|
|
|
|
"users_with_credit",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("user", "total_credit>0")
|
2010-11-04 18:20:57 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
|
|
|
tra("registered in past 24 hours"),
|
|
|
|
"users_registered_in_past_24_hours",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("user", "create_time > (unix_timestamp() - (24*3600))")
|
2010-11-04 18:20:57 +00:00
|
|
|
);
|
2013-09-28 15:53:42 +00:00
|
|
|
if (!$xml) {
|
|
|
|
echo "<tr><th>".tra("Computers")."</th><th>#</th></tr>";
|
|
|
|
}
|
2010-11-04 18:20:57 +00:00
|
|
|
show_counts(
|
|
|
|
tra("with recent credit"),
|
|
|
|
"hosts_with_recent_credit",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("host", "expavg_credit>1")
|
2010-11-04 18:20:57 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
|
|
|
tra("with credit"),
|
|
|
|
"hosts_with_credit",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("host", "total_credit>0")
|
2010-11-04 18:20:57 +00:00
|
|
|
);
|
|
|
|
show_counts(
|
|
|
|
tra("registered in past 24 hours"),
|
|
|
|
"hosts_registered_in_past_24_hours",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_count("host", "create_time > (unix_timestamp() - (24*3600))")
|
2010-11-04 18:20:57 +00:00
|
|
|
);
|
2014-11-02 05:56:47 +00:00
|
|
|
// 200 cobblestones = 1 GigaFLOPS-day
|
2010-11-04 18:20:57 +00:00
|
|
|
show_counts(
|
|
|
|
tra("current GigaFLOPs"),
|
|
|
|
"current_floating_point_speed",
|
2014-01-07 21:13:44 +00:00
|
|
|
get_mysql_sum("user", "expavg_credit/200")
|
2010-11-04 18:20:57 +00:00
|
|
|
);
|
2013-09-28 15:53:42 +00:00
|
|
|
if (!$xml) {
|
|
|
|
end_table();
|
|
|
|
echo "</td></tr></table>";
|
2010-11-04 18:20:57 +00:00
|
|
|
|
2013-09-28 15:53:42 +00:00
|
|
|
start_table();
|
|
|
|
echo "<tr><th colspan=5>".tra("Tasks by application")."</th></tr>";
|
|
|
|
row_heading_array(
|
|
|
|
array(
|
|
|
|
tra("application"),
|
|
|
|
tra("unsent"),
|
|
|
|
tra("in progress"),
|
|
|
|
tra("avg runtime of last 100 results in h (min-max)"),
|
|
|
|
tra("users in last 24h")
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2014-01-07 21:13:44 +00:00
|
|
|
$apps = get_cached_apps();
|
2013-09-28 15:53:42 +00:00
|
|
|
if ($xml) {
|
|
|
|
echo " <tasks_by_app>\n";
|
|
|
|
}
|
2010-11-04 18:20:57 +00:00
|
|
|
foreach($apps as $app) {
|
2014-01-07 21:13:44 +00:00
|
|
|
$info = get_runtime_info($app->id);
|
2013-09-28 15:53:42 +00:00
|
|
|
if ($xml) {
|
|
|
|
echo " <app>\n";
|
2014-01-07 21:13:44 +00:00
|
|
|
echo " <id>".$app->id."</id>\n";
|
|
|
|
echo " <name>".$app->name."</name>\n";
|
|
|
|
echo " <unsent>".get_mysql_count("result", "server_state = 2 and appid = ".$app->id)."</unsent>\n";
|
|
|
|
echo " <in_progress>".get_mysql_count("result", "server_state = 4 and appid = ".$app->id)."</in_progress>\n";
|
2013-09-28 15:53:42 +00:00
|
|
|
echo " <avg_runtime>".round($info->avg, 2)."</avg_runtime>\n";
|
|
|
|
echo " <min_runtime>".round($info->min, 2)."</min_runtime>\n";
|
|
|
|
echo " <max_runtime>".round($info->max, 2)."</max_runtime>\n";
|
2014-01-07 21:13:44 +00:00
|
|
|
echo " <users_24h>".$info->users."</users_24h>\n";
|
2013-09-28 15:53:42 +00:00
|
|
|
echo " </app>\n";
|
|
|
|
} else {
|
2014-01-07 21:13:44 +00:00
|
|
|
echo "<tr><td>".$app->user_friendly_name."</td>
|
|
|
|
<td>" . number_format(get_mysql_count("result", "server_state = 2 and appid = ".$app->id)) . "</td>
|
|
|
|
<td>" . number_format(get_mysql_count("result", "server_state = 4 and appid = ".$app->id)) . "</td>
|
2013-09-28 15:53:42 +00:00
|
|
|
<td>"
|
|
|
|
;
|
|
|
|
echo number_format($info->avg,2) . " (" . number_format($info->min,2) . " - " . number_format($info->max,2) . ")";
|
|
|
|
echo "</td>
|
2014-01-07 21:13:44 +00:00
|
|
|
<td>" . number_format($info->users) . "</td>
|
2013-09-28 15:53:42 +00:00
|
|
|
</tr>"
|
|
|
|
;
|
|
|
|
}
|
2010-11-04 18:20:57 +00:00
|
|
|
}
|
2013-09-28 15:53:42 +00:00
|
|
|
if ($xml) {
|
|
|
|
echo " </tasks_by_app>\n";
|
|
|
|
} else {
|
|
|
|
end_table();
|
2005-09-22 23:51:52 +00:00
|
|
|
}
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
2005-12-18 02:00:15 +00:00
|
|
|
if ($xml) {
|
2014-11-02 05:56:47 +00:00
|
|
|
$xmlstring = " </database_file_states>\n</server_status>\n";
|
2005-12-18 02:00:15 +00:00
|
|
|
echo $xmlstring;
|
|
|
|
} else {
|
2005-09-22 23:51:52 +00:00
|
|
|
echo "
|
2007-05-05 03:11:35 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
2005-09-22 23:51:52 +00:00
|
|
|
";
|
|
|
|
page_tail();
|
2005-09-20 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|