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