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