blob: b780139f23e6bcf44481db9423e908c125eaa914 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2014-2016 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Denis Roy (Eclipse Foundation) - initial API and implementation
* Christopher Guindon (Eclipse Foundation) - Solstice migration
*******************************************************************************/
$currBandwidthLimit = 350;
$currHTTPLimit = 10000; # www(300x3) + bugs(100x2) + wiki (100x2) + nodes(1000x5) + build(3000) + eclipsecon(100)
$currCPULimit = 2800; # 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
?>
<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 > 850) {
$apachecount_color = "red";
}
}
if( strpos($file, "bugs") !== FALSE) {
$row_bgcolor = "#d3f281";
if($apacheCount > 70) {
$apachecount_color = "red";
}
}
if( strpos($file, "download") !== FALSE) {
if($apacheCount > 11000) {
$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%" cellpadding=3>
<tr>
<td></td>
<td align="right"><b> dbmaster </b></td>
<td align="right"><b> dbslave2 </b></td>
<td align="right"><b> dbapi </b></td>
<td align="right"><b> dbapislave </b></td>
<td align="right"><b> db2master </b></td>
<td align="right"><b> db2slave </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);
$isdbmasterDead = ($currTIME - filemtime($fileName) > 60);
}
$fileName = $aDirectory . "dbslave2";
if($h = @fopen($fileName, "r")) {
$dbslave2line = fread($h, filesize($fileName));
@fclose($h);
$isdbslave2Dead = ($currTIME - filemtime($fileName) > 60);
}
$fileName = $aDirectory . "dbapi";
if($h = @fopen($fileName, "r")) {
$dbapiline = fread($h, filesize($fileName));
@fclose($h);
$isdbapiDead = ($currTIME - filemtime($fileName) > 60);
}
$fileName = $aDirectory . "dbapislave";
if($h = @fopen($fileName, "r")) {
$dbapislaveline = fread($h, filesize($fileName));
@fclose($h);
$isdbapislaveDead = ($currTIME - filemtime($fileName) > 60);
}
$fileName = $aDirectory . "db2master";
if($h = @fopen($fileName, "r")) {
$db2masterline = fread($h, filesize($fileName));
@fclose($h);
$isdb2masterDead = ($currTIME - filemtime($fileName) > 60);
}
$fileName = $aDirectory . "db2slave";
if($h = @fopen($fileName, "r")) {
$db2slaveline = fread($h, filesize($fileName));
@fclose($h);
$isdb2slaveDead = ($currTIME - filemtime($fileName) > 60);
}
$dbmasterparts = explode(" ", $dbmasterline);
$dbslave2parts = explode(" ", $dbslave2line);
$dbapiparts = explode(" ", $dbapiline);
$dbapislaveparts = explode(" ", $dbapislaveline);
$db2masterparts = explode(" ", $db2masterline);
$db2slaveparts = explode(" ", $db2slaveline);
for($i = 0; $i < count($dbmasterparts); $i++) {
$dbmastervariable = $dbmasterparts[$i];
$dbslave2variable = $dbslave2parts[$i];
$dbapivariable = $dbapiparts[$i];
$dbapislavevariable = $dbapislaveparts[$i];
$db2mastervariable = $db2masterparts[$i];
$db2slavevariable = $db2slaveparts[$i];
$dbmastervariableparts = explode(":", $dbmastervariable);
$dbslave2variableparts = explode(":", $dbslave2variable);
$dbapivariableparts = explode(":", $dbapivariable);
$dbapislavevariableparts = explode(":", $dbapislavevariable);
$db2mastervariableparts = explode(":", $db2mastervariable);
$db2slavevariableparts = explode(":", $db2slavevariable);
$label = $dbmastervariableparts[0];
$dbmastervalue = $dbmastervariableparts[1];
$dbslave2value = $dbslave2variableparts[1];
$dbapivalue = $dbapivariableparts[1];
$dbapislavevalue = $dbapislavevariableparts[1];
$db2mastervalue = $db2mastervariableparts[1];
$db2slavevalue = $db2slavevariableparts[1];
if($dbmastervalue == "") {
$dbmastervalue = "&#160;";
}
if($dbapivalue == "") {
$dbapivalue = "&#160;";
}
if($db2mastervalue == "") {
$db2mastervalue = "&#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"><?= $isdbmasterDead ? "<font color=red>NR</font>" : $dbmastervalue ?></td>
<td align="right"><?= $isdbslave2Dead ? "<font color=red>NR</font>" : $dbslave2value ?></td>
<td align="right"><?= $isdbapiDead ? "<font color=red>NR</font>" : $dbapivalue ?></td>
<td align="right"><?= $isdbapislaveDead ? "<font color=red>NR</font>" : $dbapislavevalue ?></td>
<td align="right"><?= $isdb2masterDead ? "<font color=red>NR</font>" : $db2mastervalue ?></td>
<td align="right"><?= $isdb2slaveDead ? "<font color=red>NR</font>" : $db2slavevalue ?></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>
</tr>
</table>
<br />
Currently running on <?= $_SERVER['SERVER_NAME'] ?> at <?= $_SERVER['SERVER_ADDR'] ?> on <?= date("Y-m-d H:i") ?><br />
</td>
<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>