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.2
Committed: Thu Mar 15 10:55:03 2001 UTC (23 years, 8 months ago) by pjm2
Branch: MAIN
Changes since 1.1: +16 -2 lines
Log Message:
Put in some basic preg_matching to pull information out of each alert.

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.2 $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     echo "<b>$alertLevel</b>$alert<br>";
36 pjm2 1.1 }
37    
38     ?>
39    
40     <? include($titleHTML); ?>
41    
42     <? printLine("Display alerts about all hosts, or a host"); ?>
43    
44     <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
45     <?
46    
47     $file_array = getdirArray($alertDirectory,'asort');
48     print "<select size=\"1\" name=\"machine\">";
49     if ($machine) { ?>
50     <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
51     <option value="">----------------</option>
52     <? }
53     foreach($file_array as $file_name) {
54     #if (is_dir($file_name)) {
55     print "<option value=\"$file_name\">$file_name</option>";
56     #}
57     }
58     print "</select>";
59    
60     ?>
61     <input type="submit" name="submit" value="Display">
62     </form>
63    
64     <? if ($machine) {
65    
66     # Get a list of all files in the machine's directory.
67     $alertArray = getdirArray("$alertDirectory/$machine", 'rsort');
68    
69 pjm2 1.2 foreach($alertArray as $file_name) {
70 pjm2 1.1 $input = file("$alertDirectory/$machine/$file_name");
71     $input = $input[0];
72     $alerts[] = $input;
73     }
74    
75     foreach ($alerts as $alert) {
76     printAlert($machine, $alert);
77     }
78    
79     }
80    
81     ?>
82    
83     <? printLine(""); ?>
84    
85     <? include($bottomHTML); ?>