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.4
Committed: Thu Mar 15 16:53:59 2001 UTC (23 years, 8 months ago) by pjm2
Branch: MAIN
Changes since 1.3: +56 -15 lines
Log Message:
Got more or less sensible things being read out for each alert now.

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