diff --git a/html/user/server_status.php b/html/user/server_status.php index 01eb6a6915..4dfb4d3f1a 100644 --- a/html/user/server_status.php +++ b/html/user/server_status.php @@ -1,49 +1,39 @@ hostname of web server (default: same as ) +// hostname of scheduling server (default: same as ) +// pid file of scheduling server httpd.conf +// (default: /etc/httpd/run/httpd.pid) +// hostname of upload/download server (default: same as ) +// pid file of upload/download server httpd.conf +// (default: /etc/httpd/run/httpd.pid) +// path to ssh (default: /usr/bin/ssh) +// path to ps (which supports "w" flag) (default: /bin/ps) -# 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"); @@ -52,14 +42,17 @@ $xmlout = ""; if ($argv[1] == "-f") { $xmlout = $argv[2]; } $xmloutfile = fopen($xmlout,"w+"); -# daemon status outputs: 1 (running) 0 (not running) or -1 (disabled) +// daemon status outputs: 1 (running) 0 (not running) or -1 (disabled) function daemon_status($host, $pidname, $progname, $disabled) { + global $ssh_exe, $ps_exe, $project_host; $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"); + $command = "$ps_exe w $pid"; + if ($host != $project_host) { $command = "$ssh_exe $host " . $command; } + $foo = exec($command); if ($foo) { if (strstr($foo, $progname)) { $running = 1; } } @@ -114,6 +107,24 @@ function get_mysql_count ($query) { return $count->count; } +$config_xml = get_config(); +$config_vars = parse_element($config_xml,""); +$project_host = parse_element($config_vars,""); +$www_host = parse_element($config_vars,""); +if ($www_host == "") { $www_host = $project_host; } +$sched_pid = parse_element($config_vars,""); +if ($sched_pid == "") { $sched_pid = "/etc/httpd/run/httpd.pid"; } +$sched_host = parse_element($config_vars,""); +if ($sched_host == "") { $sched_host = $project_host; } +$uldl_pid = parse_element($config_vars,""); +if ($uldl_pid == "") { $uldl_pid = "/etc/httpd/run/httpd.pid"; } +$uldl_host = parse_element($config_vars,""); +if ($uldl_host == "") { $uldl_host = $project_host; } +$ssh_exe = parse_element($config_vars,""); +if ($ssh_exe == "") { $ssh_exe = "/usr/bin/ssh"; } +$ps_exe = parse_element($config_vars,""); +if ($ps_exe == "") { $ps_exe = "/bin/ps"; } + page_head("Server status page"); echo "

"; @@ -134,30 +145,30 @@ if ($xmlout) { 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. +// 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 $www_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); +show_status($www_host, "data-driven web pages", $web_running); -# Check for httpd.pid file of upload/download server. +// 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("../../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(); +// parse through config.xml to get all daemons running $cursor = 0; -# while ($thisxml = trim(parse_next_element($config_xml,"",&$cursor))) { -$thisxml = trim(parse_next_element($config_xml,"",&$cursor)); +while ($thisxml = trim(parse_next_element($config_xml,"",&$cursor))) { + $thisxml = trim(parse_next_element($config_xml,"",&$cursor)); $host = parse_element($thisxml,""); + if ($host == "") { $host = $project_host; } $cmd = parse_element($thisxml,""); list($ncmd) = explode(" ",$cmd); $log = parse_element($thisxml,""); @@ -167,7 +178,7 @@ $thisxml = trim(parse_next_element($config_xml,"",&$cursor)); if (!$pid) { $pid = $ncmd . ".pid"; } $disabled = parse_element($thisxml,""); show_daemon_status($host,$nlog,$ncmd,$disabled); -# } +} if ($xmlout) { fwrite($xmloutfile," \n \n");