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