| 1 | pjm2 | 1.1 | <?php | 
 
 
 
 
 | 2 |  |  |  | 
 
 
 
 
 | 3 |  |  | # Navigation for the i-scream reports. | 
 
 
 
 
 | 4 |  |  | # pjm2@ukc.ac.uk | 
 
 
 
 
 | 5 |  |  | # | 
 
 
 
 
 | 6 |  |  | # CONFIGURABLE CONSTANTS: - | 
 
 
 
 
 | 7 |  |  |  | 
 
 
 
 
 | 8 |  |  | include("latest_config.inc.php"); | 
 
 
 
 
 | 9 |  |  |  | 
 
 
 
 
 | 10 |  |  | # | 
 
 
 
 
 | 11 |  |  | # END CONFIGURATION | 
 
 
 
 
 | 12 |  |  |  | 
 
 
 
 
 
 
 
 | 13 | pjm2 | 1.18 | include("iutils.inc.php"); | 
 
 
 
 
 
 
 
 | 14 | pjm2 | 1.1 |  | 
 
 
 
 
 
 
 
 | 15 | pjm2 | 1.9 | function printLine($title) { | 
 
 
 
 
 
 
 
 | 16 | pjm2 | 1.19 | echo "<hr style=\"color:#9999ff;\">"; | 
 
 
 
 
 
 
 
 | 17 | pjm2 | 1.9 | echo "<b>$title</b>"; | 
 
 
 
 
 
 
 
 | 18 | pjm2 | 1.6 | } | 
 
 
 
 
 | 19 |  |  |  | 
 
 
 
 
 
 
 
 | 20 | pjm2 | 1.1 |  | 
 
 
 
 
 | 21 |  |  | function showStat($title, $value, $input) { | 
 
 
 
 
 
 
 
 | 22 | pjm2 | 1.7 | preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches); | 
 
 
 
 
 
 
 
 | 23 | pjm2 | 1.1 | $value = $matches[1]; | 
 
 
 
 
 | 24 |  |  | if (empty($value)) { | 
 
 
 
 
 
 
 
 | 25 | pjm2 | 1.8 | $value = "<i><font color=\"#999999\">not sent</font></i>"; | 
 
 
 
 
 
 
 
 | 26 | pjm2 | 1.1 | } | 
 
 
 
 
 | 27 |  |  | ?> | 
 
 
 
 
 | 28 |  |  | <table border="0" width="100%"> | 
 
 
 
 
 | 29 |  |  | <tr> | 
 
 
 
 
 
 
 
 | 30 | pjm2 | 1.12 | <td width="50%" align="right" valign="top"><b><?=$title?></b></td> | 
 
 
 
 
 | 31 |  |  | <td width="50%" align="left" valign="top"><?=$value?></td> | 
 
 
 
 
 
 
 
 | 32 | pjm2 | 1.1 | </tr> | 
 
 
 
 
 | 33 |  |  | </table> | 
 
 
 
 
 | 34 |  |  | <? | 
 
 
 
 
 | 35 |  |  | } | 
 
 
 
 
 | 36 |  |  |  | 
 
 
 
 
 | 37 |  |  |  | 
 
 
 
 
 
 
 
 | 38 | pjm2 | 1.20 | function linkToHistory($report) { | 
 
 
 
 
 | 39 |  |  | global $machine; | 
 
 
 
 
 | 40 |  |  | $yesterday = date("Y-m-d", time() - 86400); | 
 
 
 
 
 | 41 |  |  | echo <<<EOT | 
 
 
 
 
 
 
 
 | 42 | pjm2 | 1.23 | <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> | 
 
 
 
 
 
 
 
 | 43 | pjm2 | 1.20 | EOT; | 
 
 
 
 
 | 44 |  |  | } | 
 
 
 
 
 | 45 |  |  |  | 
 
 
 
 
 | 46 |  |  |  | 
 
 
 
 
 
 
 
 | 47 | pjm2 | 1.1 | # show a bar-represented value. | 
 
 
 
 
 
 
 
 | 48 | pjm2 | 1.13 | function showBar($title, $value, $max, $units, $input) { | 
 
 
 
 
 
 
 
 | 49 | pjm2 | 1.1 |  | 
 
 
 
 
 | 50 |  |  | include("latest_config.inc.php"); | 
 
 
 
 
 | 51 |  |  |  | 
 
 
 
 
 
 
 
 | 52 | pjm2 | 1.22 | $report = $value; | 
 
 
 
 
 | 53 |  |  |  | 
 
 
 
 
 
 
 
 | 54 | pjm2 | 1.1 | preg_match("/$value=([^\,]*)\,/", $input, $matches); | 
 
 
 
 
 | 55 |  |  | $value = $matches[1]; | 
 
 
 
 
 | 56 |  |  | if (!is_int($max)) { | 
 
 
 
 
 | 57 |  |  | preg_match("/$max=([^\,]*)\,/", $input, $matches); | 
 
 
 
 
 | 58 |  |  | $max = $matches[1]; | 
 
 
 
 
 | 59 |  |  | } | 
 
 
 
 
 | 60 |  |  | if (empty($value) || empty($max)) { | 
 
 
 
 
 | 61 |  |  | return; | 
 
 
 
 
 | 62 |  |  | } | 
 
 
 
 
 | 63 |  |  |  | 
 
 
 
 
 | 64 |  |  | $width = intval($max_width * $value / $max); | 
 
 
 
 
 | 65 |  |  |  | 
 
 
 
 
 | 66 |  |  | ?> | 
 
 
 
 
 
 
 
 | 67 | pjm2 | 1.10 | <table border="0" cellpadding="0" cellspacing="0" align="center"> | 
 
 
 
 
 
 
 
 | 68 | pjm2 | 1.1 | <tr> | 
 
 
 
 
 
 
 
 | 69 | pjm2 | 1.23 | <td colspan="2"><? linkToHistory($report); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td> | 
 
 
 
 
 
 
 
 | 70 | pjm2 | 1.1 | </tr> | 
 
 
 
 
 | 71 |  |  | <tr> | 
 
 
 
 
 | 72 |  |  | <td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td> | 
 
 
 
 
 | 73 |  |  | </tr> | 
 
 
 
 
 | 74 |  |  | <tr> | 
 
 
 
 
 | 75 |  |  | <td colspan="2"><img src="<?=$scaleImage?>" border="0" height="11" width="<?=$max_width?>"></td> | 
 
 
 
 
 | 76 |  |  | </tr> | 
 
 
 
 
 | 77 |  |  | <tr> | 
 
 
 
 
 
 
 
 | 78 | pjm2 | 1.13 | <td align="left">0<?=$units?></td> | 
 
 
 
 
 | 79 |  |  | <td align="right"><?=$max?><?=$units?></td> | 
 
 
 
 
 
 
 
 | 80 | pjm2 | 1.1 | </tr> | 
 
 
 
 
 
 
 
 | 81 | pjm2 | 1.15 | <tr> | 
 
 
 
 
 | 82 |  |  | <td colspan="2"> </td> | 
 
 
 
 
 | 83 |  |  | </tr> | 
 
 
 
 
 
 
 
 | 84 | pjm2 | 1.1 | </table> | 
 
 
 
 
 | 85 |  |  | <? | 
 
 
 
 
 | 86 |  |  | } | 
 
 
 
 
 | 87 |  |  |  | 
 
 
 
 
 | 88 |  |  |  | 
 
 
 
 
 | 89 |  |  | ?> | 
 
 
 
 
 | 90 |  |  |  | 
 
 
 
 
 | 91 |  |  | <? include($titleHTML); ?> | 
 
 
 
 
 | 92 |  |  |  | 
 
 
 
 
 
 
 
 | 93 | pjm2 | 1.12 | <? printLine("Display the latest information received from a host"); ?> | 
 
 
 
 
 
 
 
 | 94 | pjm2 | 1.1 |  | 
 
 
 
 
 | 95 |  |  | <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> | 
 
 
 
 
 | 96 |  |  | <? | 
 
 
 
 
 | 97 |  |  |  | 
 
 
 
 
 
 
 
 | 98 | pjm2 | 1.5 | $file_array = getdirArray($latestDirectory,'asort'); | 
 
 
 
 
 
 
 
 | 99 | pjm2 | 1.1 | print "<select size=\"1\" name=\"machine\">"; | 
 
 
 
 
 | 100 |  |  | if ($machine) { ?> | 
 
 
 
 
 | 101 |  |  | <option selected value="<? echo $machine ?>"><? echo $machine ?></option> | 
 
 
 
 
 | 102 |  |  | <option value="">----------------</option> | 
 
 
 
 
 | 103 |  |  | <? } | 
 
 
 
 
 | 104 |  |  | foreach($file_array as $file_name) { | 
 
 
 
 
 
 
 
 | 105 | pjm2 | 1.3 | #if (is_dir($file_name)) { | 
 
 
 
 
 
 
 
 | 106 | pjm2 | 1.1 | print "<option value=\"$file_name\">$file_name</option>"; | 
 
 
 
 
 
 
 
 | 107 | pjm2 | 1.3 | #} | 
 
 
 
 
 
 
 
 | 108 | pjm2 | 1.1 | } | 
 
 
 
 
 | 109 |  |  | print "</select>"; | 
 
 
 
 
 | 110 |  |  |  | 
 
 
 
 
 | 111 |  |  | ?> | 
 
 
 
 
 | 112 |  |  | <input type="submit" name="submit" value="Display"> | 
 
 
 
 
 | 113 |  |  | </form> | 
 
 
 
 
 | 114 |  |  |  | 
 
 
 
 
 | 115 |  |  | <? if ($machine) { | 
 
 
 
 
 | 116 |  |  |  | 
 
 
 
 
 
 
 
 | 117 | pjm2 | 1.12 | $last_modified = filemtime("$latestDirectory/$machine/$latestData"); | 
 
 
 
 
 | 118 |  |  | clearstatcache(); | 
 
 
 
 
 | 119 |  |  | $data_age = time() - $last_modified; | 
 
 
 
 
 | 120 |  |  |  | 
 
 
 
 
 
 
 
 | 121 | pjm2 | 1.17 | $last_modified = date("l jS F - g:ia", $last_modified); | 
 
 
 
 
 
 
 
 | 122 | pjm2 | 1.12 |  | 
 
 
 
 
 | 123 |  |  | if ($data_age > $warning_age) { | 
 
 
 
 
 | 124 |  |  | $warning = <<<EOT | 
 
 
 
 
 | 125 |  |  | <br> | 
 
 
 
 
 | 126 |  |  | <font color="red"><b> | 
 
 
 
 
 | 127 |  |  | Warning: | 
 
 
 
 
 | 128 |  |  | </b></font> | 
 
 
 
 
 | 129 |  |  | This realtime report is too old to be considered recent | 
 
 
 
 
 | 130 |  |  | EOT; | 
 
 
 
 
 | 131 |  |  | } | 
 
 
 
 
 | 132 |  |  |  | 
 
 
 
 
 | 133 |  |  | echo <<<EOT | 
 
 
 
 
 
 
 
 | 134 | pjm2 | 1.16 | <table border="0" bgcolor="#000066" cellpadding="3" cellspacing="1"> | 
 
 
 
 
 
 
 
 | 135 | pjm2 | 1.12 | <tr> | 
 
 
 
 
 | 136 |  |  | <td bgcolor="#000066"> | 
 
 
 
 
 | 137 |  |  |   | 
 
 
 
 
 | 138 |  |  | </td> | 
 
 
 
 
 | 139 |  |  | <td bgcolor="#ffffcc"> | 
 
 
 
 
 | 140 |  |  | <font face="arial,sans-serif" size="2"> | 
 
 
 
 
 | 141 |  |  | <b>Recipt date:</b> $last_modified | 
 
 
 
 
 | 142 |  |  | $warning | 
 
 
 
 
 | 143 |  |  | </font> | 
 
 
 
 
 | 144 |  |  | </td> | 
 
 
 
 
 | 145 |  |  | </tr> | 
 
 
 
 
 | 146 |  |  | </table> | 
 
 
 
 
 | 147 |  |  | EOT; | 
 
 
 
 
 | 148 |  |  |  | 
 
 
 
 
 
 
 
 | 149 | pjm2 | 1.1 | # Read the file. | 
 
 
 
 
 | 150 |  |  | #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,"; | 
 
 
 
 
 
 
 
 | 151 | pjm2 | 1.2 | $input = file("$latestDirectory/$machine/$latestData"); | 
 
 
 
 
 
 
 
 | 152 | pjm2 | 1.1 | # All we need is the first line if there is more than one line. | 
 
 
 
 
 | 153 |  |  | $input = $input[0]; | 
 
 
 
 
 | 154 |  |  |  | 
 
 
 
 
 | 155 |  |  | if (empty($input)) { | 
 
 
 
 
 | 156 |  |  | echo "<br><br>There was an error reading from the latest packet received.  Please notify your i-scream server administrator."; | 
 
 
 
 
 | 157 |  |  | } | 
 
 
 
 
 | 158 |  |  | else { | 
 
 
 
 
 | 159 |  |  | # Display the data specified in the display include. | 
 
 
 
 
 | 160 |  |  | include("latest_display.inc.php"); | 
 
 
 
 
 | 161 |  |  | } | 
 
 
 
 
 
 
 
 | 162 | pjm2 | 1.9 | } | 
 
 
 
 
 
 
 
 | 163 | pjm2 | 1.12 |  | 
 
 
 
 
 
 
 
 | 164 | pjm2 | 1.1 | ?> | 
 
 
 
 
 | 165 |  |  |  | 
 
 
 
 
 
 
 
 | 166 | pjm2 | 1.16 | <? printLine(""); ?> | 
 
 
 
 
 
 
 
 | 167 | pjm2 | 1.1 |  | 
 
 
 
 
 | 168 |  |  | <? include($bottomHTML); ?> |