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