ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/php/latest/latest.php
Revision: 1.22
Committed: Tue Mar 13 20:26:35 2001 UTC (23 years, 7 months ago) by pjm2
Branch: MAIN
Changes since 1.21: +7 -2 lines
Log Message:
Minor changes

File Contents

# User Rev Content
1 pjm2 1.1 <?php
2    
3     # Navigation for the i-scream reports.
4     # pjm2@ukc.ac.uk
5     #
6     # CONFIGURABLE CONSTANTS: -
7    
8     include("latest_config.inc.php");
9    
10     #
11     # END CONFIGURATION
12    
13 pjm2 1.18 include("iutils.inc.php");
14 pjm2 1.1
15 pjm2 1.9 function printLine($title) {
16 pjm2 1.19 echo "<hr style=\"color:#9999ff;\">";
17 pjm2 1.9 echo "<b>$title</b>";
18 pjm2 1.6 }
19    
20 pjm2 1.1
21     function showStat($title, $value, $input) {
22 pjm2 1.7 preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches);
23 pjm2 1.1 $value = $matches[1];
24     if (empty($value)) {
25 pjm2 1.8 $value = "<i><font color=\"#999999\">not sent</font></i>";
26 pjm2 1.1 }
27     ?>
28     <table border="0" width="100%">
29     <tr>
30 pjm2 1.12 <td width="50%" align="right" valign="top"><b><?=$title?></b></td>
31     <td width="50%" align="left" valign="top"><?=$value?></td>
32 pjm2 1.1 </tr>
33     </table>
34     <?
35     }
36    
37    
38 pjm2 1.20 function linkToHistory($report) {
39     global $machine;
40     $yesterday = date("Y-m-d", time() - 86400);
41     echo <<<EOT
42 pjm2 1.22 <a href="browser.php?machine_name=$machine&report=$report&day=$yesterday&submit=Show">
43     <img src="minichart.gif" width="20" height="20" border="0">
44     </a>
45     <font size="2">View yesterday's 24-hour chart</font>
46 pjm2 1.20 EOT;
47     }
48    
49    
50 pjm2 1.1 # show a bar-represented value.
51 pjm2 1.13 function showBar($title, $value, $max, $units, $input) {
52 pjm2 1.1
53     include("latest_config.inc.php");
54    
55 pjm2 1.22 $report = $value;
56    
57 pjm2 1.1 preg_match("/$value=([^\,]*)\,/", $input, $matches);
58     $value = $matches[1];
59     if (!is_int($max)) {
60     preg_match("/$max=([^\,]*)\,/", $input, $matches);
61     $max = $matches[1];
62     }
63     if (empty($value) || empty($max)) {
64     return;
65     }
66    
67     $width = intval($max_width * $value / $max);
68    
69     ?>
70 pjm2 1.10 <table border="0" cellpadding="0" cellspacing="0" align="center">
71 pjm2 1.1 <tr>
72 pjm2 1.14 <td colspan="2"><b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td>
73 pjm2 1.1 </tr>
74     <tr>
75     <td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td>
76     </tr>
77     <tr>
78     <td colspan="2"><img src="<?=$scaleImage?>" border="0" height="11" width="<?=$max_width?>"></td>
79     </tr>
80     <tr>
81 pjm2 1.13 <td align="left">0<?=$units?></td>
82     <td align="right"><?=$max?><?=$units?></td>
83 pjm2 1.21 </tr>
84     <tr>
85 pjm2 1.22 <td colspan="2" align="center"><? linkToHistory($report); ?></td>
86 pjm2 1.1 </tr>
87 pjm2 1.15 <tr>
88     <td colspan="2">&nbsp;</td>
89     </tr>
90 pjm2 1.1 </table>
91     <?
92     }
93    
94    
95     ?>
96    
97     <? include($titleHTML); ?>
98    
99 pjm2 1.12 <? printLine("Display the latest information received from a host"); ?>
100 pjm2 1.1
101     <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
102     <?
103    
104 pjm2 1.5 $file_array = getdirArray($latestDirectory,'asort');
105 pjm2 1.1 print "<select size=\"1\" name=\"machine\">";
106     if ($machine) { ?>
107     <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
108     <option value="">----------------</option>
109     <? }
110     foreach($file_array as $file_name) {
111 pjm2 1.3 #if (is_dir($file_name)) {
112 pjm2 1.1 print "<option value=\"$file_name\">$file_name</option>";
113 pjm2 1.3 #}
114 pjm2 1.1 }
115     print "</select>";
116    
117     ?>
118     <input type="submit" name="submit" value="Display">
119     </form>
120    
121     <? if ($machine) {
122    
123 pjm2 1.12 $last_modified = filemtime("$latestDirectory/$machine/$latestData");
124     clearstatcache();
125     $data_age = time() - $last_modified;
126    
127 pjm2 1.17 $last_modified = date("l jS F - g:ia", $last_modified);
128 pjm2 1.12
129     if ($data_age > $warning_age) {
130     $warning = <<<EOT
131     <br>
132     <font color="red"><b>
133     Warning:
134     </b></font>
135     This realtime report is too old to be considered recent
136     EOT;
137     }
138    
139     echo <<<EOT
140 pjm2 1.16 <table border="0" bgcolor="#000066" cellpadding="3" cellspacing="1">
141 pjm2 1.12 <tr>
142     <td bgcolor="#000066">
143     &nbsp;
144     </td>
145     <td bgcolor="#ffffcc">
146     <font face="arial,sans-serif" size="2">
147     <b>Recipt date:</b> $last_modified
148     $warning
149     </font>
150     </td>
151     </tr>
152     </table>
153     EOT;
154    
155 pjm2 1.1 # Read the file.
156     #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,";
157 pjm2 1.2 $input = file("$latestDirectory/$machine/$latestData");
158 pjm2 1.1 # All we need is the first line if there is more than one line.
159     $input = $input[0];
160    
161     if (empty($input)) {
162     echo "<br><br>There was an error reading from the latest packet received. Please notify your i-scream server administrator.";
163     }
164     else {
165     # Display the data specified in the display include.
166     include("latest_display.inc.php");
167     }
168 pjm2 1.9 }
169 pjm2 1.12
170 pjm2 1.1 ?>
171    
172 pjm2 1.16 <? printLine(""); ?>
173 pjm2 1.1
174     <? include($bottomHTML); ?>