blob: 0199ca3f945c8e343ca97fb8c6b26eb2a975c738 [file] [log] [blame]
<?php
#*****************************************************************************
#
# en_status.inc
#
# Author: Denis Roy
# Date: 2004-09-10
#
# Description: Infrastructure status UI
#
# HISTORY:
#
#****************************************************************************
include("../html/header.php");
$Menu = new Menu("en");
$currBandwidthLimit = 200;
$currHTTPLimit = 10000; # www(300x3) + bugs(100x2) + wiki (100x2) + nodes(1000x5) + build(3000) + eclipsecon(100)
$currCPULimit = 210; # www(12cpu) + bugs(8cpu) + + wiki (8cpu) + nodes(8cpu) + build(4cpu) + eclipsecon+foundation(2cpu) x 5.0 load = 210 (gross approximation)
$currTIME = time();
$deadthreshold = 300; # 5 minutes = dead
include("../modules/menu.php");
ob_start();
?>
<table width="100%">
<tr>
<td width="60%" valign="top">
<b>Server load average</b> <a href="javascript:fnPopup('load');">(What does this mean?)</a><br />
<table class="tbl" width="100%">
<tr>
<td><b>Server</b></td>
<td align="right" nowrap="nowrap"><b>1 min</b></td>
<td align="right" nowrap="nowrap"><b>5 min</b></td>
<td align="right" nowrap="nowrap"><b>15 min</b></td>
<td nowrap="nowrap"><b>Top CPU Hogs</b></td>
</tr>
<?php
$aDirectory = "/home/data/common/monitor/loadavg/";
$dirlist = scandir($aDirectory);
$totCPU = 0;
foreach($dirlist as $file) {
if($file != "." && $file != ".." && $file != "main2") {
$fileName = $aDirectory . $file;
if($h = @fopen($fileName, "r")) {
$line = fread($h, filesize($fileName));
$isDead = ($currTIME - filemtime($fileName) > $deadthreshold);
@fclose($h);
if(!$isDead) {
$parts = explode(" ", $line);
$line = "";
$fileName = "/home/data/common/monitor/topps/" . $file;
if($h = @fopen($fileName, "r")) {
$line = rtrim(fread($h, filesize($fileName)), "\x00..\x1F");
@fclose($h);
}
$totCPU += $parts[0];
}
else {
$parts[0] = "&#160;";
$parts[1] = "&#160;";
$parts[2] = "&#160;";
$line = "DEAD, offline or not reporting";
}
$row_bgcolor = "";
if( strpos($file, "node") !== FALSE) {
$row_bgcolor = "#ffffcc";
}
if( strpos($file, "www") !== FALSE) {
$row_bgcolor = "#dcd5d5";
# Hide process list
if(!$isDead) {
$line = "";
}
}
if( strpos($file, "dev") !== FALSE) {
$row_bgcolor = "#66cc66";
}
if( strpos($file, "bugs") !== FALSE) {
$row_bgcolor = "#d3f281";
# Hide process list
if(!$isDead) {
$line = "";
}
}
if( strpos($file, "php-") !== FALSE) {
$row_bgcolor = "#99aaff";
# Hide process list
if(!$isDead) {
$line = "";
}
}
if( strpos($file, "fred") !== FALSE || strpos($file, "barney") !== FALSE || strpos($file, "db") !== FALSE) {
$row_bgcolor = "#fff0f0";
}
if($line == "") {
$line = "&#160;";
}
else {
$line = "<pre>" . $line . "</pre>";
}
?>
<tr <?= $row_bgcolor != "" ? "style=\"background-color:" . $row_bgcolor . ";\"" : "" ?>>
<td><a href="/committers/loadstats/showmonthstats.php?server=/home/data/common/monitor/loadstats/<?= $file ?>"><?= $file ?></a></td>
<?php
$colour = "black";
for($i = 0; $i < 3; $i++) {
if($parts[$i] > 3) {
$colour = "blue";
if(preg_match("/(barney|fred|build|bugs|www|download|dev)/", $file)) {
$colour = "black";
}
}
if($parts[$i] > 5) {
$colour = "orangered";
if(preg_match("/(barney|build|bugs|www|dev)/", $file)) {
$colour = "blue";
}
if(preg_match("/(fred|download)/", $file)) {
$colour = "black";
}
}
if($parts[$i] > 8) {
$colour = "red";
if(preg_match("/(barney|build|bugs|www|dev)/", $file)) {
$colour = "orangered";
}
if(preg_match("/(fred|download)/", $file)) {
$colour = "blue";
}
}
if($parts[$i] > 12) {
$colour = "red";
if(preg_match("/(fred|download)/", $file)) {
$colour = "blue";
}
}
if($parts[$i] > 20) {
$colour = "darkred";
if(preg_match("/(fred)/", $file)) {
$colour = "orangered";
}
if(preg_match("/(download)/", $file)) {
$colour = "blue";
}
}
if($parts[$i] > 25) {
$colour = "darkred";
if(preg_match("/(fred)/", $file)) {
$colour = "red";
}
if(preg_match("/(download)/", $file)) {
$colour = "blue";
}
}
if($parts[$i] > 30) {
$colour = "darkred";
if(preg_match("/(download)/", $file)) {
$colour = "orangered";
}
}
if($parts[$i] > 40) {
if(preg_match("/(download)/", $file)) {
$colour = "red";
}
}
if($parts[$i] > 60) {
if(preg_match("/(download)/", $file)) {
$colour = "darkred";
}
}
?>
<td align="right"><font color='<?= $colour ?>'><?= $parts[$i] ?></font></td>
<?php }
?>
<td><?= $line ?></td>
</tr>
<?php
}
}
}
?>
</table>
</td>
<td width="20"></td>
<td width="400" valign="top">
<b>Bandwidth usage and connection count</b> <a href="javascript:fnPopup('bandwidth');">(What does this mean?)</a>
<table class="tbl" width="100%">
<tr>
<td><b>Server</b></td>
<td align="right"><b>Mbps out</b></td>
<td align="right"><b>Mbps in</b></td>
<td align="right"><b>HTTP Conn</b></td>
<td align="right"><b>RSYNCd Conn</b></td>
<td align="right"><b>git Procs</b></td>
</tr>
<?php
$aDirectory = "/home/data/common/monitor/bandwdthavg/";
$dirlist = scandir($aDirectory);
$totTX = 0;
$totRX = 0;
$totHTTP = 0;
$totRSYNCD = 0;
$totPSERVER = 0;
$pctTX = 0;
$pctHTTP = 0;
$pctCPU = 0;
foreach($dirlist as $file) {
if($file != "." && $file != "..") {
$fileName = $aDirectory . $file;
if($h = @fopen($fileName, "r")) {
$line = fread($h, filesize($fileName));
$isDead = ($currTIME - filemtime($fileName) > $deadthreshold);
@fclose($h);
if(!$isDead) {
$errorFactor = 0.96;
$parts = explode(" ", $line);
$parts[2] = sprintf("%.2f", $parts[2] / 1024 * 8 * $errorFactor);
$parts[3] = sprintf("%.2f", $parts[3] / 1024 * 8 * $errorFactor);
$totTX += $parts[2];
$totRX += $parts[3];
$apacheCount = 0;
$fileName = "/home/data/common/monitor/apache2/" . $file;
if($h = @fopen($fileName, "r")) {
$apacheCount = fread($h, filesize($fileName));
if( strpos($file, "download") !== FALSE) {
# 32 threads per server
$apacheCount = $apacheCount * 32;
}
$totHTTP += $apacheCount;
@fclose($h);
}
else {
$apacheCount = "&#160;";
}
$rsyncdCount = 0;
$fileName = "/home/data/common/monitor/rsyncd/" . $file;
if($h = @fopen($fileName, "r")) {
$rsyncdCount = fread($h, filesize($fileName));
$totRSYNCD += $rsyncdCount;
@fclose($h);
}
else {
$rsyncdCount = "&#160;";
}
$pserverCount = 0;
$fileName = "/home/data/common/monitor/pserver/" . $file;
if($h = @fopen($fileName, "r")) {
$pserverCount = fread($h, filesize($fileName));
$totPSERVER += $pserverCount;
@fclose($h);
}
else {
$pserverCount = "&#160;";
}
}
else {
$pserverCount = 0;
$rsyncdCount = 0;
$apacheCount = 0;
$parts[2] = 0;
$parts[3] = 0;
}
$row_bgcolor = "";
$apachecount_color = "black";
if( strpos($file, "dev") !== FALSE) {
$row_bgcolor = "#66cc66";
if($apacheCount > 3000) {
$apachecount_color = "red";
}
}
if( strpos($file, "www") !== FALSE) {
$row_bgcolor = "#dcd5d5";
if($apacheCount > 600) {
$apachecount_color = "red";
}
}
if( strpos($file, "bugs") !== FALSE) {
$row_bgcolor = "#d3f281";
if($apacheCount > 70) {
$apachecount_color = "red";
}
}
if( strpos($file, "download") !== FALSE) {
if($apacheCount > 7500) {
$apachecount_color = "red";
}
}
if( strpos($file, "php-") !== FALSE) {
$row_bgcolor = "#99aaff";
if($apacheCount > 500) {
$apachecount_color = "red";
}
}
if( strpos($file, "fred") !== FALSE || strpos($file, "barney") || strpos($file, "wilma") !== FALSE) {
$row_bgcolor = "#fff0f0";
}
?>
<tr <?= $row_bgcolor != "" ? "style=\"background-color:" . $row_bgcolor . ";\"" : "" ?>>
<td><?= $file ?></td>
<td align="right"><?= $parts[2] ?></td>
<td align="right"><?= $parts[3] ?></td>
<td align="right"><font color='<?=$apachecount_color ?>'><?= $apacheCount ?></font></td>
<td align="right"><?= $rsyncdCount ?></td>
<td align="right"><?= $pserverCount ?></td>
</tr>
<?php
}
}
$pctTX = number_format($totTX / $currBandwidthLimit * 100, 1);
$pctHTTP = number_format($totHTTP / $currHTTPLimit * 100, 1);
$pctCPU = number_format($totCPU / $currCPULimit * 100, 1);
}
?>
<tr>
<td><b>Total</b></td>
<td align="right"><b><?= $totTX ?></b></td>
<td align="right"><b><?= $totRX ?></b></td>
<td align="right"><b><?= $totHTTP ?></b></td>
<td align="right"><b><?= $totRSYNCD ?></b></td>
<td align="right"><b><?= $totPSERVER ?></b></td>
</tr>
</table>
</td>
</tr>
</table>
<br /><br />
<table width="100%">
<tr>
<td valign="top">
<b>MySQL server metrics</b> <a href="javascript:fnPopup('mysql');">(What does this mean?)</a>
<table class="tbl" width="100%">
<tr>
<td></td>
<td align="right"><b>dbmaster</b></td>
<td align="right"><b>dbslave</b></td>
<td align="right"><b>dbslave2</b></td>
</tr>
<?php
$aDirectory = "/home/data/common/monitor/mysql/";
$dir = opendir($aDirectory);
$fileName = $aDirectory . "dbmaster";
if($h = @fopen($fileName, "r")) {
$dbmasterline = fread($h, filesize($fileName));
@fclose($h);
}
$fileName = $aDirectory . "dbslave";
if($h = @fopen($fileName, "r")) {
$dbslaveline = fread($h, filesize($fileName));
@fclose($h);
}
$fileName = $aDirectory . "dbslave2";
if($h = @fopen($fileName, "r")) {
$dbslave2line = fread($h, filesize($fileName));
@fclose($h);
}
$dbmasterparts = explode(" ", $dbmasterline);
$dbslaveparts = explode(" ", $dbslaveline);
$dbslave2parts = explode(" ", $dbslave2line);
for($i = 0; $i < count($dbmasterparts); $i++) {
$dbmastervariable = $dbmasterparts[$i];
$dbslavevariable = $dbslaveparts[$i];
$dbslave2variable = $dbslave2parts[$i];
$dbmastervariableparts = explode(":", $dbmastervariable);
$dbslavevariableparts = explode(":", $dbslavevariable);
$dbslave2variableparts = explode(":", $dbslave2variable);
$label = $dbmastervariableparts[0];
$dbmastervalue = $dbmastervariableparts[1];
$dbslavevalue = $dbslavevariableparts[1];
$dbslave2value = $dbslave2variableparts[1];
if($dbmastervalue == "") {
$dbmastervalue = "&#160;";
}
if($label == "Uptime") {
$label = "Uptime_Days";
}
$row_bgcolor = "";
if($label == "Queries_Per_Second") {
$row_bgcolor = "#ffffcc";
}
if($label == "Threads" || $label == "Queries_Per_Second" || $label == "Query_Cache_Hit_Rate(%)" || $label == "Slave_running" || $label == "Slave_IO_Running" || $label == "Slave_SQL_Running" || $label == "Seconds_Behind_Master") {
?>
<tr <?= $row_bgcolor != "" ? "style=\"background-color:" . $row_bgcolor . ";\"" : "" ?>>
<td><b><?= $label ?></b></td>
<td align="right"><?= $dbmastervalue ?></td>
<td align="right"><?= $dbslavevalue ?></td>
<td align="right"><?= $dbslave2value ?></td>
</tr>
<?php
}
}
?>
</table>
</td>
<td width="20"></td>
<td valign="top" >
<!-- <b>Job run status</b> <a href="javascript:fnPopup('jobs');">(What does this mean?)</a>
<table class="tbl" width="100%">
<tr>
<td><b>Job Description</b></td>
<td><b>Last Run</b></td>
<td><b>Last Attempt</b></td>
<td><b>Server</b></td>
<td><b>Abort Reason</b></td>
</tr> -->
<?php
/*
$aDirectory = "/home/data/common/monitor/lastrun/";
$dir = opendir($aDirectory);
while (($file = readdir($dir)) !== false) {
if($file != "." && $file != "..") {
$fileName = $aDirectory . $file;
if($h = @fopen($fileName, "r")) {
$line = fread($h, filesize($fileName));
@fclose($h);
$parts = explode("^", $line);
$jobDesc = "";
if($file == "fixperm") {
$jobDesc = "Fix permissions on download.eclipse.org";
}
if(substr($file, 0, 9) == "rsync.nfs") {
$jobDesc = "Cluster replication";
}
if($file == "mail.archive") {
$jobDesc = "Mailing list archive to HTML";
}
if($file == "news.archive") {
$jobDesc = "Newsgroup archive to HTML";
}
if(substr($file, 0, 14) == "rsync.websites") {
$jobDesc = "Backend replication - web";
}
if($parts[0] == $parts[1]) {
$parts[1] = "&#160;";
}
?>
<tr>
<td><?= $jobDesc ?></td>
<td><?= $parts[0] ?></td>
<td><?= $parts[1] ?></td>
<td><?= $parts[2] ?></td>
<td><?= str_replace("\n", "", $parts[3]) ?> </td>
</tr>
<?php
}
}
}
*/
?>
<!-- </table>
<br /> -->
<table><tr><td style="background-color:#ffffcc;">Yellow indicates dev/download general cluster node.</td>
<td style="background-color:#dcd5d5;">Gray indicates www.eclipse.org cluster node.</td></tr>
<tr><td style="background-color:#d3f281;">Greenish indicates Bugzilla cluster node.</td>
<td style="background-color:#fff0f0;">Twinkle pink indicates Storage/database backend node.</td></tr>
<tr style="background-color:#99aaff;"><td>Blue indicates PHP/Wiki cluster node.</td></tr>
</table>
</td>
<td width="20"></td>
<td valign="top">
<b>Storage Area Network</b>
<br /><b>SAN1</b> = downloads/archives storage &#160; <b>SAN2</b> = unused
<table class="tbl" width="100%">
<tr>
<td><b>Server</b></td>
<td align="right"><b>Load</b></td>
<td align="right"><b>SAN1 KB/s out</b></td>
<td align="right"><b>SAN1 KB/s in</b></td>
<td align="right"><b>SAN2 KB/s out</b></td>
<td align="right"><b>SAN2 KB/s in</b></td>
</tr>
<?php
$aDirectory = "/home/data/common/monitor/san/";
$dirlist = scandir($aDirectory);
$totTXSAN1 = 0;
$totRXSAN1 = 0;
$totTXSAN2 = 0;
$totRXSAN2 = 0;
foreach($dirlist as $file) {
if($file != "." && $file != "..") {
$fileName = $aDirectory . $file;
if($h = @fopen($fileName, "r")) {
$line = fread($h, filesize($fileName));
@fclose($h);
/*
* Time 1236185706
Humantime Wed Mar 4 11:55:06 2009
Load 1.44
eth0 0.0 RX 0.0 TX
eth1 222.5 RX 1917.8 TX
*/
$lines = explode("\n", $line);
foreach ($lines as $line) {
if(substr($line,0,4) == "Time") {
$parts = explode(" ", $line);
$Time = $parts[1];
}
if(substr($line,0,4) == "Load") {
$parts = explode(" ", $line);
$Load = $parts[1];
}
if(substr($line,0,4) == "eth0") {
$parts = explode(" ", $line);
$SAN1RX = $parts[1];
$SAN1TX = $parts[3];
}
if(substr($line,0,4) == "eth1") {
$parts = explode(" ", $line);
$SAN2RX = $parts[1];
$SAN2TX = $parts[3];
}
}
$isDead = ($currTIME - $Time > $deadthreshold);
if(!$isDead) {
$totTXSAN1 += $SAN1TX;
$totRXSAN1 += $SAN1RX;
$totTXSAN2 += $SAN2TX;
$totRXSAN2 += $SAN2RX;
}
else {
$SAN1RX = "DEAD";
$SAN1TX = "DEAD";
$SAN2RX = "DEAD";
$SAN2TX = "DEAD";
}
?>
<tr>
<td><?= $file ?></td>
<td align="right"><?= $Load ?></td>
<td align="right"><?= $SAN1TX ?></td>
<td align="right"><?= $SAN1RX ?></td>
<td align="right"><?= $SAN2TX ?></td>
<td align="right"><?= $SAN2RX ?></td>
</tr>
<?php
}
}
}
?>
<tr>
<td><b>Total</b></td>
<td>&#160;</td>
<td align="right"><b><?= $totTXSAN1 ?></b></td>
<td align="right"><b><?= $totRXSAN1 ?></b></td>
<td align="right"><b><?= $totTXSAN2 ?></b></td>
<td align="right"><b><?= $totRXSAN2 ?></b></td>
</tr>
</table>
</td>
</tr>
</table>
<br />
Currently running on <?= $_SERVER['SERVER_NAME'] ?> at <?= $_SERVER['SERVER_ADDR'] ?> on <?= date("Y-m-d H:i") ?><br />
</td>
<?php
$html = ob_get_contents();
ob_end_clean();
?>
<script language="javascript">
function fnPopup(_file){
var filename = 'inc/en_popup_' + _file + '.html';
window.open(filename, 'popup', 'toolbar=no,scrollbar=no,addressbar=no,width=500,height=400');
}
</script>
<style>
.tbl { border: 1px solid; }
.tbl tr { padding: 0px; }
.tbl td {
border:1px solid;
border-color: #bbb;
}
pre { margin: 0px; }
}
</style>
<META HTTP-EQUIV="Refresh" CONTENT="120;" />
<td width="100%" valign="top" class="normal">
<table width="90%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td><b>CPU:</b> <?= $pctCPU ?> %</td>
<td><b>Bandwidth:</b> <?= $pctTX ?> %</td>
<td><b>HTTPConn:</b> <?= $pctHTTP ?> %</td>
</tr>
</table>
<?
echo $html;
include("../html/footer.php");
?>