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> |
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 |
|
|
68 |
– |
printLine(""); |
69 |
– |
|
80 |
|
} |
81 |
|
|
82 |
< |
function printReports($machine) { |
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 |
< |
echo <<<EOT |
88 |
< |
<table border="0" cellpadding="3" cellspacing="2" bgcolor="#000066" width="100%"> |
89 |
< |
<tr> |
90 |
< |
<td> |
91 |
< |
<font color="white"> |
92 |
< |
<b> |
93 |
< |
Current alerts for $machine |
94 |
< |
</b> |
95 |
< |
<font size="2"> |
96 |
< |
<br>Sorted by time, latest first. |
97 |
< |
</font> |
98 |
< |
</font> |
99 |
< |
</td> |
100 |
< |
</tr> |
101 |
< |
<tr> |
102 |
< |
<td bgcolor="white"> |
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(""); |
118 |
> |
printLine(""); |
119 |
> |
} |
120 |
|
|
121 |
|
if ($alertArray != FALSE) { |
122 |
|
|
127 |
|
} |
128 |
|
|
129 |
|
foreach ($alerts as $alert) { |
130 |
< |
printAlert($machine, $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 |
< |
echo <<<EOT |
139 |
< |
</td> |
140 |
< |
</tr> |
141 |
< |
</table> |
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 |
|
|
152 |
|
|
153 |
|
<? include($titleHTML); ?> |
154 |
|
|
155 |
< |
<? printLine("Display the latest alerts for a host"); ?> |
155 |
> |
<? printLine("Latest alerts for hosts"); ?> |
156 |
|
|
157 |
+ |
<? if (!$hideform) { ?> |
158 |
+ |
|
159 |
|
<form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> |
160 |
|
<? |
161 |
|
|
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 |
|
printLine(""); |
185 |
|
|
186 |
|
if ($machine == "ALL") { |
187 |
|
$machine_array = getdirArray($alertDirectory, 'asort'); |
188 |
< |
foreach ($machine_array as $machine) { |
189 |
< |
printReports($machine); |
188 |
> |
if ($machine_array != FALSE) { |
189 |
> |
foreach ($machine_array as $machine) { |
190 |
> |
printReports($machine, $small); |
191 |
> |
} |
192 |
|
} |
193 |
|
} |
194 |
|
else { |
195 |
< |
printReports($machine); |
195 |
> |
printReports($machine, $small); |
196 |
|
} |
197 |
|
|
198 |
|
} |