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.9 by pjm2, Fri Mar 16 19:55:15 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) {
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 >    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 <    echo <<<EOT
54 <    
55 <    <table border="0" cellspacing="5">
56 <      <tr>
57 <        <td><b>$attributeName</b></td>
58 <        <td>&nbsp;</td>
59 <        <td><font color="$alertColour" size="2"><b>$alertLevel</b></font></td>
60 <        <td>&nbsp;</td>
61 <      </tr>
62 <      <tr>
63 <        <td><font size="2">Threshold:</font></td>
64 <        <td>$thresholdValue</td>
65 <        <td><font size="2">Initially raised:</font></td>
66 <        <td>$initialAlertTime</td>
67 <      </tr>
68 <      <tr>
69 <        <td><font size="2">Alert value:</font></td>
70 <        <td><b>$value</b></td>
71 <        <td><!--Next alert time:--> </td>
62 <        <td><!--$timeTillNextAlert--> </td>
63 <      </tr>
64 <    </table>
65 <    
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 +            
101 + EOT;
102 +        printLine("");
103 +    }
104  
68    printLine("");
69
105   }
106  
107 < function printReports($machine) {
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 <    echo <<<EOT
113 <        <center>
114 <          <font size="4">
115 <            <b>
116 <              Current alerts for $machine
117 <            </b>
118 <          </font>
119 <          <font size="2">
120 <            <br>Sorted by time, latest first.
121 <          </font>
122 <        </center>
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("");
143 >        printLine("");
144 >    }
145    
146      if ($alertArray != FALSE) {
147  
# Line 99 | Line 152 | EOT;
152          }
153        
154          foreach ($alerts as $alert) {
155 <            printAlert($machine, $alert);
155 >            printAlert($machine, $alert, $small);
156          }
157      }
158      else {
159 <        echo "There are currently no alerts held about <b>$machine</b>";
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 112 | Line 179 | EOT;
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 131 | Line 200 | EOT;
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         if ($machine == "ALL") {
214             $machine_array = getdirArray($alertDirectory, 'asort');
215 <           foreach ($machine_array as $machine) {
216 <               printReports($machine);
215 >           if ($machine_array != FALSE) {
216 >               foreach ($machine_array as $machine) {
217 >                   printReports($machine, $small);
218 >               }
219             }
220         }
221         else {
222 <           printReports($machine);
222 >           printReports($machine, $small);
223         }
224        
225     }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines