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.5
Committed: Thu Mar 15 17:14:59 2001 UTC (23 years, 8 months ago) by pjm2
Branch: MAIN
Changes since 1.4: +19 -20 lines
Log Message:
Added alert level colours and altered the layout so it makes a bit more
sense for service checks.

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.1 function printAlert($machine, $alert) {
26 pjm2 1.5
27     include("alerts_config.inc.php");
28    
29 pjm2 1.2 $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 pjm2 1.4
39 pjm2 1.5 $alertColour = $alertLevelColours[$alertLevel];
40     $alertLevel = $alertLevelNames[$alertLevel];
41    
42 pjm2 1.4 echo <<<EOT
43    
44 pjm2 1.5 <table border="0">
45 pjm2 1.4 <tr>
46     <td><b>$attributeName</b></td>
47 pjm2 1.5 <td>&nbsp;</td>
48 pjm2 1.4 <td>Alert level:</td>
49 pjm2 1.5 <td><font color="$alertColour"><b>$alertLevel</b></font></td>
50 pjm2 1.4 </tr>
51     <tr>
52 pjm2 1.5 <td>Threshold:</td>
53     <td>$thresholdValue</td>
54     <td>Initially raised:</td>
55 pjm2 1.4 <td>$initialAlertTime</td>
56     </tr>
57     <tr>
58 pjm2 1.5 <td>Alert value:</td>
59     <td><b>$value</b></td>
60     <td><!--Next alert time:--> </td>
61     <td><!--$timeTillNextAlert--> </td>
62 pjm2 1.4 </tr>
63     </table>
64    
65     EOT;
66    
67     printLine("");
68    
69 pjm2 1.1 }
70    
71 pjm2 1.4 function printReports($machine) {
72     # Get a list of all files in the machine's directory.
73     include("alerts_config.inc.php");
74     $alertArray = getdirArray("$alertDirectory/$machine", 'rsort');
75    
76     foreach($alertArray as $file_name) {
77     $input = file("$alertDirectory/$machine/$file_name");
78     $input = $input[0];
79     $alerts[] = $input;
80     }
81    
82     foreach ($alerts as $alert) {
83     printAlert($machine, $alert);
84     }
85     }
86    
87    
88 pjm2 1.1 ?>
89    
90     <? include($titleHTML); ?>
91    
92 pjm2 1.3 <? printLine("Display the latest alerts for a host"); ?>
93 pjm2 1.1
94     <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
95     <?
96    
97     $file_array = getdirArray($alertDirectory,'asort');
98     print "<select size=\"1\" name=\"machine\">";
99     if ($machine) { ?>
100     <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
101     <option value="">----------------</option>
102     <? }
103     foreach($file_array as $file_name) {
104     #if (is_dir($file_name)) {
105     print "<option value=\"$file_name\">$file_name</option>";
106     #}
107     }
108     print "</select>";
109    
110     ?>
111     <input type="submit" name="submit" value="Display">
112     </form>
113    
114     <? if ($machine) {
115 pjm2 1.3
116     printLine("");
117 pjm2 1.1
118 pjm2 1.4 printReports($machine);
119 pjm2 1.1
120 pjm2 1.5 }
121     else {
122     printLine("");
123 pjm2 1.1 }
124    
125     ?>
126    
127     <? include($bottomHTML); ?>