20 |
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
|
# |
22 |
|
|
23 |
– |
# Navigation for the i-scream reports. |
24 |
– |
# pjm2@ukc.ac.uk |
25 |
– |
# |
23 |
|
# CONFIGURABLE CONSTANTS: - |
24 |
|
|
25 |
|
include("latest_config.inc.php"); |
29 |
|
|
30 |
|
include("iutils.inc.php"); |
31 |
|
|
32 |
+ |
if ($formMethod == "GET") { |
33 |
+ |
$machine = isset($_GET['machine']) ? $_GET['machine'] : ""; |
34 |
+ |
} |
35 |
+ |
|
36 |
+ |
|
37 |
|
function printLine($title) { |
38 |
|
echo "<hr style=\"color:#9999ff;\">"; |
39 |
|
echo "<b>$title</b>"; |
40 |
|
} |
41 |
|
|
42 |
|
|
43 |
+ |
function showUptime($title, $value, $input, $graph="") { |
44 |
+ |
$report = $value; |
45 |
+ |
|
46 |
+ |
$value = getPregMatch($value, $input); |
47 |
+ |
if (!isset($value)) { |
48 |
+ |
$value = "<i><font color=\"#999999\">not sent</font></i>"; |
49 |
+ |
} |
50 |
+ |
?> |
51 |
+ |
<table border="0" width="100%"> |
52 |
+ |
<tr> |
53 |
+ |
<td width="50%" align="right" valign="top"> |
54 |
+ |
<b><?=$title?></b> |
55 |
+ |
</td> |
56 |
+ |
<td width="50%" align="left" valign="top"> |
57 |
+ |
<? if (preg_match("/^[0-9]+\.?[0-9]*$/", $value)) { |
58 |
+ |
linkToHistory($graph); |
59 |
+ |
} ?> |
60 |
+ |
<?=uptime($value)?> (<?=$value?> seconds)</td> |
61 |
+ |
</tr> |
62 |
+ |
</table> |
63 |
+ |
<? |
64 |
+ |
} |
65 |
+ |
|
66 |
+ |
|
67 |
|
function showStat($title, $value, $input, $graph="") { |
68 |
|
|
69 |
|
$report = $value; |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
+ |
# convert bytes to MB |
103 |
+ |
function b2Mb($bytes) { |
104 |
+ |
$mb = $bytes / (1024*1024); |
105 |
+ |
return (int) $mb; |
106 |
+ |
} |
107 |
+ |
|
108 |
+ |
|
109 |
+ |
# Convert seconds uptime to something readable |
110 |
+ |
function uptime($until) { |
111 |
+ |
$day = date('z', $until); |
112 |
+ |
$hour = date('G', $until); |
113 |
+ |
$hour = $hour - 1; # one too many |
114 |
+ |
$minute = date('i', $until); |
115 |
+ |
$return = ""; |
116 |
+ |
if ($day) { |
117 |
+ |
$return = "$return$day Days "; |
118 |
+ |
} |
119 |
+ |
if ($hour) { |
120 |
+ |
$return = "$return$hour Hours "; |
121 |
+ |
} |
122 |
+ |
return "$return$minute Mins"; |
123 |
+ |
} |
124 |
+ |
|
125 |
+ |
|
126 |
|
# show all disk information. |
127 |
|
function showDisks($diskRoot, $units, $input) { |
128 |
|
include("latest_config.inc.php"); |
139 |
|
$totalinodes = getPregMatch("$diskRoot.p$i.attributes.totalinodes", $input); |
140 |
|
$freeinodes = getPregMatch("$diskRoot.p$i.attributes.freeinodes", $input); |
141 |
|
showBar("$name ($mount)<br>space used", $used, $total, $units, $input, "disk-$graph"); |
142 |
< |
showBar("inodes used", (int) $freeinodes, (int) $totalinodes, " inodes", $input, "", "swap"); |
142 |
> |
showBar("inodes used", (float) $freeinodes, (float) $totalinodes, " inodes", $input, "", "swap"); |
143 |
> |
showStat("FS Type", "$diskRoot.p$i.attributes.fstype", $input); |
144 |
|
print " <br><br>\n"; |
145 |
|
} |
146 |
|
else { |
175 |
|
# show all network information. |
176 |
|
function showNet($netRoot, $input) { |
177 |
|
include("latest_config.inc.php"); |
178 |
< |
|
178 |
> |
|
179 |
|
$i = 0; |
180 |
|
while(1) { |
181 |
|
$name = getPregMatch("$netRoot.p$i.attributes.name", $input); |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
+ |
# show all mail queue information |
197 |
+ |
function showMailQ($mailqRoot, $input) { |
198 |
+ |
include("latest_config.inc.php"); |
199 |
+ |
|
200 |
+ |
$i = 0; |
201 |
+ |
while(1) { |
202 |
+ |
$name = getPregMatch("$mailqRoot.p$i.attributes.name", $input); |
203 |
+ |
if ($name) { |
204 |
+ |
print "<br><center><b>($name)</b></center>"; |
205 |
+ |
$name = preg_replace("/\s+/", "", $name); |
206 |
+ |
showStat("Messages in queue", "$mailqRoot.p$i.attributes.size", $input, "mailq-$name"); |
207 |
+ |
print " <br>\n"; |
208 |
+ |
} |
209 |
+ |
else { |
210 |
+ |
break; |
211 |
+ |
} |
212 |
+ |
$i++; |
213 |
+ |
} |
214 |
+ |
} |
215 |
+ |
|
216 |
+ |
|
217 |
|
# Return a preg_match result. |
218 |
|
function getPregMatch($value, $input) { |
219 |
|
preg_match("/$value=([^\,\}]*)[\,\}]/", $input, $matches); |
241 |
|
$value = $max - $value; |
242 |
|
} |
243 |
|
|
244 |
+ |
if ($units == 'MB') { |
245 |
+ |
$value = b2Mb ($value); |
246 |
+ |
$max = b2Mb ($max); |
247 |
+ |
} |
248 |
+ |
|
249 |
|
if(empty($max)) { |
250 |
|
$width = 1; |
251 |
|
} |
318 |
|
</b></font> |
319 |
|
This realtime report is too old to be considered recent |
320 |
|
EOT; |
321 |
+ |
} |
322 |
+ |
else { |
323 |
+ |
$warning = ""; |
324 |
|
} |
325 |
|
|
326 |
|
echo <<<EOT |