# | 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 | > | |
27 | > | include("alerts_config.inc.php"); |
28 | > | |
29 | > | $alertLevel = getValue("alertLevel", $alert); |
30 | > | $lastAlert = getValue("lastAlert", $alert); |
31 | > | $thresholdLevel = getValue("thresholdLevel", $alert); |
32 | > | $source = getValue("source", $alert); |
33 | > | $thresholdValue = getValue("thresholdValue", $alert); |
34 | > | $value = getValue("value", $alert); |
35 | > | $attributeName = getValue("attributeName", $alert); |
36 | > | $timeTillNextAlert = getValue("timeTillNextAlert", $alert); |
37 | > | $initialAlertTime = getValue("initialAlertTime", $alert); |
38 | > | |
39 | > | $alertColour = $alertLevelColours[$alertLevel]; |
40 | > | $alertLevel = $alertLevelNames[$alertLevel]; |
41 | > | |
42 | > | echo <<<EOT |
43 | > | |
44 | > | <table border="0"> |
45 | > | <tr> |
46 | > | <td><b>$attributeName</b></td> |
47 | > | <td> </td> |
48 | > | <td>Alert level:</td> |
49 | > | <td><font color="$alertColour"><b>$alertLevel</b></font></td> |
50 | > | </tr> |
51 | > | <tr> |
52 | > | <td>Threshold:</td> |
53 | > | <td>$thresholdValue</td> |
54 | > | <td>Initially raised:</td> |
55 | > | <td>$initialAlertTime</td> |
56 | > | </tr> |
57 | > | <tr> |
58 | > | <td>Alert value:</td> |
59 | > | <td><b>$value</b></td> |
60 | > | <td><!--Next alert time:--> </td> |
61 | > | <td><!--$timeTillNextAlert--> </td> |
62 | > | </tr> |
63 | > | </table> |
64 | > | |
65 | > | EOT; |
66 | > | |
67 | > | printLine(""); |
68 | > | |
69 | } | |
70 | ||
71 | + | function printReports($machine) { |
72 | + | # Get a list of all files in the machine's directory. |
73 | + | include("alerts_config.inc.php"); |
74 | + | $alertArray = getdirArray("$alertDirectory/$machine", 'rsort'); |
75 | + | |
76 | + | foreach($alertArray as $file_name) { |
77 | + | $input = file("$alertDirectory/$machine/$file_name"); |
78 | + | $input = $input[0]; |
79 | + | $alerts[] = $input; |
80 | + | } |
81 | + | |
82 | + | foreach ($alerts as $alert) { |
83 | + | printAlert($machine, $alert); |
84 | + | } |
85 | + | } |
86 | + | |
87 | + | |
88 | ?> | |
89 | ||
90 | <? include($titleHTML); ?> | |
91 | ||
92 | < | <? printLine("Display alerts about all hosts, or a host"); ?> |
92 | > | <? printLine("Display the latest alerts for a host"); ?> |
93 | ||
94 | <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>"> | |
95 | <? | |
# | Line 49 | Line 113 | function printAlert($machine, $alert) { | |
113 | ||
114 | <? if ($machine) { | |
115 | ||
116 | < | # 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 | < | } |
116 | > | printLine(""); |
117 | ||
118 | + | printReports($machine); |
119 | + | |
120 | } | |
121 | + | else { |
122 | + | printLine(""); |
123 | + | } |
124 | ||
125 | ?> | |
68 | – | |
69 | – | <? printLine(""); ?> |
126 | ||
127 | <? include($bottomHTML); ?> |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |