ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/php/alerts/alerts.php
(Generate patch)

Comparing projects/cms/source/reports/php/alerts/alerts.php (file contents):
Revision 1.1 by pjm2, Thu Mar 15 10:36:50 2001 UTC vs.
Revision 1.4 by pjm2, Thu Mar 15 16:53:59 2001 UTC

# Line 17 | Line 17 | function printLine($title) {
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 <    echo "$alert<br>";
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 alerts about all hosts, or a host"); ?>
96 > <? printLine("Display the latest alerts for a host"); ?>
97  
98   <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
99   <?
# Line 49 | Line 117 | function printAlert($machine, $alert) {
117  
118   <? if ($machine) {
119  
120 <       # Get a list of all files in the machine's directory.
53 <       $alertArray = getdirArray("$alertDirectory/$machine", 'rsort');
54 <      
55 <       foreach($file_array as $file_name) {
56 <           $input = file("$alertDirectory/$machine/$file_name");
57 <           $input = $input[0];
58 <           $alerts[] = $input;
59 <       }
60 <      
61 <       foreach ($alerts as $alert) {
62 <           printAlert($machine, $alert);
63 <       }
120 >       printLine("");
121  
122 +       printReports($machine);
123 +      
124     }
125  
126   ?>
68
69 <? printLine(""); ?>
127  
128   <? include($bottomHTML); ?>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines