Ticket #913: sample_server_status.patch
File sample_server_status.patch, 11.2 KB (added by , 14 years ago) |
---|
-
C:/Coding/Sources/BOINC-help/
old new 63 63 require_once("../inc/util_ops.inc"); 64 64 require_once("../inc/xml.inc"); 65 65 require_once("../inc/cache.inc"); 66 require_once("../inc/translation.inc"); 66 67 67 68 $xml = get_int("xml", true); 68 69 69 $cache_args = "";70 $cache_args = $languages_in_use[0]; 70 71 if ($xml) $cache_args = "xml=1"; 71 72 $cache_period = 600; 72 73 start_cache($cache_period, $cache_args); … … 110 111 $htmlstring = "<tr><td>$function</td><td>$host</td>"; 111 112 if ($running == 1) { 112 113 $xmlstring .= " <status>running</status>\n"; 113 $htmlstring .= "<td class=\"running\"> Running</td>\n";114 $htmlstring .= "<td class=\"running\">".tra("Running")."</td>\n"; 114 115 } elseif ($running == 0) { 115 116 $xmlstring .= " <status>not running</status>\n"; 116 $htmlstring .= "<td class=\"notrunning\"> Not Running</td>\n";117 $htmlstring .= "<td class=\"notrunning\">".tra("Not Running")."</td>\n"; 117 118 } else { 118 119 $xmlstring .= " <status>disabled</status>\n"; 119 $htmlstring .= "<td class=\"disabled\"> Disabled</td>\n";120 $htmlstring .= "<td class=\"disabled\">".tra("Disabled")."</td>\n"; 120 121 } 121 122 $xmlstring .= " </daemon>\n"; 122 123 $htmlstring .= "</tr>\n"; … … 157 158 return $count->count; 158 159 } 159 160 161 function get_mysql_value ($query) { 162 $result = mysql_query($query); 163 $row = mysql_fetch_object($result); 164 mysql_free_result($result); 165 return $row->value; 166 } 167 168 function get_mysql_assoc($query) { 169 $sql = "SELECT * FROM app WHERE deprecated != 1"; 170 $result = mysql_query($sql); 171 while($row = mysql_fetch_assoc($result)) { 172 $assoc[] = $row; 173 } 174 mysql_free_result($result); 175 return $assoc; 176 } 177 178 function get_mysql_user ($clause) { 179 $result = mysql_query("select count(userid) as userid from (SELECT distinct userid FROM result where validate_state=1 and received_time > (unix_timestamp()-(3600*24*1)) " . $clause . ") t"); 180 $count = mysql_fetch_object($result); 181 mysql_free_result($result); 182 return $count->userid; 183 } 184 185 function get_cpu_time ($appid) { 186 $result = mysql_query(" 187 Select ceil(avg(cpu_time)/3600*100)/100 as cpu_time, 188 ceil(min(cpu_time)/3600*100)/100 as min, 189 ceil(max(cpu_time)/3600*100)/100 as max 190 from (SELECT cpu_time FROM `result` WHERE appid = $appid and validate_state =1 and received_time > (unix_timestamp()-(3600*24)) ORDER BY `received_time` DESC limit 100) t"); 191 $count = mysql_fetch_object($result); 192 mysql_free_result($result); 193 return $count; 194 } 195 160 196 $config_xml = get_config(); 161 197 $config_vars = parse_element($config_xml,"<config>"); 162 198 $project_host = parse_element($config_vars,"<host>"); … … 205 241 if ($xmlout) { 206 242 fwrite($xmloutfile,$xmlstring); 207 243 } 208 page_head( "Server status page");244 page_head(tra("Server status page")); 209 245 if ($version) { 210 echo "Server software version: $version<p>\n";246 echo tra("Server software version: %1", $version) . " / "; 211 247 } 212 248 echo time_str(time()), " 213 249 <table width=100%> 214 250 <tr> 215 251 <td width=40% valign=top> 216 <h2> Server status</h2>252 <h2>".tra("Server status")."</h2> 217 253 <table border=0 cellpadding=4> 218 <tr><th> Program</th><th>Host</th><th>Status</th></tr>254 <tr><th>".tra("Program")."</th><th>".tra("Host")."</th><th>".tra("Status")."</th></tr> 219 255 "; 220 256 } 221 257 ; … … 226 262 // 227 263 $web_running = !file_exists("../../stop_web"); 228 264 if ($web_running == 0) $web_running = -1; 229 show_status($www_host, "data-driven web pages", $web_running);265 show_status($www_host, tra("data-driven web pages"), $web_running); 230 266 231 267 // Check for httpd.pid file of upload/download server. 232 268 // 233 269 $uldl_running = file_exists($uldl_pid); 234 270 if ($uldl_running == 0) $uldl_running = -1; 235 show_status($uldl_host, "upload/download server", $uldl_running);271 show_status($uldl_host, tra("upload/download server"), $uldl_running); 236 272 237 273 $sched_running = !file_exists("../../stop_sched"); 238 show_status($sched_host, "scheduler", $sched_running);274 show_status($sched_host, tra("scheduler"), $sched_running); 239 275 240 276 // parse through config.xml to get all daemons running 241 277 // … … 268 304 fwrite($xmloutfile,$xmlstring); 269 305 } 270 306 echo " 271 <tr><td align=right><b> Running:</b></td>272 <td colspan=2> Program is operating normally</td></tr>273 <tr><td align=right><b> Not Running:</b></td>274 <td colspan=2> Program failed or ran out of work<br>275 (or the project is down)</td></tr>276 <tr><td align=right><b> Disabled:</b></td>277 <td colspan=2> Program has been disabled by staff<br>278 (for debugging/maintenance)</td></tr>307 <tr><td align=right><b>".tra("Running:")."</b></td> 308 <td colspan=2>".tra("Program is operating normally")."</td></tr> 309 <tr><td align=right><b>".tra("Not Running:")."</b></td> 310 <td colspan=2>".tra("Program failed or ran out of work<br> 311 (or the project is down)")."</td></tr> 312 <tr><td align=right><b>".tra("Disabled:")."</b></td> 313 <td colspan=2>".tra("Program has been disabled by staff<br> 314 (for debugging/maintenance)")."</td></tr> 279 315 </table> 280 316 </td> 281 <td width=40%valign=top>282 <h2> Database/file status</h2>317 <td valign=top> 318 <h2>".tra("Database/file status")."</h2> 283 319 "; 284 320 } 285 321 286 322 $retval = db_init_aux(); 287 323 if ($retval) { 288 echo "The database server is not accessible";324 echo tra("The database server is not accessible"); 289 325 } else { 290 326 if (!$xml) { 291 echo " 327 echo "<table border=0 cellpadding=0 cellspacing=0><tr><td> 292 328 <table border=0 cellpadding=4> 293 <tr><th> State</th><th>#</th></tr>329 <tr><th>".tra("State")."</th><th>#</th></tr> 294 330 "; 295 331 } 296 332 … … 302 338 // show_counts("Tasks ready to send","results_ready_to_send",$n); 303 339 304 340 show_counts( 305 "Tasks ready to send",341 tra("Tasks ready to send"), 306 342 "results_ready_to_send", 307 343 get_mysql_count("result where server_state = 2") 308 344 ); 309 345 show_counts( 310 "Tasks in progress",346 tra("Tasks in progress"), 311 347 "results_in_progress", 312 348 get_mysql_count("result where server_state = 4") 313 349 ); 314 350 show_counts( 315 "Workunits waiting for validation",351 tra("Workunits waiting for validation"), 316 352 "workunits_waiting_for_validation", 317 353 get_mysql_count("workunit where need_validate=1") 318 354 ); 319 355 show_counts( 320 "Workunits waiting for assimilation",356 tra("Workunits waiting for assimilation"), 321 357 "workunits_waiting_for_assimilation", 322 358 get_mysql_count("workunit where assimilate_state=1") 323 359 ); 324 360 show_counts( 325 "Workunits waiting for file deletion",361 tra("Workunits waiting for file deletion"), 326 362 "workunits_waiting_for_deletion", 327 363 get_mysql_count("workunit where file_delete_state=1") 328 364 ); 329 365 show_counts( 330 "Tasks waiting for file deletion",366 tra("Tasks waiting for file deletion"), 331 367 "results_waiting_for_deletion", 332 368 get_mysql_count("result where file_delete_state=1") 333 369 ); … … 340 376 $gap = 0; 341 377 } 342 378 show_counts( 343 "Transitioner backlog (hours)",379 tra("Transitioner backlog (hours)"), 344 380 "transitioner_backlog_hours", 345 381 $gap 346 382 ); 347 383 if (!$xml) { 348 echo "</table>"; 384 echo "</table></td><td>"; 385 echo "<table>"; 386 echo "<tr><th>".tra("Users")."</th><th>#</th></tr>"; 387 show_counts( 388 tra("in database"), 389 "users_in_database", 390 get_mysql_count("user") 391 ); 392 show_counts( 393 tra("with credit"), 394 "users_with_credit", 395 get_mysql_count("user where total_credit>0") 396 ); 397 show_counts( 398 tra("registered in past 24 hours"), 399 "users_registered_in_past_24_hours", 400 get_mysql_count("user where create_time > (unix_timestamp() - (24*3600))") 401 ); 402 echo "<tr><th>".tra("Computers")."</th><th>#</th></tr>"; 403 show_counts( 404 tra("in database"), 405 "hosts_in_database", 406 get_mysql_count("host") 407 ); 408 show_counts( 409 tra("with credit"), 410 "hosts_with_credit", 411 get_mysql_count("host where total_credit>0") 412 ); 413 show_counts( 414 tra("registered in past 24 hours"), 415 "hosts_registered_in_past_24_hours", 416 get_mysql_count("host where create_time > (unix_timestamp() - (24*3600))") 417 ); 418 show_counts( 419 tra("active in past 7 days"), 420 "hosts_active_in_past_7_days", 421 get_mysql_count("host where rpc_time > (unix_timestamp() - (7*24*3600))") 422 ); 423 show_counts( 424 tra("potential GigaFLOPs")."<sup>1)</sup>", 425 "potential_gflops", 426 get_mysql_value("select sum(p_fpops)/1e9 as value FROM host") 427 ); 428 show_counts( 429 tra("pot. GigaFLOPs in past 7 days")."<sup>2)</sup>", 430 "pot_gflops_in_past_7_days", 431 get_mysql_value("select sum(p_fpops)/1e9 as value FROM host WHERE rpc_time > (unix_timestamp() - (7*86400))") 432 ); 433 // 100,000 cobblestones = 1 TeraFLOPS 434 // divide by 2, because double credits 435 show_counts( 436 tra("current GigaFLOPs")."<sup>3)</sup>", 437 "current_floating_point_speed", 438 get_mysql_value("SELECT sum(expavg_credit)/2/100 as value FROM user") 439 ); 440 441 end_table(); 442 echo "</td></tr></table>"; 443 444 start_table(); 445 echo "<tr><th colspan=5>".tra("Tasks by application")."</th></tr>"; 446 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"))); 447 $apps = get_mysql_assoc("SELECT * FROM app WHERE deprecated != 1"); 448 foreach($apps as $app) { 449 $appid = $row["id"]; 450 $uf_name = $row["user_friendly_name"]; 451 echo "<tr><td>$uf_name</td> 452 <td>" . number_format(get_mysql_count("result where server_state = 2 and appid = $appid")) . "</td> 453 <td>" . number_format(get_mysql_count("result where server_state = 4 and appid = $appid")) . "</td> 454 <td>"; 455 $count = get_cpu_time($appid); 456 echo number_format($count->cpu_time,2) . " (" . number_format($count->min,2) . " - " . number_format($count->max,2) . ")"; 457 echo "</td> 458 <td>" . number_format(get_mysql_user("and appid = $appid")) . "</td> 459 </tr>"; 460 } 461 end_table(); 462 463 // This can be used to show the status of Workunits of the same Batch if they have a common 464 // substring within the Workunits name. Adjust to your own naming convention first. 465 //start_table(); 466 //row1(tra("Workunits to do")); 467 468 //$sql = "SELECT substring(workunit.name, 1, (locate(']', workunit.name))) as b, count(*) as todo FROM workunit where assimilate_state!=2 group by substring(workunit.name, 1, (locate(']', workunit.name)))"; 469 //$result = mysql_query($sql); 470 //while ($row = mysql_fetch_assoc($result)) { 471 // row2($row["b"], $row["todo"]); 472 //} 473 //end_table(); 349 474 } 350 475 } 351 476 … … 358 483 } 359 484 echo " 360 485 </td> 361 <td> </td>362 486 </tr> 363 487 </table> 364 488 "; 489 echo tra("1) the sum of the benchmarked FLOPs of all hosts in the database")."<br/>"; 490 echo tra("2) the sum of the benchmarked FLOPs of all hosts that have contacted the server within the past week")."<br/>"; 491 echo tra("3) from the sum of the Recent Average Credit (RAC) for all users"); 365 492 page_tail(); 366 493 } 367 494