| 10 |  | # | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 11 |  | # END CONFIGURATION | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 12 |  |  | 
 
 
 
 
 
 
 
 | 13 | + | include("iutils.inc.php"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 14 |  |  | 
 
 
 
 
 
 
 
 
 | 14 | – | # return an array of subdirectories from a directory. | 
 
 
 
 
 
 
 
 
 | 15 | – | function getdirArray($dir='./',$sort='asort') { | 
 
 
 
 
 
 
 
 
 | 16 | – | global $dir_file_count; | 
 
 
 
 
 
 
 
 
 | 17 | – | if ( is_dir($dir) ) { | 
 
 
 
 
 
 
 
 
 | 18 | – | $fd = @opendir($dir); | 
 
 
 
 
 
 
 
 
 | 19 | – | while ( ($part = @readdir($fd)) == TRUE ) { | 
 
 
 
 
 
 
 
 
 | 20 | – | clearstatcache(); | 
 
 
 
 
 
 
 
 
 | 21 | – | if ($part != "." && $part != "..") { | 
 
 
 
 
 
 
 
 
 | 22 | – | $dir_array[] = $part; | 
 
 
 
 
 
 
 
 
 | 23 | – | } | 
 
 
 
 
 
 
 
 
 | 24 | – | } | 
 
 
 
 
 
 
 
 
 | 25 | – | if($fd == TRUE) { | 
 
 
 
 
 
 
 
 
 | 26 | – | closedir($fd); | 
 
 
 
 
 
 
 
 
 | 27 | – | } | 
 
 
 
 
 
 
 
 
 | 28 | – | if (is_array($dir_array)) { | 
 
 
 
 
 
 
 
 
 | 29 | – | $sort($dir_array); | 
 
 
 
 
 
 
 
 
 | 30 | – | $dir_file_count = count($dir_array); | 
 
 
 
 
 
 
 
 
 | 31 | – | Return $dir_array; | 
 
 
 
 
 
 
 
 
 | 32 | – | } else { | 
 
 
 
 
 
 
 
 
 | 33 | – | Return FALSE; | 
 
 
 
 
 
 
 
 
 | 34 | – | } | 
 
 
 
 
 
 
 
 
 | 35 | – | } else { | 
 
 
 
 
 
 
 
 
 | 36 | – | Return FALSE; | 
 
 
 
 
 
 
 
 
 | 37 | – | } | 
 
 
 
 
 
 
 
 
 | 38 | – | } | 
 
 
 
 
 
 
 
 
 | 39 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 15 |  | function printLine($title) { | 
 
 
 
 
 
 
 
 
 
 
 | 16 | < | echo "<hr color=\"#9999ff\">"; | 
 
 
 
 
 
 
 
 
 | 16 | > | echo "<hr style=\"color:#9999ff;\">"; | 
 
 
 
 
 
 
 
 
 
 
 | 17 |  | echo "<b>$title</b>"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 18 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 19 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 20 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 |  | function showStat($title, $value, $input) { | 
 
 
 
 
 
 
 
 | 22 | + |  | 
 
 
 
 
 
 
 
 | 23 | + | $report = $value; | 
 
 
 
 
 
 
 
 | 24 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 25 |  | preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 26 |  | $value = $matches[1]; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 27 |  | if (empty($value)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 30 |  | ?> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 |  | <table border="0" width="100%"> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 |  | <tr> | 
 
 
 
 
 
 
 
 
 
 
 | 33 | < | <td width="50%" align="right" valign="top"><b><font size="2"><?=$title?>:</font></b></td> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 34 | < | <td width="50%" align="left" valign="top"><font size="2"><?=$value?></font></td> | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 33 | > | <td width="50%" align="right" valign="top"> | 
 
 
 
 
 | 34 | > | <b><?=$title?></b> | 
 
 
 
 
 | 35 | > | </td> | 
 
 
 
 
 | 36 | > | <td width="50%" align="left" valign="top"> | 
 
 
 
 
 | 37 | > | <? if (preg_match("/^[0-9]+\.?[0-9]*$/", $value)) { | 
 
 
 
 
 | 38 | > | linkToHistory($report); | 
 
 
 
 
 | 39 | > | } ?> | 
 
 
 
 
 | 40 | > | <?=$value?></td> | 
 
 
 
 
 
 
 
 
 
 
 | 41 |  | </tr> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 |  | </table> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 43 |  | <? | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 44 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 46 |  |  | 
 
 
 
 
 
 
 
 | 47 | + | function linkToHistory($report) { | 
 
 
 
 
 
 
 
 | 48 | + | global $machine; | 
 
 
 
 
 
 
 
 | 49 | + | $yesterday = date("Y-m-d", time() - 86400); | 
 
 
 
 
 
 
 
 | 50 | + | echo <<<EOT | 
 
 
 
 
 
 
 
 | 51 | + | <a href="browser.php?machine_name=$machine&report=$report&day=$yesterday&submit=Show"><img src="minichart.gif" alt="View yesterday's 24-hour chart" width="20" height="20" border="0"></a> | 
 
 
 
 
 
 
 
 | 52 | + | EOT; | 
 
 
 
 
 
 
 
 | 53 | + | } | 
 
 
 
 
 
 
 
 | 54 | + |  | 
 
 
 
 
 
 
 
 | 55 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 56 |  | # show a bar-represented value. | 
 
 
 
 
 
 
 
 
 
 
 | 57 | < | function showBar($title, $value, $max, $input) { | 
 
 
 
 
 
 
 
 
 | 57 | > | function showBar($title, $value, $max, $units, $input) { | 
 
 
 
 
 
 
 
 
 
 
 | 58 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 59 |  | include("latest_config.inc.php"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 60 |  |  | 
 
 
 
 
 
 
 
 | 61 | + | $report = $value; | 
 
 
 
 
 
 
 
 | 62 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 63 |  | preg_match("/$value=([^\,]*)\,/", $input, $matches); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 64 |  | $value = $matches[1]; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 65 |  | if (!is_int($max)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 75 |  | ?> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 76 |  | <table border="0" cellpadding="0" cellspacing="0" align="center"> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 77 |  | <tr> | 
 
 
 
 
 
 
 
 
 
 
 | 78 | < | <td colspan="2"><b><?=$title?></b></td> | 
 
 
 
 
 
 
 
 
 | 78 | > | <td colspan="2"><? linkToHistory($report); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td> | 
 
 
 
 
 
 
 
 
 
 
 | 79 |  | </tr> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 |  | <tr> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 |  | <td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td> | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 84 |  | <td colspan="2"><img src="<?=$scaleImage?>" border="0" height="11" width="<?=$max_width?>"></td> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 85 |  | </tr> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 86 |  | <tr> | 
 
 
 
 
 
 
 
 
 
 
 | 87 | < | <td align="left">0</td> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 88 | < | <td align="right"><?=$max?></td> | 
 
 
 
 
 
 
 
 
 | 87 | > | <td align="left">0<?=$units?></td> | 
 
 
 
 
 | 88 | > | <td align="right"><?=$max?><?=$units?></td> | 
 
 
 
 
 
 
 
 
 
 
 | 89 |  | </tr> | 
 
 
 
 
 
 
 
 | 90 | + | <tr> | 
 
 
 
 
 
 
 
 | 91 | + | <td colspan="2"> </td> | 
 
 
 
 
 
 
 
 | 92 | + | </tr> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 |  | </table> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 94 |  | <? | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 95 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 100 |  | <? include($titleHTML); ?> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 101 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 102 | < | <? printLine("Display the latest information received from a host."); ?> | 
 
 
 
 
 
 
 
 
 | 102 | > | <? printLine("Display the latest information received from a host"); ?> | 
 
 
 
 
 
 
 
 
 
 
 | 103 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 104 |  | <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 105 |  | <? | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 123 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 124 |  | <? if ($machine) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 125 |  |  | 
 
 
 
 
 
 
 
 | 126 | + | $last_modified = filemtime("$latestDirectory/$machine/$latestData"); | 
 
 
 
 
 
 
 
 | 127 | + | clearstatcache(); | 
 
 
 
 
 
 
 
 | 128 | + | $data_age = time() - $last_modified; | 
 
 
 
 
 
 
 
 | 129 | + |  | 
 
 
 
 
 
 
 
 | 130 | + | $last_modified = date("l jS F - g:ia", $last_modified); | 
 
 
 
 
 
 
 
 | 131 | + |  | 
 
 
 
 
 
 
 
 | 132 | + | if ($data_age > $warning_age) { | 
 
 
 
 
 
 
 
 | 133 | + | $warning = <<<EOT | 
 
 
 
 
 
 
 
 | 134 | + | <br> | 
 
 
 
 
 
 
 
 | 135 | + | <font color="red"><b> | 
 
 
 
 
 
 
 
 | 136 | + | Warning: | 
 
 
 
 
 
 
 
 | 137 | + | </b></font> | 
 
 
 
 
 
 
 
 | 138 | + | This realtime report is too old to be considered recent | 
 
 
 
 
 
 
 
 | 139 | + | EOT; | 
 
 
 
 
 
 
 
 | 140 | + | } | 
 
 
 
 
 
 
 
 | 141 | + |  | 
 
 
 
 
 
 
 
 | 142 | + | echo <<<EOT | 
 
 
 
 
 
 
 
 | 143 | + | <table border="0" bgcolor="#000066" cellpadding="3" cellspacing="1"> | 
 
 
 
 
 
 
 
 | 144 | + | <tr> | 
 
 
 
 
 
 
 
 | 145 | + | <td bgcolor="#000066"> | 
 
 
 
 
 
 
 
 | 146 | + |   | 
 
 
 
 
 
 
 
 | 147 | + | </td> | 
 
 
 
 
 
 
 
 | 148 | + | <td bgcolor="#ffffcc"> | 
 
 
 
 
 
 
 
 | 149 | + | <font face="arial,sans-serif" size="2"> | 
 
 
 
 
 
 
 
 | 150 | + | <b>Receipt date:</b> $last_modified | 
 
 
 
 
 
 
 
 | 151 | + | $warning | 
 
 
 
 
 
 
 
 | 152 | + | </font> | 
 
 
 
 
 
 
 
 | 153 | + | </td> | 
 
 
 
 
 
 
 
 | 154 | + | </tr> | 
 
 
 
 
 
 
 
 | 155 | + | </table> | 
 
 
 
 
 
 
 
 | 156 | + | EOT; | 
 
 
 
 
 
 
 
 | 157 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 158 |  | # Read the file. | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 159 |  | #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 160 |  | $input = file("$latestDirectory/$machine/$latestData"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 169 |  | include("latest_display.inc.php"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 170 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 |  | } | 
 
 
 
 
 
 
 
 
 | 142 | – | else { | 
 
 
 
 
 
 
 
 
 | 143 | – | printLine(""); | 
 
 
 
 
 
 
 
 
 | 144 | – | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 172 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 |  | ?> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 174 |  |  | 
 
 
 
 
 
 
 
 | 175 | + | <? printLine(""); ?> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 176 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 177 |  | <? include($bottomHTML); ?> |