1 |
pjm2 |
1.1 |
<?php |
2 |
|
|
|
3 |
tdb |
1.34 |
# |
4 |
|
|
# i-scream central monitoring system |
5 |
tdb |
1.36 |
# http://www.i-scream.org |
6 |
tdb |
1.34 |
# 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 |
pjm2 |
1.1 |
# Navigation for the i-scream alerts. |
24 |
|
|
# pjm2@ukc.ac.uk |
25 |
|
|
# |
26 |
|
|
# CONFIGURABLE CONSTANTS: - |
27 |
|
|
|
28 |
|
|
include("alerts_config.inc.php"); |
29 |
|
|
|
30 |
|
|
# |
31 |
|
|
# END CONFIGURATION |
32 |
|
|
|
33 |
|
|
include("iutils.inc.php"); |
34 |
|
|
|
35 |
|
|
function printLine($title) { |
36 |
|
|
echo "<hr style=\"color:#9999ff;\">"; |
37 |
|
|
echo "<b>$title</b>"; |
38 |
|
|
} |
39 |
|
|
|
40 |
pjm2 |
1.2 |
function getValue($value, $alert) { |
41 |
|
|
preg_match("/$value=([^\,\}]*)[\,\}]/", $alert, $matches); |
42 |
|
|
return $matches[1]; |
43 |
|
|
} |
44 |
|
|
|
45 |
pjm2 |
1.14 |
function printAlert($machine, $alert, $small="") { |
46 |
pjm2 |
1.5 |
|
47 |
pjm2 |
1.26 |
global $fontsize; |
48 |
|
|
|
49 |
pjm2 |
1.5 |
include("alerts_config.inc.php"); |
50 |
|
|
|
51 |
pjm2 |
1.20 |
$alertLevelNum = getValue("alertLevel", $alert); |
52 |
pjm2 |
1.2 |
$lastAlert = getValue("lastAlert", $alert); |
53 |
|
|
$thresholdLevel = getValue("thresholdLevel", $alert); |
54 |
|
|
$source = getValue("source", $alert); |
55 |
|
|
$thresholdValue = getValue("thresholdValue", $alert); |
56 |
|
|
$value = getValue("value", $alert); |
57 |
|
|
$attributeName = getValue("attributeName", $alert); |
58 |
|
|
$timeTillNextAlert = getValue("timeTillNextAlert", $alert); |
59 |
|
|
$initialAlertTime = getValue("initialAlertTime", $alert); |
60 |
pjm2 |
1.4 |
|
61 |
pjm2 |
1.25 |
if ($thresholdLevel == "1") { |
62 |
|
|
$thresholdLevel = "Lower"; |
63 |
|
|
} |
64 |
|
|
else if ($thresholdLevel == "2") { |
65 |
|
|
$thresholdLevel = "Upper"; |
66 |
|
|
} |
67 |
|
|
else { |
68 |
|
|
$thresholdLevel = "Normal"; |
69 |
|
|
} |
70 |
|
|
|
71 |
pjm2 |
1.20 |
$alertColour = $alertLevelColours[$alertLevelNum]; |
72 |
|
|
$alertLevel = $alertLevelNames[$alertLevelNum]; |
73 |
pjm2 |
1.6 |
$initialAlertTime = strftime("%x %X", intval($initialAlertTime / 1000)); |
74 |
pjm2 |
1.5 |
|
75 |
pjm2 |
1.27 |
if ($small == "on") { |
76 |
pjm2 |
1.16 |
echo <<<EOT |
77 |
|
|
<tr> |
78 |
pjm2 |
1.17 |
<td width="50"> |
79 |
|
|
|
80 |
|
|
</td> |
81 |
pjm2 |
1.30 |
<td> |
82 |
pjm2 |
1.20 |
<img src="level$alertLevelNum.gif" width="41" height="9" border="0" alt="$alertLevel"> |
83 |
|
|
</td> |
84 |
pjm2 |
1.30 |
<td> |
85 |
pjm2 |
1.26 |
<font size="$fontsize" color="$alertColour"><b>$alertLevel</b></font> |
86 |
pjm2 |
1.17 |
</td> |
87 |
pjm2 |
1.30 |
<td> |
88 |
tdb |
1.33 |
<font size="$fontsize">$attributeName (c:$value t:$thresholdValue)</font> |
89 |
pjm2 |
1.17 |
</td> |
90 |
pjm2 |
1.16 |
<td> |
91 |
pjm2 |
1.17 |
|
92 |
pjm2 |
1.16 |
</td> |
93 |
|
|
</tr> |
94 |
|
|
EOT; |
95 |
pjm2 |
1.13 |
} |
96 |
|
|
else { |
97 |
|
|
echo <<<EOT |
98 |
|
|
|
99 |
pjm2 |
1.22 |
<table border="0" cellspacing="5" width="100%"> |
100 |
pjm2 |
1.13 |
<tr> |
101 |
pjm2 |
1.23 |
<td align="left" width="40%"> |
102 |
pjm2 |
1.21 |
<img src="level$alertLevelNum.gif" width="41" height="9" border="0" alt="$alertLevel"> |
103 |
|
|
<font color="$alertColour" size="2"><b>$alertLevel</b></font> |
104 |
|
|
</td> |
105 |
pjm2 |
1.23 |
<td align="right" width="60%"> |
106 |
pjm2 |
1.22 |
<b>$attributeName</b> |
107 |
|
|
</td> |
108 |
|
|
</tr> |
109 |
|
|
<tr> |
110 |
|
|
<td align="right"><font size="2">Threshold:</font></td> |
111 |
pjm2 |
1.25 |
<td align="left">$thresholdValue ($thresholdLevel)</td> |
112 |
pjm2 |
1.13 |
</tr> |
113 |
|
|
<tr> |
114 |
pjm2 |
1.22 |
<td align="right"><font size="2">Alert value:</font></td> |
115 |
|
|
<td align="left"><b>$value</b></td> |
116 |
pjm2 |
1.13 |
</tr> |
117 |
|
|
<tr> |
118 |
pjm2 |
1.22 |
<td align="right"><font size="2">Initially raised:</font></td> |
119 |
|
|
<td align="left">$initialAlertTime</td> |
120 |
pjm2 |
1.13 |
</tr> |
121 |
|
|
</table> |
122 |
|
|
|
123 |
pjm2 |
1.4 |
EOT; |
124 |
pjm2 |
1.13 |
printLine(""); |
125 |
|
|
} |
126 |
pjm2 |
1.4 |
|
127 |
pjm2 |
1.1 |
} |
128 |
|
|
|
129 |
pjm2 |
1.14 |
function printReports($machine, $small="") { |
130 |
pjm2 |
1.26 |
global $fontsize; |
131 |
|
|
|
132 |
pjm2 |
1.7 |
# Get a list of all files in the machine's directory. |
133 |
|
|
include("alerts_config.inc.php"); |
134 |
|
|
$alertArray = getdirArray("$alertDirectory/$machine", 'rsort'); |
135 |
|
|
|
136 |
pjm2 |
1.27 |
if ($small == "on") { |
137 |
pjm2 |
1.15 |
echo <<<EOT |
138 |
pjm2 |
1.30 |
<table border="0" cellpadding="2" cellspacing="6"> |
139 |
pjm2 |
1.15 |
<tr> |
140 |
pjm2 |
1.20 |
<td colspan="5"> |
141 |
pjm2 |
1.26 |
<font size="$fontsize"><b><a href="alerts.php?machine=$machine" style="color: black; text-decoration: none;">$machine</a></b></font> |
142 |
pjm2 |
1.15 |
</td> |
143 |
|
|
</tr> |
144 |
|
|
EOT; |
145 |
pjm2 |
1.14 |
} |
146 |
|
|
else { |
147 |
|
|
echo <<<EOT |
148 |
|
|
<p> </p> |
149 |
|
|
<table border="0" cellpadding="3" cellspacing="2" bgcolor="#000066" width="100%"> |
150 |
pjm2 |
1.30 |
<tr> |
151 |
pjm2 |
1.14 |
<td> |
152 |
|
|
<font color="white"> |
153 |
|
|
<b> |
154 |
pjm2 |
1.24 |
Current alerts for <a href="latest.php?machine=$machine" style="color: white">$machine</a> |
155 |
pjm2 |
1.14 |
</b> |
156 |
|
|
<font size="2"> |
157 |
|
|
<br>Sorted by time, latest first. |
158 |
|
|
</font> |
159 |
|
|
</font> |
160 |
|
|
</td> |
161 |
|
|
</tr> |
162 |
|
|
<tr> |
163 |
|
|
<td bgcolor="white"> |
164 |
pjm2 |
1.7 |
|
165 |
|
|
EOT; |
166 |
|
|
|
167 |
pjm2 |
1.14 |
printLine(""); |
168 |
|
|
} |
169 |
pjm2 |
1.7 |
|
170 |
pjm2 |
1.8 |
if ($alertArray != FALSE) { |
171 |
|
|
|
172 |
|
|
foreach($alertArray as $file_name) { |
173 |
|
|
$input = file("$alertDirectory/$machine/$file_name"); |
174 |
|
|
$input = $input[0]; |
175 |
|
|
$alerts[] = $input; |
176 |
|
|
} |
177 |
|
|
|
178 |
|
|
foreach ($alerts as $alert) { |
179 |
pjm2 |
1.14 |
printAlert($machine, $alert, $small); |
180 |
pjm2 |
1.8 |
} |
181 |
pjm2 |
1.7 |
} |
182 |
pjm2 |
1.8 |
else { |
183 |
pjm2 |
1.27 |
if ($small != "on") { |
184 |
pjm2 |
1.21 |
echo "There are currently no alerts held about <b>$machine</b>"; |
185 |
|
|
printLine(""); |
186 |
|
|
} |
187 |
pjm2 |
1.7 |
} |
188 |
pjm2 |
1.10 |
|
189 |
pjm2 |
1.27 |
if ($small == "on") { |
190 |
pjm2 |
1.31 |
echo <<<EOT |
191 |
|
|
<tr> |
192 |
|
|
<td colspan="5"> </td> |
193 |
|
|
</tr> |
194 |
|
|
</table> |
195 |
|
|
EOT; |
196 |
pjm2 |
1.14 |
} |
197 |
|
|
else { |
198 |
|
|
echo <<<EOT |
199 |
|
|
</td> |
200 |
|
|
</tr> |
201 |
|
|
</table> |
202 |
pjm2 |
1.10 |
EOT; |
203 |
pjm2 |
1.14 |
} |
204 |
pjm2 |
1.4 |
} |
205 |
|
|
|
206 |
|
|
|
207 |
pjm2 |
1.1 |
?> |
208 |
|
|
|
209 |
|
|
<? include($titleHTML); ?> |
210 |
|
|
|
211 |
pjm2 |
1.28 |
<? if ($hideform != "on") { ?> |
212 |
pjm2 |
1.18 |
|
213 |
pjm2 |
1.16 |
<? printLine("Latest alerts for hosts"); ?> |
214 |
pjm2 |
1.1 |
|
215 |
|
|
<form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> |
216 |
|
|
<? |
217 |
|
|
|
218 |
|
|
$file_array = getdirArray($alertDirectory,'asort'); |
219 |
|
|
print "<select size=\"1\" name=\"machine\">"; |
220 |
|
|
if ($machine) { ?> |
221 |
|
|
<option selected value="<? echo $machine ?>"><? echo $machine ?></option> |
222 |
|
|
<option value="">----------------</option> |
223 |
|
|
<? } |
224 |
pjm2 |
1.9 |
foreach ($file_array as $file_name) { |
225 |
pjm2 |
1.1 |
#if (is_dir($file_name)) { |
226 |
|
|
print "<option value=\"$file_name\">$file_name</option>"; |
227 |
|
|
#} |
228 |
|
|
} |
229 |
|
|
print "</select>"; |
230 |
|
|
|
231 |
|
|
?> |
232 |
pjm2 |
1.14 |
<input type="hidden" name="small" value="<?=$small?>"> |
233 |
pjm2 |
1.1 |
<input type="submit" name="submit" value="Display"> |
234 |
|
|
</form> |
235 |
pjm2 |
1.16 |
|
236 |
|
|
<? } ?> |
237 |
pjm2 |
1.1 |
|
238 |
|
|
<? if ($machine) { |
239 |
pjm2 |
1.3 |
|
240 |
|
|
printLine(""); |
241 |
pjm2 |
1.1 |
|
242 |
pjm2 |
1.32 |
$masterwidth = ""; |
243 |
|
|
if ($small != "on") { |
244 |
|
|
$masterwidth = ' width="100%"'; |
245 |
|
|
} |
246 |
|
|
|
247 |
|
|
echo <<<EOT |
248 |
|
|
<table border="0" align="center"$masterwidth> |
249 |
|
|
<tr> |
250 |
|
|
<td> |
251 |
|
|
EOT; |
252 |
|
|
|
253 |
pjm2 |
1.9 |
if ($machine == "ALL") { |
254 |
|
|
$machine_array = getdirArray($alertDirectory, 'asort'); |
255 |
pjm2 |
1.12 |
if ($machine_array != FALSE) { |
256 |
|
|
foreach ($machine_array as $machine) { |
257 |
pjm2 |
1.14 |
printReports($machine, $small); |
258 |
pjm2 |
1.12 |
} |
259 |
tdb |
1.33 |
} |
260 |
|
|
else { |
261 |
|
|
print "<font size='$fontsize'><b>There are currently no alerts</b></font>"; |
262 |
pjm2 |
1.9 |
} |
263 |
|
|
} |
264 |
|
|
else { |
265 |
pjm2 |
1.14 |
printReports($machine, $small); |
266 |
pjm2 |
1.9 |
} |
267 |
pjm2 |
1.1 |
|
268 |
pjm2 |
1.32 |
echo <<<EOT |
269 |
|
|
</td> |
270 |
|
|
</tr> |
271 |
|
|
</table> |
272 |
|
|
EOT; |
273 |
pjm2 |
1.5 |
} |
274 |
|
|
else { |
275 |
|
|
printLine(""); |
276 |
pjm2 |
1.1 |
} |
277 |
|
|
|
278 |
|
|
?> |
279 |
|
|
|
280 |
|
|
<? include($bottomHTML); ?> |