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