# | 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 | ||
# | Line 38 | Line 38 | function printAlert($machine, $alert) { | |
38 | ||
39 | $alertColour = $alertLevelColours[$alertLevel]; | |
40 | $alertLevel = $alertLevelNames[$alertLevel]; | |
41 | + | $initialAlertTime = strftime("%x %X", intval($initialAlertTime / 1000)); |
42 | ||
43 | < | echo <<<EOT |
44 | < | |
45 | < | <table border="0"> |
46 | < | <tr> |
47 | < | <td><b>$attributeName</b></td> |
48 | < | <td> </td> |
49 | < | <td>Alert level:</td> |
50 | < | <td><font color="$alertColour"><b>$alertLevel</b></font></td> |
51 | < | </tr> |
52 | < | <tr> |
53 | < | <td>Threshold:</td> |
54 | < | <td>$thresholdValue</td> |
55 | < | <td>Initially raised:</td> |
56 | < | <td>$initialAlertTime</td> |
57 | < | </tr> |
58 | < | <tr> |
58 | < | <td>Alert value:</td> |
59 | < | <td><b>$value</b></td> |
60 | < | <td><!--Next alert time:--> </td> |
61 | < | <td><!--$timeTillNextAlert--> </td> |
62 | < | </tr> |
63 | < | </table> |
64 | < | |
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 | ||
67 | – | printLine(""); |
68 | – | |
89 | } | |
90 | ||
91 | < | function printReports($machine) { |
92 | < | # Get a list of all files in the machine's directory. |
93 | < | include("alerts_config.inc.php"); |
94 | < | $alertArray = getdirArray("$alertDirectory/$machine", 'rsort'); |
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($alertArray as $file_name) { |
139 | < | $input = file("$alertDirectory/$machine/$file_name"); |
140 | < | $input = $input[0]; |
141 | < | $alerts[] = $input; |
142 | < | } |
143 | < | |
144 | < | foreach ($alerts as $alert) { |
145 | < | printAlert($machine, $alert); |
146 | < | } |
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 | ||
# | Line 89 | Line 161 | function printReports($machine) { | |
161 | ||
162 | <? include($titleHTML); ?> | |
163 | ||
164 | < | <? printLine("Display the latest alerts for a host"); ?> |
164 | > | <? if (!$hideform) { ?> |
165 | ||
166 | + | <? printLine("Latest alerts for hosts"); ?> |
167 | + | |
168 | <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> | |
169 | <? | |
170 | ||
# | Line 100 | Line 174 | function printReports($machine) { | |
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 108 | Line 182 | function printReports($machine) { | |
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 | printLine(""); | |
194 | ||
195 | < | printReports($machine); |
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 | > | else { |
204 | > | printReports($machine, $small); |
205 | > | } |
206 | ||
207 | } | |
208 | else { |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |