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 alerts. |
24 |
|
# pjm2@ukc.ac.uk |
25 |
|
# |
44 |
|
|
45 |
|
function printAlert($machine, $alert, $small="") { |
46 |
|
|
47 |
+ |
global $fontsize; |
48 |
+ |
|
49 |
|
include("alerts_config.inc.php"); |
50 |
|
|
51 |
< |
$alertLevel = getValue("alertLevel", $alert); |
51 |
> |
$alertLevelNum = getValue("alertLevel", $alert); |
52 |
|
$lastAlert = getValue("lastAlert", $alert); |
53 |
|
$thresholdLevel = getValue("thresholdLevel", $alert); |
54 |
|
$source = getValue("source", $alert); |
58 |
|
$timeTillNextAlert = getValue("timeTillNextAlert", $alert); |
59 |
|
$initialAlertTime = getValue("initialAlertTime", $alert); |
60 |
|
|
61 |
< |
$alertColour = $alertLevelColours[$alertLevel]; |
62 |
< |
$alertLevel = $alertLevelNames[$alertLevel]; |
61 |
> |
if ($thresholdLevel == "1") { |
62 |
> |
$thresholdLevel = "Lower"; |
63 |
> |
} |
64 |
> |
else if ($thresholdLevel == "2") { |
65 |
> |
$thresholdLevel = "Upper"; |
66 |
> |
} |
67 |
> |
else { |
68 |
> |
$thresholdLevel = "Normal"; |
69 |
> |
} |
70 |
> |
|
71 |
> |
$alertColour = $alertLevelColours[$alertLevelNum]; |
72 |
> |
$alertLevel = $alertLevelNames[$alertLevelNum]; |
73 |
|
$initialAlertTime = strftime("%x %X", intval($initialAlertTime / 1000)); |
74 |
|
|
75 |
< |
if ($small == "true") { |
75 |
> |
if ($small == "on") { |
76 |
|
echo <<<EOT |
77 |
|
<tr> |
78 |
+ |
<td width="50"> |
79 |
+ |
|
80 |
+ |
</td> |
81 |
|
<td> |
82 |
< |
<font size="2">$attributeName <font color="$alertColour"><b>$alertLevel</b></font></font> |
82 |
> |
<img src="level$alertLevelNum.gif" width="41" height="9" border="0" alt="$alertLevel"> |
83 |
|
</td> |
84 |
+ |
<td> |
85 |
+ |
<font size="$fontsize" color="$alertColour"><b>$alertLevel</b></font> |
86 |
+ |
</td> |
87 |
+ |
<td> |
88 |
+ |
<font size="$fontsize">$attributeName (c:$value t:$thresholdValue)</font> |
89 |
+ |
</td> |
90 |
+ |
<td> |
91 |
+ |
|
92 |
+ |
</td> |
93 |
|
</tr> |
94 |
|
EOT; |
95 |
|
} |
96 |
|
else { |
97 |
|
echo <<<EOT |
98 |
|
|
99 |
< |
<table border="0" cellspacing="5"> |
99 |
> |
<table border="0" cellspacing="5" width="100%"> |
100 |
|
<tr> |
101 |
< |
<td><b>$attributeName</b></td> |
102 |
< |
<td> </td> |
103 |
< |
<td><font color="$alertColour" size="2"><b>$alertLevel</b></font></td> |
104 |
< |
<td> </td> |
101 |
> |
<td align="left" width="40%"> |
102 |
> |
<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 |
> |
<td align="right" width="60%"> |
106 |
> |
<b>$attributeName</b> |
107 |
> |
</td> |
108 |
|
</tr> |
109 |
|
<tr> |
110 |
< |
<td><font size="2">Threshold:</font></td> |
111 |
< |
<td>$thresholdValue</td> |
65 |
< |
<td><font size="2">Initially raised:</font></td> |
66 |
< |
<td>$initialAlertTime</td> |
110 |
> |
<td align="right"><font size="2">Threshold:</font></td> |
111 |
> |
<td align="left">$thresholdValue ($thresholdLevel)</td> |
112 |
|
</tr> |
113 |
|
<tr> |
114 |
< |
<td><font size="2">Alert value:</font></td> |
115 |
< |
<td><b>$value</b></td> |
71 |
< |
<td><!--Next alert time:--> </td> |
72 |
< |
<td><!--$timeTillNextAlert--> </td> |
114 |
> |
<td align="right"><font size="2">Alert value:</font></td> |
115 |
> |
<td align="left"><b>$value</b></td> |
116 |
|
</tr> |
117 |
+ |
<tr> |
118 |
+ |
<td align="right"><font size="2">Initially raised:</font></td> |
119 |
+ |
<td align="left">$initialAlertTime</td> |
120 |
+ |
</tr> |
121 |
|
</table> |
122 |
|
|
123 |
|
EOT; |
127 |
|
} |
128 |
|
|
129 |
|
function printReports($machine, $small="") { |
130 |
+ |
global $fontsize; |
131 |
+ |
|
132 |
|
# 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 |
< |
if ($small == "true") { |
136 |
> |
if ($small == "on") { |
137 |
|
echo <<<EOT |
138 |
< |
<table border="0" cellpadding="2" cellspacing="0" bgcolor="#ffffff" width="100%"> |
138 |
> |
<table border="0" cellpadding="2" cellspacing="6"> |
139 |
|
<tr> |
140 |
< |
<td bgcolor="#000066"> |
141 |
< |
<font color="white"><b>$machine</b></font> |
140 |
> |
<td colspan="5"> |
141 |
> |
<font size="$fontsize"><b><a href="alerts.php?machine=$machine" style="color: black; text-decoration: none;">$machine</a></b></font> |
142 |
|
</td> |
143 |
|
</tr> |
144 |
|
EOT; |
147 |
|
echo <<<EOT |
148 |
|
<p> </p> |
149 |
|
<table border="0" cellpadding="3" cellspacing="2" bgcolor="#000066" width="100%"> |
150 |
< |
<tr> |
150 |
> |
<tr> |
151 |
|
<td> |
152 |
|
<font color="white"> |
153 |
|
<b> |
154 |
< |
Current alerts for $machine |
154 |
> |
Current alerts for <a href="latest.php?machine=$machine" style="color: white">$machine</a> |
155 |
|
</b> |
156 |
|
<font size="2"> |
157 |
|
<br>Sorted by time, latest first. |
180 |
|
} |
181 |
|
} |
182 |
|
else { |
183 |
< |
echo "There are currently no alerts held about <b>$machine</b>"; |
184 |
< |
printLine(""); |
183 |
> |
if ($small != "on") { |
184 |
> |
echo "There are currently no alerts held about <b>$machine</b>"; |
185 |
> |
printLine(""); |
186 |
> |
} |
187 |
|
} |
188 |
|
|
189 |
< |
if ($small == "true") { |
190 |
< |
echo "</table>"; |
189 |
> |
if ($small == "on") { |
190 |
> |
echo <<<EOT |
191 |
> |
<tr> |
192 |
> |
<td colspan="5"> </td> |
193 |
> |
</tr> |
194 |
> |
</table> |
195 |
> |
EOT; |
196 |
|
} |
197 |
|
else { |
198 |
|
echo <<<EOT |
208 |
|
|
209 |
|
<? include($titleHTML); ?> |
210 |
|
|
211 |
+ |
<? if ($hideform != "on") { ?> |
212 |
+ |
|
213 |
|
<? printLine("Latest alerts for hosts"); ?> |
214 |
|
|
157 |
– |
<? if (!$hideform) { ?> |
158 |
– |
|
215 |
|
<form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> |
216 |
|
<? |
217 |
|
|
239 |
|
|
240 |
|
printLine(""); |
241 |
|
|
242 |
+ |
$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 |
|
if ($machine == "ALL") { |
254 |
|
$machine_array = getdirArray($alertDirectory, 'asort'); |
255 |
|
if ($machine_array != FALSE) { |
257 |
|
printReports($machine, $small); |
258 |
|
} |
259 |
|
} |
260 |
+ |
else { |
261 |
+ |
print "<font size='$fontsize'><b>There are currently no alerts</b></font>"; |
262 |
+ |
} |
263 |
|
} |
264 |
|
else { |
265 |
|
printReports($machine, $small); |
266 |
|
} |
267 |
|
|
268 |
+ |
echo <<<EOT |
269 |
+ |
</td> |
270 |
+ |
</tr> |
271 |
+ |
</table> |
272 |
+ |
EOT; |
273 |
|
} |
274 |
|
else { |
275 |
|
printLine(""); |