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.25
Committed: Wed Mar 21 19:10:33 2001 UTC (23 years, 7 months ago) by pjm2
Branch: MAIN
Changes since 1.24: +11 -1 lines
Log Message:
Added "Upper" and "Lower" comments in threshold levels.  Or, for those
that are neither, "Normal" is shown by the threshold value.

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