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.26
Committed: Sat Mar 17 21:57:16 2001 UTC (23 years, 7 months ago) by pjm2
Branch: MAIN
Changes since 1.25: +5 -1 lines
Log Message:
Bar displays can now be called with the optional paramter of $arrange.  If
this is set to "swap", then the 'difference' is displayed.  I.e. if we
have the data available for free memory and total memory, then it will be
possible to display a bar of used memory.

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