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.5 by pjm2, Thu Mar 15 17:14:59 2001 UTC vs.
Revision 1.20 by pjm2, Wed Mar 21 17:32:24 2001 UTC

# Line 22 | Line 22 | function getValue($value, $alert) {
22      return $matches[1];
23   }
24  
25 < function printAlert($machine, $alert) {
25 > function printAlert($machine, $alert, $small="") {
26  
27      include("alerts_config.inc.php");
28  
29 <    $alertLevel = getValue("alertLevel", $alert);
29 >    $alertLevelNum = getValue("alertLevel", $alert);
30      $lastAlert = getValue("lastAlert", $alert);
31      $thresholdLevel = getValue("thresholdLevel", $alert);
32      $source = getValue("source", $alert);
# Line 36 | Line 36 | function printAlert($machine, $alert) {
36      $timeTillNextAlert = getValue("timeTillNextAlert", $alert);
37      $initialAlertTime = getValue("initialAlertTime", $alert);
38  
39 <    $alertColour = $alertLevelColours[$alertLevel];
40 <    $alertLevel = $alertLevelNames[$alertLevel];
39 >    $alertColour = $alertLevelColours[$alertLevelNum];
40 >    $alertLevel = $alertLevelNames[$alertLevelNum];
41 >    $initialAlertTime = strftime("%x %X", intval($initialAlertTime / 1000));
42  
43 <    echo <<<EOT
44 <    
45 <    <table border="0">
46 <      <tr>
47 <        <td><b>$attributeName</b></td>
48 <        <td>&nbsp;</td>
49 <        <td>Alert level:</td>
50 <        <td><font color="$alertColour"><b>$alertLevel</b></font></td>
51 <      </tr>
52 <      <tr>
53 <        <td>Threshold:</td>
54 <        <td>$thresholdValue</td>
55 <        <td>Initially raised:</td>
56 <        <td>$initialAlertTime</td>
57 <      </tr>
58 <      <tr>
59 <        <td>Alert value:</td>
60 <        <td><b>$value</b></td>
61 <        <td><!--Next alert time:--> </td>
61 <        <td><!--$timeTillNextAlert--> </td>
62 <      </tr>
63 <    </table>
64 <    
43 >    if ($small == "true") {
44 >        echo <<<EOT
45 >            <tr>
46 >             <td width="50">
47 >              &nbsp;
48 >             </td>
49 >             <td align="left">
50 >              <img src="level$alertLevelNum.gif" width="41" height="9" border="0" alt="$alertLevel">
51 >             </td>
52 >             <td align="left">
53 >              <font size="3" color="$alertColour"><b>$alertLevel</b></font>
54 >             </td>
55 >             <td align="left">
56 >              <font size="3">$attributeName</font>
57 >             </td>
58 >             <td>
59 >              &nbsp;
60 >             </td>
61 >            </tr>
62   EOT;
63 +    }
64 +    else {
65 +        echo <<<EOT
66 +        
67 +        <table border="0" cellspacing="5">
68 +          <tr>
69 +            <td><b>$attributeName</b></td>
70 +            <td>&nbsp;</td>
71 +            <td><font color="$alertColour" size="2"><b>$alertLevel</b></font></td>
72 +            <td>&nbsp;</td>
73 +          </tr>
74 +          <tr>
75 +            <td><font size="2">Threshold:</font></td>
76 +            <td>$thresholdValue</td>
77 +            <td><font size="2">Initially raised:</font></td>
78 +            <td>$initialAlertTime</td>
79 +          </tr>
80 +          <tr>
81 +            <td><font size="2">Alert value:</font></td>
82 +            <td><b>$value</b></td>
83 +            <td><!--Next alert time:--> </td>
84 +            <td><!--$timeTillNextAlert--> </td>
85 +          </tr>
86 +        </table>
87 +            
88 + EOT;
89 +        printLine("");
90 +    }
91  
67    printLine("");
68
92   }
93  
94 < function printReports($machine) {
95 <   # Get a list of all files in the machine's directory.
96 <   include("alerts_config.inc.php");
97 <   $alertArray = getdirArray("$alertDirectory/$machine", 'rsort');
94 > function printReports($machine, $small="") {
95 >    # Get a list of all files in the machine's directory.
96 >    include("alerts_config.inc.php");
97 >    $alertArray = getdirArray("$alertDirectory/$machine", 'rsort');
98 >  
99 >    if ($small == "true") {
100 >        echo <<<EOT
101 >           <table border="0" cellpadding="2" cellspacing="0">
102 >            <tr>
103 >             <td colspan="5">
104 >              <font size="+1"><b>$machine</b></font>
105 >             </td>
106 >            </tr>
107 > EOT;
108 >    }
109 >    else {
110 >        echo <<<EOT
111 >             <p>&nbsp;</p>
112 >             <table border="0" cellpadding="3" cellspacing="2" bgcolor="#000066" width="100%">
113 >               <tr>
114 >               <td>
115 >                <font color="white">
116 >                 <b>
117 >                  Current alerts for $machine
118 >                 </b>
119 >                 <font size="2">
120 >                  <br>Sorted by time, latest first.
121 >                 </font>
122 >                </font>
123 >               </td>
124 >              </tr>
125 >              <tr>
126 >               <td bgcolor="white">
127 >    
128 > EOT;
129 >
130 >        printLine("");
131 >    }
132 >  
133 >    if ($alertArray != FALSE) {
134 >
135 >        foreach($alertArray as $file_name) {
136 >            $input = file("$alertDirectory/$machine/$file_name");
137 >            $input = $input[0];
138 >            $alerts[] = $input;
139 >        }
140        
141 <   foreach($alertArray as $file_name) {
142 <       $input = file("$alertDirectory/$machine/$file_name");
143 <       $input = $input[0];
144 <       $alerts[] = $input;
145 <   }
146 <      
147 <   foreach ($alerts as $alert) {
148 <       printAlert($machine, $alert);
149 <   }
141 >        foreach ($alerts as $alert) {
142 >            printAlert($machine, $alert, $small);
143 >        }
144 >    }
145 >    else {
146 >        echo "There are currently no alerts held about <b>$machine</b>";
147 >        printLine("");
148 >    }
149 >
150 >    if ($small == "true") {
151 >        echo "</table>";
152 >    }
153 >    else {
154 >        echo <<<EOT
155 >             </td>
156 >            </tr>
157 >           </table>
158 > EOT;
159 >    }
160   }
161  
162  
# Line 89 | Line 164 | function printReports($machine) {
164  
165   <? include($titleHTML); ?>
166  
167 < <? printLine("Display the latest alerts for a host"); ?>
167 > <? if (!$hideform) { ?>
168  
169 + <? printLine("Latest alerts for hosts"); ?>
170 +
171   <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
172   <?
173  
# Line 100 | Line 177 | function printReports($machine) {
177          <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
178          <option value="">----------------</option>
179      <? }
180 <    foreach($file_array as $file_name) {
180 >    foreach ($file_array as $file_name) {
181          #if (is_dir($file_name)) {
182              print "<option value=\"$file_name\">$file_name</option>";
183          #}
# Line 108 | Line 185 | function printReports($machine) {
185      print "</select>";
186  
187   ?>
188 + <input type="hidden" name="small" value="<?=$small?>">
189   <input type="submit" name="submit" value="Display">
190   </form>
191  
192 + <? } ?>
193 +
194   <? if ($machine) {
195  
196         printLine("");
197  
198 <       printReports($machine);
198 >       if ($machine == "ALL") {
199 >           $machine_array = getdirArray($alertDirectory, 'asort');
200 >           if ($machine_array != FALSE) {
201 >               foreach ($machine_array as $machine) {
202 >                   printReports($machine, $small);
203 >               }
204 >           }
205 >       }
206 >       else {
207 >           printReports($machine, $small);
208 >       }
209        
210     }
211     else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines