1 |
|
<?php |
2 |
|
|
3 |
– |
# Navigation for the i-scream reports. |
4 |
– |
# pjm2@ukc.ac.uk |
3 |
|
# |
4 |
< |
# CONFIGURABLE CONSTANTS |
4 |
> |
# i-scream central monitoring system |
5 |
> |
# http://www.i-scream.org |
6 |
> |
# Copyright (C) 2000-2002 i-scream |
7 |
> |
# |
8 |
> |
# This program is free software; you can redistribute it and/or |
9 |
> |
# modify it under the terms of the GNU General Public License |
10 |
> |
# as published by the Free Software Foundation; either version 2 |
11 |
> |
# of the License, or (at your option) any later version. |
12 |
> |
# |
13 |
> |
# This program is distributed in the hope that it will be useful, |
14 |
> |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
> |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
> |
# GNU General Public License for more details. |
17 |
> |
# |
18 |
> |
# You should have received a copy of the GNU General Public License |
19 |
> |
# along with this program; if not, write to the Free Software |
20 |
> |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
|
# |
22 |
|
|
23 |
< |
# The report directory, and the number of days to display. |
10 |
< |
$reportDirectory = "/home/cut/pjm2/webpages/reports"; |
11 |
< |
$maxDaysShown = 7; |
23 |
> |
# CONFIGURABLE CONSTANTS: - |
24 |
|
|
25 |
< |
# Page appearance. |
14 |
< |
$scaleImage = "24hour.gif"; |
15 |
< |
$lineColor = "#9999ff"; |
25 |
> |
include("browser_config.inc.php"); |
26 |
|
|
17 |
– |
# Files to include |
18 |
– |
$titleHTML = "title.inc"; |
19 |
– |
$bottomHTML = "bottom.inc"; |
20 |
– |
$machineNameHTML = "machine_name.inc"; |
21 |
– |
$reportHTML = "report.inc"; |
22 |
– |
|
23 |
– |
# What are the names of the report files? |
24 |
– |
$reportLimitsFile = "i-maxmin.txt"; |
25 |
– |
$reportChartFile = "i-chart.gif"; |
26 |
– |
$reportChartDataFile = "i-data.txt"; |
27 |
– |
|
28 |
– |
# Submission details. |
29 |
– |
$formMethod = "GET"; |
30 |
– |
$thisPage = "browser.php"; |
31 |
– |
|
32 |
– |
# Leave this alone unless you know what you're doing ;) |
33 |
– |
$minFileSize = 33; |
34 |
– |
|
27 |
|
# |
28 |
|
# END CONFIGURATION |
29 |
|
|
32 |
|
|
33 |
|
|
34 |
|
# Used to return whether or not a report data file is empty. |
35 |
< |
function isReportEmpty($filename) { |
36 |
< |
if (filesize($filename) < minFileSize) { |
35 |
> |
function isReportEmpty($filename, $minFileSize) { |
36 |
> |
if (filesize($filename) < $minFileSize) { |
37 |
|
return TRUE; |
38 |
|
} |
39 |
|
return FALSE; |
40 |
|
} |
41 |
|
|
42 |
|
|
43 |
< |
# return an array of subdirectories in the current directory. |
52 |
< |
function getdirArray($dir='./',$sort='asort') { |
53 |
< |
global $dir_file_count; |
54 |
< |
if ( is_dir($dir) ) { |
55 |
< |
$fd = @opendir($dir); |
56 |
< |
while ( ($part = @readdir($fd)) == TRUE ) { |
57 |
< |
clearstatcache(); |
58 |
< |
if ($part != "." && $part != "..") { |
59 |
< |
if (preg_match("/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/", $part)) { |
60 |
< |
$dir_array[] = $part; |
61 |
< |
} |
62 |
< |
} |
63 |
< |
} |
64 |
< |
if($fd == TRUE) { |
65 |
< |
closedir($fd); |
66 |
< |
} |
67 |
< |
if (is_array($dir_array)) { |
68 |
< |
$sort($dir_array); |
69 |
< |
$dir_file_count = count($dir_array); |
70 |
< |
Return $dir_array; |
71 |
< |
} else { |
72 |
< |
Return FALSE; |
73 |
< |
} |
74 |
< |
} else { |
75 |
< |
Return FALSE; |
76 |
< |
} |
77 |
< |
} |
43 |
> |
include("iutils.inc.php"); |
44 |
|
|
45 |
|
?> |
46 |
|
|
54 |
|
|
55 |
|
$file_array = getdirArray($reportDirectory,'rsort'); |
56 |
|
print "<select size=\"1\" name=\"day\">"; |
57 |
+ |
if ($day) { ?> |
58 |
+ |
<option selected value="<? echo $day ?>"><? echo $day ?></option> |
59 |
+ |
<option value="">----------------</option> |
60 |
+ |
<? } |
61 |
|
foreach($file_array as $file_name) { |
62 |
< |
if (is_dir($file_name)) { |
62 |
> |
#if (is_dir($file_name)) { |
63 |
> |
if (preg_match("/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/", $file_name)) { |
64 |
|
$i++; |
65 |
|
print "<option value=\"$file_name\">$file_name</option>"; |
66 |
|
} |
88 |
|
<? } else { ?> |
89 |
|
<option selected value="">[select machine]</option> |
90 |
|
<? } ?> |
91 |
< |
<? include("$day/$machineNameHTML"); ?> |
91 |
> |
<? include("$reportDirectory/$day/$machineNameHTML"); ?> |
92 |
|
</select> |
93 |
|
|
94 |
|
<select size="1" name="report"> |
98 |
|
<? } else { ?> |
99 |
|
<option selected value="">[select report]</option> |
100 |
|
<? } ?> |
101 |
< |
<? include("$day/$reportHTML"); ?> |
101 |
> |
<? include("$reportDirectory/$day/$reportHTML"); ?> |
102 |
|
</select> |
103 |
|
|
104 |
|
<input type="hidden" name="day" value="<? echo $day ?>"> |
115 |
|
<? |
116 |
|
if ($submit == "Show" && $machine_name && $report) { |
117 |
|
|
118 |
< |
include("$day/$machine_name/$report/$reportLimitsFile"); |
119 |
< |
|
149 |
< |
$url = escapeshellcmd("$day/$machine_name/$report/$reportChartFile"); |
150 |
< |
if (isReportEmpty("$day/$machine_name/$report/$reportChartDataFile")) { |
118 |
> |
$url = "$webRoot/$day/$machine_name/$report/$reportChartFile"; |
119 |
> |
if (isReportEmpty("$reportDirectory/$day/$machine_name/$report/$reportChartDataFile", $minFileSize)) { |
120 |
|
echo "Host <b>$machine_name</b> did not send any information about <b>$report</b> on <b>$day</b>. Please select another report."; |
121 |
|
} |
122 |
< |
else if (file_exists($url)) { ?> |
123 |
< |
|
122 |
> |
else if (file_exists("$reportDirectory/$day/$machine_name/$report/$reportChartFile")) { |
123 |
> |
|
124 |
> |
include("$reportDirectory/$day/$machine_name/$report/$reportLimitsFile"); |
125 |
> |
|
126 |
> |
?> |
127 |
> |
|
128 |
|
<center><b>[<? echo $machine_name; ?>] - <? echo $report; ?></b></center> |
129 |
|
|
130 |
|
<table border="0" cellpadding="0" cellspacing="0"> |
147 |
|
</tr> |
148 |
|
</table> |
149 |
|
|
150 |
< |
<hr weigth="1" color="<? echo $lineColor ?>"> |
150 |
> |
<hr weight="1" color="<? echo $lineColor ?>"> |
151 |
|
|
152 |
+ |
<b>Latest data</b> |
153 |
+ |
<p> |
154 |
+ |
Latest set of data received from |
155 |
+ |
<a href="<? echo "latest.php?machine=$machine_name"; ?>"><?=$machine_name?></a> |
156 |
+ |
<br> |
157 |
+ |
Alerts for <a href="alerts.php?machine=<?=$machine_name?>"><?=$machine_name?></a> |
158 |
+ |
|
159 |
+ |
|
160 |
+ |
<hr weight="1" color="<? echo $lineColor ?>"> |
161 |
+ |
|
162 |
|
<b>Extra data</b> |
163 |
|
<p> |
164 |
< |
<a href="<? echo "$day/$machine_name/$report/$reportChartDataFile" ?>">Raw plot data</a><br> |
165 |
< |
<a href="<? echo "$day/$machine_name/$report/$reportChartFile" ?>">GIF chart</a><br> |
166 |
< |
<a href="<? echo "$day/$machine_name/$report/$reportLimitsFile" ?>">PHP y-axis limits include</a> |
164 |
> |
<a href="<? echo "$webRoot/$day/$machine_name/$report/$reportChartDataFile" ?>">Raw plot data</a><br> |
165 |
> |
<a href="<? echo "$webRoot/$day/$machine_name/$report/$reportChartFile" ?>">GIF chart</a><br> |
166 |
> |
<a href="<? echo "$webRoot/$day/$machine_name/$report/$reportLimitsFile" ?>">PHP y-axis limits include</a> |
167 |
|
|
168 |
|
<? } |
169 |
|
else { |