# | Line 22 | Line 22 | function getValue($value, $alert) { | |
---|---|---|
22 | return $matches[1]; | |
23 | } | |
24 | ||
25 | < | function printAlert($machine, $alert) { |
25 | > | function printAlert($machine, $alert, $small="") { |
26 | > | |
27 | > | include("alerts_config.inc.php"); |
28 | > | |
29 | $alertLevel = getValue("alertLevel", $alert); | |
30 | $lastAlert = getValue("lastAlert", $alert); | |
31 | $thresholdLevel = getValue("thresholdLevel", $alert); | |
# | Line 32 | Line 35 | function printAlert($machine, $alert) { | |
35 | $attributeName = getValue("attributeName", $alert); | |
36 | $timeTillNextAlert = getValue("timeTillNextAlert", $alert); | |
37 | $initialAlertTime = getValue("initialAlertTime", $alert); | |
38 | < | echo "<b>$alertLevel</b>$alert<br>"; |
38 | > | |
39 | > | $alertColour = $alertLevelColours[$alertLevel]; |
40 | > | $alertLevel = $alertLevelNames[$alertLevel]; |
41 | > | $initialAlertTime = strftime("%x %X", intval($initialAlertTime / 1000)); |
42 | > | |
43 | > | if ($small == "true") { |
44 | > | echo <<<EOT |
45 | > | <tr> |
46 | > | <td width="50"> |
47 | > | |
48 | > | </td> |
49 | > | <td align="left"> |
50 | > | <font size="2" color="$alertColour"><b>$alertLevel</b></font> |
51 | > | </td> |
52 | > | <td align="left"> |
53 | > | <font size="2">$attributeName</font> |
54 | > | </td> |
55 | > | <td> |
56 | > | |
57 | > | </td> |
58 | > | </tr> |
59 | > | EOT; |
60 | > | } |
61 | > | else { |
62 | > | echo <<<EOT |
63 | > | |
64 | > | <table border="0" cellspacing="5"> |
65 | > | <tr> |
66 | > | <td><b>$attributeName</b></td> |
67 | > | <td> </td> |
68 | > | <td><font color="$alertColour" size="2"><b>$alertLevel</b></font></td> |
69 | > | <td> </td> |
70 | > | </tr> |
71 | > | <tr> |
72 | > | <td><font size="2">Threshold:</font></td> |
73 | > | <td>$thresholdValue</td> |
74 | > | <td><font size="2">Initially raised:</font></td> |
75 | > | <td>$initialAlertTime</td> |
76 | > | </tr> |
77 | > | <tr> |
78 | > | <td><font size="2">Alert value:</font></td> |
79 | > | <td><b>$value</b></td> |
80 | > | <td><!--Next alert time:--> </td> |
81 | > | <td><!--$timeTillNextAlert--> </td> |
82 | > | </tr> |
83 | > | </table> |
84 | > | |
85 | > | EOT; |
86 | > | printLine(""); |
87 | > | } |
88 | > | |
89 | } | |
90 | ||
91 | + | function printReports($machine, $small="") { |
92 | + | # Get a list of all files in the machine's directory. |
93 | + | include("alerts_config.inc.php"); |
94 | + | $alertArray = getdirArray("$alertDirectory/$machine", 'rsort'); |
95 | + | |
96 | + | if ($small == "true") { |
97 | + | echo <<<EOT |
98 | + | <table border="0" cellpadding="2" cellspacing="0"> |
99 | + | <tr> |
100 | + | <td colspan="4"> |
101 | + | <b>$machine</b> |
102 | + | </td> |
103 | + | </tr> |
104 | + | EOT; |
105 | + | } |
106 | + | else { |
107 | + | echo <<<EOT |
108 | + | <p> </p> |
109 | + | <table border="0" cellpadding="3" cellspacing="2" bgcolor="#000066" width="100%"> |
110 | + | <tr> |
111 | + | <td> |
112 | + | <font color="white"> |
113 | + | <b> |
114 | + | Current alerts for $machine |
115 | + | </b> |
116 | + | <font size="2"> |
117 | + | <br>Sorted by time, latest first. |
118 | + | </font> |
119 | + | </font> |
120 | + | </td> |
121 | + | </tr> |
122 | + | <tr> |
123 | + | <td bgcolor="white"> |
124 | + | |
125 | + | EOT; |
126 | + | |
127 | + | printLine(""); |
128 | + | } |
129 | + | |
130 | + | if ($alertArray != FALSE) { |
131 | + | |
132 | + | foreach($alertArray as $file_name) { |
133 | + | $input = file("$alertDirectory/$machine/$file_name"); |
134 | + | $input = $input[0]; |
135 | + | $alerts[] = $input; |
136 | + | } |
137 | + | |
138 | + | foreach ($alerts as $alert) { |
139 | + | printAlert($machine, $alert, $small); |
140 | + | } |
141 | + | } |
142 | + | else { |
143 | + | echo "There are currently no alerts held about <b>$machine</b>"; |
144 | + | printLine(""); |
145 | + | } |
146 | + | |
147 | + | if ($small == "true") { |
148 | + | echo "</table>"; |
149 | + | } |
150 | + | else { |
151 | + | echo <<<EOT |
152 | + | </td> |
153 | + | </tr> |
154 | + | </table> |
155 | + | EOT; |
156 | + | } |
157 | + | } |
158 | + | |
159 | + | |
160 | ?> | |
161 | ||
162 | <? include($titleHTML); ?> | |
163 | ||
164 | < | <? printLine("Display alerts about all hosts, or a host"); ?> |
164 | > | <? if (!$hideform) { ?> |
165 | ||
166 | + | <? printLine("Latest alerts for hosts"); ?> |
167 | + | |
168 | <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> | |
169 | <? | |
170 | ||
# | Line 50 | Line 174 | function printAlert($machine, $alert) { | |
174 | <option selected value="<? echo $machine ?>"><? echo $machine ?></option> | |
175 | <option value="">----------------</option> | |
176 | <? } | |
177 | < | foreach($file_array as $file_name) { |
177 | > | foreach ($file_array as $file_name) { |
178 | #if (is_dir($file_name)) { | |
179 | print "<option value=\"$file_name\">$file_name</option>"; | |
180 | #} | |
# | Line 58 | Line 182 | function printAlert($machine, $alert) { | |
182 | print "</select>"; | |
183 | ||
184 | ?> | |
185 | + | <input type="hidden" name="small" value="<?=$small?>"> |
186 | <input type="submit" name="submit" value="Display"> | |
187 | </form> | |
188 | ||
189 | + | <? } ?> |
190 | + | |
191 | <? if ($machine) { | |
192 | ||
193 | < | # Get a list of all files in the machine's directory. |
194 | < | $alertArray = getdirArray("$alertDirectory/$machine", 'rsort'); |
195 | < | |
196 | < | foreach($alertArray as $file_name) { |
197 | < | $input = file("$alertDirectory/$machine/$file_name"); |
198 | < | $input = $input[0]; |
199 | < | $alerts[] = $input; |
193 | > | printLine(""); |
194 | > | |
195 | > | if ($machine == "ALL") { |
196 | > | $machine_array = getdirArray($alertDirectory, 'asort'); |
197 | > | if ($machine_array != FALSE) { |
198 | > | foreach ($machine_array as $machine) { |
199 | > | printReports($machine, $small); |
200 | > | } |
201 | > | } |
202 | } | |
203 | < | |
204 | < | foreach ($alerts as $alert) { |
76 | < | printAlert($machine, $alert); |
203 | > | else { |
204 | > | printReports($machine, $small); |
205 | } | |
206 | < | |
206 | > | |
207 | } | |
208 | + | else { |
209 | + | printLine(""); |
210 | + | } |
211 | ||
212 | ?> | |
82 | – | |
83 | – | <? printLine(""); ?> |
213 | ||
214 | <? include($bottomHTML); ?> |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |