ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/php/alerts/alerts.php
Revision: 1.17
Committed: Wed Mar 21 12:29:44 2001 UTC (23 years, 8 months ago) by pjm2
Branch: MAIN
Changes since 1.16: +13 -4 lines
Log Message:
Sorted out the table layout and indenting issues.

File Contents

# Content
1 <?php
2
3 # Navigation for the i-scream alerts.
4 # pjm2@ukc.ac.uk
5 #
6 # CONFIGURABLE CONSTANTS: -
7
8 include("alerts_config.inc.php");
9
10 #
11 # END CONFIGURATION
12
13 include("iutils.inc.php");
14
15 function printLine($title) {
16 echo "<hr style=\"color:#9999ff;\">";
17 echo "<b>$title</b>";
18 }
19
20 function getValue($value, $alert) {
21 preg_match("/$value=([^\,\}]*)[\,\}]/", $alert, $matches);
22 return $matches[1];
23 }
24
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);
32 $source = getValue("source", $alert);
33 $thresholdValue = getValue("thresholdValue", $alert);
34 $value = getValue("value", $alert);
35 $attributeName = getValue("attributeName", $alert);
36 $timeTillNextAlert = getValue("timeTillNextAlert", $alert);
37 $initialAlertTime = getValue("initialAlertTime", $alert);
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 width="50">
47 &nbsp;
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 &nbsp;
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>&nbsp;</td>
68 <td><font color="$alertColour" size="2"><b>$alertLevel</b></font></td>
69 <td>&nbsp;</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
89 }
90
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>&nbsp;</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 ($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
160 ?>
161
162 <? include($titleHTML); ?>
163
164 <? printLine("Latest alerts for hosts"); ?>
165
166 <? if (!$hideform) { ?>
167
168 <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
169 <?
170
171 $file_array = getdirArray($alertDirectory,'asort');
172 print "<select size=\"1\" name=\"machine\">";
173 if ($machine) { ?>
174 <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
175 <option value="">----------------</option>
176 <? }
177 foreach ($file_array as $file_name) {
178 #if (is_dir($file_name)) {
179 print "<option value=\"$file_name\">$file_name</option>";
180 #}
181 }
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 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 {
209 printLine("");
210 }
211
212 ?>
213
214 <? include($bottomHTML); ?>