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.4 by pjm2, Thu Mar 15 16:53:59 2001 UTC vs.
Revision 1.25 by pjm2, Wed Mar 21 19:10:33 2001 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines