1 |
|
<?php |
2 |
|
|
3 |
– |
# Navigation for the i-scream alerts. |
4 |
– |
# pjm2@ukc.ac.uk |
3 |
|
# |
4 |
+ |
# i-scream central monitoring system |
5 |
+ |
# http://www.i-scream.org |
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 |
|
# CONFIGURABLE CONSTANTS: - |
24 |
|
|
25 |
|
include("alerts_config.inc.php"); |
29 |
|
|
30 |
|
include("iutils.inc.php"); |
31 |
|
|
32 |
+ |
if ($formMethod == "GET") { |
33 |
+ |
# in order of public.php |
34 |
+ |
$machine = isset($_GET['machine']) ? $_GET['machine'] : ""; |
35 |
+ |
$fontsize = isset($_GET['fontsize']) ? $_GET['fontsize'] : ""; |
36 |
+ |
$hideform = isset($_GET['hideform']) ? $_GET['hideform'] : ""; |
37 |
+ |
$pagewidth = isset($_GET['pagewidth']) ? $_GET['pagewidth'] : ""; |
38 |
+ |
$small = isset($_GET['small']) ? $_GET['small'] : ""; |
39 |
+ |
} |
40 |
+ |
|
41 |
|
function printLine($title) { |
42 |
|
echo "<hr style=\"color:#9999ff;\">"; |
43 |
|
echo "<b>$title</b>"; |
50 |
|
|
51 |
|
function printAlert($machine, $alert, $small="") { |
52 |
|
|
53 |
+ |
global $fontsize; |
54 |
+ |
|
55 |
|
include("alerts_config.inc.php"); |
56 |
|
|
57 |
< |
$alertLevel = getValue("alertLevel", $alert); |
57 |
> |
$alertLevelNum = getValue("alertLevel", $alert); |
58 |
|
$lastAlert = getValue("lastAlert", $alert); |
59 |
|
$thresholdLevel = getValue("thresholdLevel", $alert); |
60 |
|
$source = getValue("source", $alert); |
64 |
|
$timeTillNextAlert = getValue("timeTillNextAlert", $alert); |
65 |
|
$initialAlertTime = getValue("initialAlertTime", $alert); |
66 |
|
|
67 |
< |
$alertColour = $alertLevelColours[$alertLevel]; |
68 |
< |
$alertLevel = $alertLevelNames[$alertLevel]; |
67 |
> |
if ($thresholdLevel == "1") { |
68 |
> |
$thresholdLevel = "Lower"; |
69 |
> |
} |
70 |
> |
else if ($thresholdLevel == "2") { |
71 |
> |
$thresholdLevel = "Upper"; |
72 |
> |
} |
73 |
> |
else { |
74 |
> |
$thresholdLevel = "Normal"; |
75 |
> |
} |
76 |
> |
|
77 |
> |
$alertColour = $alertLevelColours[$alertLevelNum]; |
78 |
> |
$alertLevel = $alertLevelNames[$alertLevelNum]; |
79 |
|
$initialAlertTime = strftime("%x %X", intval($initialAlertTime / 1000)); |
80 |
|
|
81 |
< |
if ($small == "true") { |
82 |
< |
echo "small"; |
81 |
> |
if ($small == "on") { |
82 |
> |
echo <<<EOT |
83 |
> |
<tr> |
84 |
> |
<td width="50"> |
85 |
> |
|
86 |
> |
</td> |
87 |
> |
<td> |
88 |
> |
<img src="level$alertLevelNum.gif" width="41" height="9" border="0" alt="$alertLevel"> |
89 |
> |
</td> |
90 |
> |
<td> |
91 |
> |
<font size="$fontsize" color="$alertColour"><b>$alertLevel</b></font> |
92 |
> |
</td> |
93 |
> |
<td> |
94 |
> |
<font size="$fontsize">$attributeName (c:$value t:$thresholdValue)</font> |
95 |
> |
</td> |
96 |
> |
<td> |
97 |
> |
|
98 |
> |
</td> |
99 |
> |
</tr> |
100 |
> |
EOT; |
101 |
|
} |
102 |
|
else { |
103 |
|
echo <<<EOT |
104 |
|
|
105 |
< |
<table border="0" cellspacing="5"> |
105 |
> |
<table border="0" cellspacing="5" width="100%"> |
106 |
|
<tr> |
107 |
< |
<td><b>$attributeName</b></td> |
108 |
< |
<td> </td> |
109 |
< |
<td><font color="$alertColour" size="2"><b>$alertLevel</b></font></td> |
110 |
< |
<td> </td> |
107 |
> |
<td align="left" width="40%"> |
108 |
> |
<img src="level$alertLevelNum.gif" width="41" height="9" border="0" alt="$alertLevel"> |
109 |
> |
<font color="$alertColour" size="2"><b>$alertLevel</b></font> |
110 |
> |
</td> |
111 |
> |
<td align="right" width="60%"> |
112 |
> |
<b>$attributeName</b> |
113 |
> |
</td> |
114 |
|
</tr> |
115 |
|
<tr> |
116 |
< |
<td><font size="2">Threshold:</font></td> |
117 |
< |
<td>$thresholdValue</td> |
59 |
< |
<td><font size="2">Initially raised:</font></td> |
60 |
< |
<td>$initialAlertTime</td> |
116 |
> |
<td align="right"><font size="2">Threshold:</font></td> |
117 |
> |
<td align="left">$thresholdValue ($thresholdLevel)</td> |
118 |
|
</tr> |
119 |
|
<tr> |
120 |
< |
<td><font size="2">Alert value:</font></td> |
121 |
< |
<td><b>$value</b></td> |
65 |
< |
<td><!--Next alert time:--> </td> |
66 |
< |
<td><!--$timeTillNextAlert--> </td> |
120 |
> |
<td align="right"><font size="2">Alert value:</font></td> |
121 |
> |
<td align="left"><b>$value</b></td> |
122 |
|
</tr> |
123 |
+ |
<tr> |
124 |
+ |
<td align="right"><font size="2">Initially raised:</font></td> |
125 |
+ |
<td align="left">$initialAlertTime</td> |
126 |
+ |
</tr> |
127 |
|
</table> |
128 |
|
|
129 |
|
EOT; |
133 |
|
} |
134 |
|
|
135 |
|
function printReports($machine, $small="") { |
136 |
+ |
global $fontsize; |
137 |
+ |
|
138 |
|
# Get a list of all files in the machine's directory. |
139 |
|
include("alerts_config.inc.php"); |
140 |
|
$alertArray = getdirArray("$alertDirectory/$machine", 'rsort'); |
141 |
|
|
142 |
< |
if ($small == "true") { |
142 |
> |
if ($small == "on") { |
143 |
|
echo <<<EOT |
144 |
< |
<table border="0" cellpadding="2" cellspacing="2" bgcolor="#ffffff" width="100%"> |
144 |
> |
<table border="0" cellpadding="2" cellspacing="6"> |
145 |
|
<tr> |
146 |
< |
<td bgcolor="#000066"> |
147 |
< |
<font color="white"><b>$machine</b></font> |
146 |
> |
<td colspan="5"> |
147 |
> |
<font size="$fontsize"><b><a href="alerts.php?machine=$machine" style="color: black; text-decoration: none;">$machine</a></b></font> |
148 |
|
</td> |
149 |
|
</tr> |
150 |
|
EOT; |
153 |
|
echo <<<EOT |
154 |
|
<p> </p> |
155 |
|
<table border="0" cellpadding="3" cellspacing="2" bgcolor="#000066" width="100%"> |
156 |
< |
<tr> |
156 |
> |
<tr> |
157 |
|
<td> |
158 |
|
<font color="white"> |
159 |
|
<b> |
160 |
< |
Current alerts for $machine |
160 |
> |
Current alerts for <a href="latest.php?machine=$machine" style="color: white">$machine</a> |
161 |
|
</b> |
162 |
|
<font size="2"> |
163 |
|
<br>Sorted by time, latest first. |
186 |
|
} |
187 |
|
} |
188 |
|
else { |
189 |
< |
echo "There are currently no alerts held about <b>$machine</b>"; |
190 |
< |
printLine(""); |
189 |
> |
if ($small != "on") { |
190 |
> |
echo "There are currently no alerts held about <b>$machine</b>"; |
191 |
> |
printLine(""); |
192 |
> |
} |
193 |
|
} |
194 |
|
|
195 |
< |
if ($small == "true") { |
196 |
< |
echo "</table>"; |
195 |
> |
if ($small == "on") { |
196 |
> |
echo <<<EOT |
197 |
> |
<tr> |
198 |
> |
<td colspan="5"> </td> |
199 |
> |
</tr> |
200 |
> |
</table> |
201 |
> |
EOT; |
202 |
|
} |
203 |
|
else { |
204 |
|
echo <<<EOT |
212 |
|
|
213 |
|
?> |
214 |
|
|
215 |
< |
<? include($titleHTML); ?> |
215 |
> |
<?php include($titleHTML); ?> |
216 |
|
|
217 |
< |
<? printLine("Display the latest alerts for a host"); ?> |
217 |
> |
<?php if ($hideform != "on") { ?> |
218 |
|
|
219 |
< |
<form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> |
152 |
< |
<? |
219 |
> |
<?php printLine("Latest alerts for hosts"); ?> |
220 |
|
|
221 |
+ |
<form method="<?php echo $formMethod ?>" action="<?php echo $thisPage ?>"> |
222 |
+ |
<?php |
223 |
+ |
|
224 |
|
$file_array = getdirArray($alertDirectory,'asort'); |
225 |
|
print "<select size=\"1\" name=\"machine\">"; |
226 |
|
if ($machine) { ?> |
227 |
< |
<option selected value="<? echo $machine ?>"><? echo $machine ?></option> |
227 |
> |
<option selected value="<?php echo $machine ?>"><?php echo $machine ?></option> |
228 |
|
<option value="">----------------</option> |
229 |
< |
<? } |
229 |
> |
<?php } |
230 |
|
foreach ($file_array as $file_name) { |
231 |
|
#if (is_dir($file_name)) { |
232 |
|
print "<option value=\"$file_name\">$file_name</option>"; |
235 |
|
print "</select>"; |
236 |
|
|
237 |
|
?> |
238 |
< |
<input type="hidden" name="small" value="<?=$small?>"> |
238 |
> |
<input type="hidden" name="small" value="<?php=$small?>"> |
239 |
|
<input type="submit" name="submit" value="Display"> |
240 |
|
</form> |
241 |
|
|
242 |
< |
<? if ($machine) { |
242 |
> |
<?php } ?> |
243 |
|
|
244 |
+ |
<?php if ($machine) { |
245 |
+ |
|
246 |
|
printLine(""); |
247 |
|
|
248 |
+ |
$masterwidth = ""; |
249 |
+ |
if ($small != "on") { |
250 |
+ |
$masterwidth = ' width="100%"'; |
251 |
+ |
} |
252 |
+ |
|
253 |
+ |
echo <<<EOT |
254 |
+ |
<table border="0" align="center"$masterwidth> |
255 |
+ |
<tr> |
256 |
+ |
<td> |
257 |
+ |
EOT; |
258 |
+ |
|
259 |
|
if ($machine == "ALL") { |
260 |
|
$machine_array = getdirArray($alertDirectory, 'asort'); |
261 |
|
if ($machine_array != FALSE) { |
263 |
|
printReports($machine, $small); |
264 |
|
} |
265 |
|
} |
266 |
+ |
else { |
267 |
+ |
print "<font size='$fontsize'><b>There are currently no alerts</b></font>"; |
268 |
+ |
} |
269 |
|
} |
270 |
|
else { |
271 |
|
printReports($machine, $small); |
272 |
|
} |
273 |
|
|
274 |
+ |
echo <<<EOT |
275 |
+ |
</td> |
276 |
+ |
</tr> |
277 |
+ |
</table> |
278 |
+ |
EOT; |
279 |
|
} |
280 |
|
else { |
281 |
|
printLine(""); |
283 |
|
|
284 |
|
?> |
285 |
|
|
286 |
< |
<? include($bottomHTML); ?> |
286 |
> |
<?php include($bottomHTML); ?> |