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 |
|
|
27 |
|
?> |
28 |
|
<table border="0" width="100%"> |
29 |
|
<tr> |
30 |
< |
<td width="50%" align="right" valign="top"><b><font size="2"><?=$title?>:</font></b></td> |
31 |
< |
<td width="50%" align="left" valign="top"><font size="2"><?=$value?></font></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"><img src="minichart.gif" width="20" height="20" border="0"></a> |
43 |
+ |
EOT; |
44 |
+ |
} |
45 |
+ |
|
46 |
+ |
|
47 |
|
# show a bar-represented value. |
48 |
< |
function showBar($title, $value, $max, $input) { |
48 |
> |
function showBar($title, $value, $max, $units, $input) { |
49 |
|
|
50 |
|
include("latest_config.inc.php"); |
51 |
|
|
64 |
|
?> |
65 |
|
<table border="0" cellpadding="0" cellspacing="0" align="center"> |
66 |
|
<tr> |
67 |
< |
<td colspan="2"><b><?=$title?></b></td> |
67 |
> |
<td colspan="2"><b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td> |
68 |
|
</tr> |
69 |
|
<tr> |
70 |
|
<td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td> |
73 |
|
<td colspan="2"><img src="<?=$scaleImage?>" border="0" height="11" width="<?=$max_width?>"></td> |
74 |
|
</tr> |
75 |
|
<tr> |
76 |
< |
<td align="left">0</td> |
77 |
< |
<td align="right"><?=$max?></td> |
76 |
> |
<td align="left">0<?=$units?></td> |
77 |
> |
<td align="right"><?=$max?><?=$units?></td> |
78 |
|
</tr> |
79 |
+ |
<tr> |
80 |
+ |
<td colspan="2"><? linkToHistory($value); ?> View yesterday's graph</td> |
81 |
+ |
</tr> |
82 |
+ |
<tr> |
83 |
+ |
<td colspan="2"> </td> |
84 |
+ |
</tr> |
85 |
|
</table> |
86 |
|
<? |
87 |
|
} |
91 |
|
|
92 |
|
<? include($titleHTML); ?> |
93 |
|
|
94 |
< |
<? printLine("Display the latest information received from a host."); ?> |
94 |
> |
<? printLine("Display the latest information received from a host"); ?> |
95 |
|
|
96 |
|
<form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> |
97 |
|
<? |
115 |
|
|
116 |
|
<? if ($machine) { |
117 |
|
|
118 |
+ |
$last_modified = filemtime("$latestDirectory/$machine/$latestData"); |
119 |
+ |
clearstatcache(); |
120 |
+ |
$data_age = time() - $last_modified; |
121 |
+ |
|
122 |
+ |
$last_modified = date("l jS F - g:ia", $last_modified); |
123 |
+ |
|
124 |
+ |
if ($data_age > $warning_age) { |
125 |
+ |
$warning = <<<EOT |
126 |
+ |
<br> |
127 |
+ |
<font color="red"><b> |
128 |
+ |
Warning: |
129 |
+ |
</b></font> |
130 |
+ |
This realtime report is too old to be considered recent |
131 |
+ |
EOT; |
132 |
+ |
} |
133 |
+ |
|
134 |
+ |
echo <<<EOT |
135 |
+ |
<table border="0" bgcolor="#000066" cellpadding="3" cellspacing="1"> |
136 |
+ |
<tr> |
137 |
+ |
<td bgcolor="#000066"> |
138 |
+ |
|
139 |
+ |
</td> |
140 |
+ |
<td bgcolor="#ffffcc"> |
141 |
+ |
<font face="arial,sans-serif" size="2"> |
142 |
+ |
<b>Recipt date:</b> $last_modified |
143 |
+ |
$warning |
144 |
+ |
</font> |
145 |
+ |
</td> |
146 |
+ |
</tr> |
147 |
+ |
</table> |
148 |
+ |
EOT; |
149 |
+ |
|
150 |
|
# Read the file. |
151 |
|
#$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,"; |
152 |
|
$input = file("$latestDirectory/$machine/$latestData"); |
161 |
|
include("latest_display.inc.php"); |
162 |
|
} |
163 |
|
} |
164 |
< |
printLine(""); |
164 |
> |
|
165 |
|
?> |
166 |
|
|
167 |
+ |
<? printLine(""); ?> |
168 |
|
|
169 |
|
<? include($bottomHTML); ?> |