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 |
|
|
40 |
|
$alertLevel = $alertLevelNames[$alertLevel]; |
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 |
> |
<font size="3" color="$alertColour"><b>$alertLevel</b></font> |
51 |
> |
</td> |
52 |
> |
<td align="left"> |
53 |
> |
<font size="3">$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 |
|
|
68 |
– |
printLine(""); |
69 |
– |
|
89 |
|
} |
90 |
|
|
91 |
< |
function printReports($machine) { |
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 |
< |
echo <<<EOT |
97 |
< |
<center> |
98 |
< |
<font size="4"> |
99 |
< |
<b> |
100 |
< |
Current alerts for $machine |
101 |
< |
</b> |
102 |
< |
</font> |
103 |
< |
<font size="2"> |
104 |
< |
<br>Sorted by time, latest first. |
105 |
< |
</font> |
106 |
< |
</center> |
96 |
> |
if ($small == "true") { |
97 |
> |
echo <<<EOT |
98 |
> |
<table border="0" cellpadding="2" cellspacing="0"> |
99 |
> |
<tr> |
100 |
> |
<td colspan="4"> |
101 |
> |
<font size="+1"><b>$machine</b></font> |
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(""); |
92 |
< |
|
93 |
< |
foreach($alertArray as $file_name) { |
94 |
< |
$input = file("$alertDirectory/$machine/$file_name"); |
95 |
< |
$input = $input[0]; |
96 |
< |
$alerts[] = $input; |
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); |
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 |
|
|
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 |
|
|
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 |
|
#} |
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 { |