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, 2 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

# 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) {
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
42 echo <<<EOT
43
44 <table border="0">
45 <tr>
46 <td><b>$attributeName</b></td>
47 <td>&nbsp;</td>
48 <td>Alert level:</td>
49 <td><font color="$alertColour"><b>$alertLevel</b></font></td>
50 </tr>
51 <tr>
52 <td>Threshold:</td>
53 <td>$thresholdValue</td>
54 <td>Initially raised:</td>
55 <td>$initialAlertTime</td>
56 </tr>
57 <tr>
58 <td>Alert value:</td>
59 <td><b>$value</b></td>
60 <td><!--Next alert time:--> </td>
61 <td><!--$timeTillNextAlert--> </td>
62 </tr>
63 </table>
64
65 EOT;
66
67 printLine("");
68
69 }
70
71 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 ?>
89
90 <? include($titleHTML); ?>
91
92 <? printLine("Display the latest alerts for a host"); ?>
93
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
116 printLine("");
117
118 printReports($machine);
119
120 }
121 else {
122 printLine("");
123 }
124
125 ?>
126
127 <? include($bottomHTML); ?>