1 |
|
<?php |
2 |
|
|
3 |
+ |
# |
4 |
+ |
# i-scream central monitoring system |
5 |
+ |
# http://www.i-scream.org.uk |
6 |
+ |
# Copyright (C) 2000-2002 i-scream |
7 |
+ |
# |
8 |
+ |
# This program is free software; you can redistribute it and/or |
9 |
+ |
# modify it under the terms of the GNU General Public License |
10 |
+ |
# as published by the Free Software Foundation; either version 2 |
11 |
+ |
# of the License, or (at your option) any later version. |
12 |
+ |
# |
13 |
+ |
# This program is distributed in the hope that it will be useful, |
14 |
+ |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
+ |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
+ |
# GNU General Public License for more details. |
17 |
+ |
# |
18 |
+ |
# You should have received a copy of the GNU General Public License |
19 |
+ |
# along with this program; if not, write to the Free Software |
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 |
|
# |
38 |
|
} |
39 |
|
|
40 |
|
|
41 |
< |
function showStat($title, $value, $input) { |
41 |
> |
function showStat($title, $value, $input, $graph="") { |
42 |
|
|
43 |
|
$report = $value; |
44 |
|
|
45 |
< |
preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches); |
46 |
< |
$value = $matches[1]; |
27 |
< |
if (empty($value)) { |
45 |
> |
$value = getPregMatch($value, $input); |
46 |
> |
if (!isset($value)) { |
47 |
|
$value = "<i><font color=\"#999999\">not sent</font></i>"; |
48 |
|
} |
49 |
|
?> |
54 |
|
</td> |
55 |
|
<td width="50%" align="left" valign="top"> |
56 |
|
<? if (preg_match("/^[0-9]+\.?[0-9]*$/", $value)) { |
57 |
< |
linkToHistory($report); |
57 |
> |
linkToHistory($graph); |
58 |
|
} ?> |
59 |
|
<?=$value?></td> |
60 |
|
</tr> |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
< |
function linkToHistory($report) { |
66 |
> |
function linkToHistory($graph) { |
67 |
|
global $machine; |
68 |
< |
$yesterday = date("Y-m-d", time() - 86400); |
69 |
< |
echo <<<EOT |
70 |
< |
<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> |
68 |
> |
if(!empty($graph)) { |
69 |
> |
echo <<<EOT |
70 |
> |
<a href="graphs.php?machine_name=$machine&graph=$graph&submit=Show"><img src="minichart.gif" alt="View historical graphs of this data" width="20" height="20" border="0"></a> |
71 |
|
EOT; |
72 |
+ |
} |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
+ |
# show all disk information. |
77 |
+ |
function showDisks($diskRoot, $units, $input) { |
78 |
+ |
include("latest_config.inc.php"); |
79 |
+ |
|
80 |
+ |
$i = 0; |
81 |
+ |
while(1) { |
82 |
+ |
$name = getPregMatch("$diskRoot.p$i.attributes.name", $input); |
83 |
+ |
$mount = getPregMatch("$diskRoot.p$i.attributes.mount", $input); |
84 |
+ |
if ($name || $mount) { |
85 |
+ |
$used = "$diskRoot.p$i.attributes.used"; |
86 |
+ |
$kbytes = "$diskRoot.p$i.attributes.kbytes"; |
87 |
+ |
$graph = preg_replace("/_/", "$hex_underscore", $mount); |
88 |
+ |
$graph = preg_replace("/\//", "$hex_slash", $graph); |
89 |
+ |
showBar("$name<br>($mount)", $used, $kbytes, $units, $input, "disk-$graph"); |
90 |
+ |
} |
91 |
+ |
else { |
92 |
+ |
break; |
93 |
+ |
} |
94 |
+ |
$i++; |
95 |
+ |
} |
96 |
+ |
} |
97 |
+ |
|
98 |
+ |
# Return a preg_match result. |
99 |
+ |
function getPregMatch($value, $input) { |
100 |
+ |
preg_match("/$value=([^\,\}]*)[\,\}]/", $input, $matches); |
101 |
+ |
return $matches[1]; |
102 |
+ |
} |
103 |
+ |
|
104 |
+ |
|
105 |
|
# show a bar-represented value. |
106 |
< |
function showBar($title, $value, $max, $units, $input, $arrange='normal') { |
106 |
> |
function showBar($title, $value, $max, $units, $input, $graph="", $arrange='normal') { |
107 |
|
|
108 |
|
include("latest_config.inc.php"); |
109 |
|
|
110 |
|
$report = $value; |
111 |
|
|
112 |
< |
preg_match("/$value=([^\,]*)\,/", $input, $matches); |
64 |
< |
$value = $matches[1]; |
112 |
> |
$value = getPregMatch($value, $input); |
113 |
|
if (!is_int($max)) { |
114 |
< |
preg_match("/$max=([^\,]*)\,/", $input, $matches); |
67 |
< |
$max = $matches[1]; |
114 |
> |
$max = getPregMatch($max, $input); |
115 |
|
} |
116 |
< |
if (empty($value) || empty($max)) { |
116 |
> |
if (!isset($value) || !isset($max)) { |
117 |
|
return; |
118 |
|
} |
119 |
|
|
121 |
|
$value = $max - $value; |
122 |
|
} |
123 |
|
|
124 |
< |
$width = intval($max_width * $value / $max); |
124 |
> |
if(empty($max)) { |
125 |
> |
$width = 1; |
126 |
> |
} |
127 |
> |
else { |
128 |
> |
$width = intval($max_width * $value / $max); |
129 |
> |
if ($width < 1) { |
130 |
> |
$width = 1; |
131 |
> |
} |
132 |
> |
} |
133 |
|
|
134 |
|
?> |
135 |
|
<table border="0" cellpadding="0" cellspacing="0" align="center"> |
136 |
|
<tr> |
137 |
< |
<td colspan="2"><? linkToHistory($report); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td> |
137 |
> |
<td colspan="2"><? linkToHistory($graph); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td> |
138 |
|
</tr> |
139 |
|
<tr> |
140 |
|
<td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td> |
186 |
|
clearstatcache(); |
187 |
|
$data_age = time() - $last_modified; |
188 |
|
|
189 |
< |
$last_modified = date("l jS F - g:ia", $last_modified); |
189 |
> |
$last_modified = date("l jS F Y - g:ia", $last_modified); |
190 |
|
|
191 |
|
if ($data_age > $warning_age) { |
192 |
|
$warning = <<<EOT |
221 |
|
$input = $input[0]; |
222 |
|
} |
223 |
|
|
224 |
< |
if (empty($input)) { |
224 |
> |
if (!isset($input)) { |
225 |
|
echo "<br><br>There are currently no latest details about <b>$machine</b>. Please notify your i-scream server administrator if you believe this to be incorrect."; |
226 |
|
} |
227 |
|
else { |