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.31
Committed: Thu Mar 22 19:02:12 2001 UTC (23 years, 8 months ago) by pjm2
Branch: MAIN
Changes since 1.30: +6 -1 lines
Log Message:
It seemed like a good idea to put a little space between each machine.

File Contents

# User Rev Content
1 pjm2 1.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 pjm2 1.2 function getValue($value, $alert) {
21     preg_match("/$value=([^\,\}]*)[\,\}]/", $alert, $matches);
22     return $matches[1];
23     }
24    
25 pjm2 1.14 function printAlert($machine, $alert, $small="") {
26 pjm2 1.5
27 pjm2 1.26 global $fontsize;
28    
29 pjm2 1.5 include("alerts_config.inc.php");
30    
31 pjm2 1.20 $alertLevelNum = getValue("alertLevel", $alert);
32 pjm2 1.2 $lastAlert = getValue("lastAlert", $alert);
33     $thresholdLevel = getValue("thresholdLevel", $alert);
34     $source = getValue("source", $alert);
35     $thresholdValue = getValue("thresholdValue", $alert);
36     $value = getValue("value", $alert);
37     $attributeName = getValue("attributeName", $alert);
38     $timeTillNextAlert = getValue("timeTillNextAlert", $alert);
39     $initialAlertTime = getValue("initialAlertTime", $alert);
40 pjm2 1.4
41 pjm2 1.25 if ($thresholdLevel == "1") {
42     $thresholdLevel = "Lower";
43     }
44     else if ($thresholdLevel == "2") {
45     $thresholdLevel = "Upper";
46     }
47     else {
48     $thresholdLevel = "Normal";
49     }
50    
51 pjm2 1.20 $alertColour = $alertLevelColours[$alertLevelNum];
52     $alertLevel = $alertLevelNames[$alertLevelNum];
53 pjm2 1.6 $initialAlertTime = strftime("%x %X", intval($initialAlertTime / 1000));
54 pjm2 1.5
55 pjm2 1.27 if ($small == "on") {
56 pjm2 1.16 echo <<<EOT
57     <tr>
58 pjm2 1.17 <td width="50">
59     &nbsp;
60     </td>
61 pjm2 1.30 <td>
62 pjm2 1.20 <img src="level$alertLevelNum.gif" width="41" height="9" border="0" alt="$alertLevel">
63     </td>
64 pjm2 1.30 <td>
65 pjm2 1.26 <font size="$fontsize" color="$alertColour"><b>$alertLevel</b></font>
66 pjm2 1.17 </td>
67 pjm2 1.30 <td>
68 pjm2 1.26 <font size="$fontsize">$attributeName</font>
69 pjm2 1.17 </td>
70 pjm2 1.16 <td>
71 pjm2 1.17 &nbsp;
72 pjm2 1.16 </td>
73     </tr>
74     EOT;
75 pjm2 1.13 }
76     else {
77     echo <<<EOT
78    
79 pjm2 1.22 <table border="0" cellspacing="5" width="100%">
80 pjm2 1.13 <tr>
81 pjm2 1.23 <td align="left" width="40%">
82 pjm2 1.21 <img src="level$alertLevelNum.gif" width="41" height="9" border="0" alt="$alertLevel">
83     <font color="$alertColour" size="2"><b>$alertLevel</b></font>
84     </td>
85 pjm2 1.23 <td align="right" width="60%">
86 pjm2 1.22 <b>$attributeName</b>
87     </td>
88     </tr>
89     <tr>
90     <td align="right"><font size="2">Threshold:</font></td>
91 pjm2 1.25 <td align="left">$thresholdValue ($thresholdLevel)</td>
92 pjm2 1.13 </tr>
93     <tr>
94 pjm2 1.22 <td align="right"><font size="2">Alert value:</font></td>
95     <td align="left"><b>$value</b></td>
96 pjm2 1.13 </tr>
97     <tr>
98 pjm2 1.22 <td align="right"><font size="2">Initially raised:</font></td>
99     <td align="left">$initialAlertTime</td>
100 pjm2 1.13 </tr>
101     </table>
102    
103 pjm2 1.4 EOT;
104 pjm2 1.13 printLine("");
105     }
106 pjm2 1.4
107 pjm2 1.1 }
108    
109 pjm2 1.14 function printReports($machine, $small="") {
110 pjm2 1.26 global $fontsize;
111    
112 pjm2 1.7 # Get a list of all files in the machine's directory.
113     include("alerts_config.inc.php");
114     $alertArray = getdirArray("$alertDirectory/$machine", 'rsort');
115    
116 pjm2 1.27 if ($small == "on") {
117 pjm2 1.15 echo <<<EOT
118 pjm2 1.30 <table border="0" cellpadding="2" cellspacing="6">
119 pjm2 1.15 <tr>
120 pjm2 1.20 <td colspan="5">
121 pjm2 1.26 <font size="$fontsize"><b><a href="alerts.php?machine=$machine" style="color: black; text-decoration: none;">$machine</a></b></font>
122 pjm2 1.15 </td>
123     </tr>
124     EOT;
125 pjm2 1.14 }
126     else {
127     echo <<<EOT
128     <p>&nbsp;</p>
129     <table border="0" cellpadding="3" cellspacing="2" bgcolor="#000066" width="100%">
130 pjm2 1.30 <tr>
131 pjm2 1.14 <td>
132     <font color="white">
133     <b>
134 pjm2 1.24 Current alerts for <a href="latest.php?machine=$machine" style="color: white">$machine</a>
135 pjm2 1.14 </b>
136     <font size="2">
137     <br>Sorted by time, latest first.
138     </font>
139     </font>
140     </td>
141     </tr>
142     <tr>
143     <td bgcolor="white">
144 pjm2 1.7
145     EOT;
146    
147 pjm2 1.14 printLine("");
148     }
149 pjm2 1.7
150 pjm2 1.8 if ($alertArray != FALSE) {
151    
152     foreach($alertArray as $file_name) {
153     $input = file("$alertDirectory/$machine/$file_name");
154     $input = $input[0];
155     $alerts[] = $input;
156     }
157    
158     foreach ($alerts as $alert) {
159 pjm2 1.14 printAlert($machine, $alert, $small);
160 pjm2 1.8 }
161 pjm2 1.7 }
162 pjm2 1.8 else {
163 pjm2 1.27 if ($small != "on") {
164 pjm2 1.21 echo "There are currently no alerts held about <b>$machine</b>";
165     printLine("");
166     }
167 pjm2 1.7 }
168 pjm2 1.10
169 pjm2 1.27 if ($small == "on") {
170 pjm2 1.31 echo <<<EOT
171     <tr>
172     <td colspan="5">&nbsp;</td>
173     </tr>
174     </table>
175     EOT;
176 pjm2 1.14 }
177     else {
178     echo <<<EOT
179     </td>
180     </tr>
181     </table>
182 pjm2 1.10 EOT;
183 pjm2 1.14 }
184 pjm2 1.4 }
185    
186    
187 pjm2 1.1 ?>
188    
189     <? include($titleHTML); ?>
190    
191 pjm2 1.28 <? if ($hideform != "on") { ?>
192 pjm2 1.18
193 pjm2 1.16 <? printLine("Latest alerts for hosts"); ?>
194 pjm2 1.1
195     <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
196     <?
197    
198     $file_array = getdirArray($alertDirectory,'asort');
199     print "<select size=\"1\" name=\"machine\">";
200     if ($machine) { ?>
201     <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
202     <option value="">----------------</option>
203     <? }
204 pjm2 1.9 foreach ($file_array as $file_name) {
205 pjm2 1.1 #if (is_dir($file_name)) {
206     print "<option value=\"$file_name\">$file_name</option>";
207     #}
208     }
209     print "</select>";
210    
211     ?>
212 pjm2 1.14 <input type="hidden" name="small" value="<?=$small?>">
213 pjm2 1.1 <input type="submit" name="submit" value="Display">
214     </form>
215 pjm2 1.16
216     <? } ?>
217 pjm2 1.1
218 pjm2 1.30 <table border="0" align="center">
219     <tr>
220     <td>
221    
222 pjm2 1.1 <? if ($machine) {
223 pjm2 1.3
224     printLine("");
225 pjm2 1.1
226 pjm2 1.9 if ($machine == "ALL") {
227     $machine_array = getdirArray($alertDirectory, 'asort');
228 pjm2 1.12 if ($machine_array != FALSE) {
229     foreach ($machine_array as $machine) {
230 pjm2 1.14 printReports($machine, $small);
231 pjm2 1.12 }
232 pjm2 1.9 }
233     }
234     else {
235 pjm2 1.14 printReports($machine, $small);
236 pjm2 1.9 }
237 pjm2 1.1
238 pjm2 1.5 }
239     else {
240     printLine("");
241 pjm2 1.1 }
242    
243     ?>
244 pjm2 1.30
245     </td>
246     </tr>
247     </table>
248 pjm2 1.1
249     <? include($bottomHTML); ?>