34 |
# You need to update this to point to the URL |
# You need to update this to point to the URL |
35 |
# you use to access Cricket. |
# you use to access Cricket. |
36 |
# $gBaseURL = "http://localhost/~cricket/grapher.cgi"; |
# $gBaseURL = "http://localhost/~cricket/grapher.cgi"; |
37 |
$gBaseURL = "http://romul.pliva.hr/cgi-bin/cricket/grapher.cgi"; |
my $hostname = `hostname -f`; |
38 |
|
chomp($hostname); |
39 |
|
$gBaseURL = "http://$hostname/cgi-bin/cricket/grapher.cgi"; |
40 |
|
|
41 |
# change this to destination directory |
# change this to destination directory |
42 |
$path = "/home/dpavlin/public_html"; |
$path = "/data/mon/"; |
|
# this is basename of all html files |
|
|
$name = "overview"; |
|
43 |
} |
} |
44 |
|
|
45 |
#use lib "$gInstallRoot/../lib"; |
#use lib "$gInstallRoot/../lib"; |
57 |
use Common::Options; |
use Common::Options; |
58 |
use Common::Log; |
use Common::Log; |
59 |
|
|
60 |
|
# |
61 |
|
# Set this option to 0 if you don't want JavaScript roll-up/roll-down |
62 |
|
# of images to be created |
63 |
|
# |
64 |
|
my $dynamic_js = 1; |
65 |
|
|
66 |
Common::Options::commonOptions( 'baseURL=s' => \$gBaseURL ); |
Common::Options::commonOptions( 'baseURL=s' => \$gBaseURL ); |
67 |
initConst(); |
initConst(); |
68 |
|
|
93 |
} |
} |
94 |
} |
} |
95 |
|
|
96 |
foreach my $filename (keys %html) { |
my %html_file; |
97 |
|
|
98 |
|
foreach my $item (sort keys %html) { |
99 |
|
my ($range,$target) = split(/\t/,$item,2); |
100 |
|
my (undef,$service,$arg) = split(/\//,$target,3); |
101 |
|
|
102 |
|
$html_file{"$range/$service"} .= $html{$item}; |
103 |
|
$html_file{"overview-$range"} .= $html{$item}; |
104 |
|
} |
105 |
|
|
106 |
|
foreach my $key (keys %html_file) { |
107 |
|
|
108 |
|
my $filename = "$path/$key.html"; |
109 |
|
my($dir) = dirname($filename); |
110 |
|
if (! -d $dir) { |
111 |
|
Info("Making directory $dir to hold file $filename."); |
112 |
|
Common::Util::MkDir($dir); |
113 |
|
} |
114 |
|
Info("Dumping HTML for $key to $filename."); |
115 |
open(OUT,"> $filename") || die "can't open output html '$filename': $!"; |
open(OUT,"> $filename") || die "can't open output html '$filename': $!"; |
116 |
print OUT $html{$filename},"</body></html>"; |
print OUT "<html><head><title>$key</title>"; |
117 |
|
print OUT '<meta content="no-cache" http-equiv="Pragma"> |
118 |
|
<meta content="300" http-equiv="Refresh">' if ($filename =~ m/Daily/i); |
119 |
|
print OUT '</head><body>'; |
120 |
|
my $html=<<'HTMLEND'; |
121 |
|
|
122 |
|
<script language="JavaScript"> |
123 |
|
var Selected = ""; |
124 |
|
|
125 |
|
function Switch(elm) |
126 |
|
{ |
127 |
|
var cookie = Get_Cookie("##cookie_name##"); |
128 |
|
|
129 |
|
var elmref; |
130 |
|
|
131 |
|
// uncomment following lines for just 1 selected content |
132 |
|
/* |
133 |
|
if (Selected != "") |
134 |
|
{ |
135 |
|
elmref = eval("document.getElementById('" + Selected + "_h1')"); |
136 |
|
if (elmref) elmref.style.display = 'none'; |
137 |
|
elmref = eval("document.getElementById('" + Selected + "_h0')"); |
138 |
|
// roll-up color |
139 |
|
if (elmref) elmref.bgColor = '#eeeeee'; |
140 |
|
} |
141 |
|
if (Selected != elm.name) |
142 |
|
{ |
143 |
|
Selected = elm.name; |
144 |
|
elmref = eval("document.getElementById('" + Selected + "_h1')"); |
145 |
|
if (elmref) |
146 |
|
{ |
147 |
|
if (elmref.style.display=='none') elmref.style.display=''; |
148 |
|
else elmref.style.display = 'none'; |
149 |
|
} |
150 |
|
elmref = eval("document.getElementById('" + Selected + "_h0')"); |
151 |
|
// roll-down color |
152 |
|
if (elmref) elmref.bgColor = '#ffffff'; |
153 |
|
} |
154 |
|
else |
155 |
|
Selected=""; |
156 |
|
*/ |
157 |
|
|
158 |
|
// or use this to unroll more than one line |
159 |
|
Selected = elm.name; |
160 |
|
elmref = eval("document.getElementById('" + Selected + "_h1')"); |
161 |
|
if (elmref) |
162 |
|
{ |
163 |
|
if (elmref.style.display=='none') elmref.style.display=''; |
164 |
|
else elmref.style.display = 'none'; |
165 |
|
cookie ^= 1 << Selected; |
166 |
|
} |
167 |
|
|
168 |
|
Set_Cookie("##cookie_name##",cookie); |
169 |
|
return false; |
170 |
|
} |
171 |
|
|
172 |
|
function SwitchThis() |
173 |
|
{ |
174 |
|
return Switch(this); |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
</script> |
179 |
|
|
180 |
|
<table border=0 id=DynamicTable bgColor='#e0e0e0' cellpadding=2 cellspacing=1> |
181 |
|
|
182 |
|
HTMLEND |
183 |
|
if ($dynamic_js) { |
184 |
|
my $cookie_name = $key; |
185 |
|
$cookie_name =~ s/[^a-zA-Z0-9]//g; |
186 |
|
$html =~ s/##cookie_name##/$cookie_name/g; |
187 |
|
print OUT $html; |
188 |
|
} |
189 |
|
|
190 |
|
print OUT $html_file{$key}; |
191 |
|
$html = <<'HTMLEND'; |
192 |
|
</table> |
193 |
|
|
194 |
|
<script language=javascript> |
195 |
|
|
196 |
|
function Get_Cookie(name) { |
197 |
|
var start = document.cookie.indexOf(name+"="); |
198 |
|
var len = start+name.length+1; |
199 |
|
if ((!start) && (name != document.cookie.substring(0,name.length))) return null; |
200 |
|
if (start == -1) return null; |
201 |
|
var end = document.cookie.indexOf(";",len); |
202 |
|
if (end == -1) end = document.cookie.length; |
203 |
|
return unescape(document.cookie.substring(len,end)); |
204 |
|
} |
205 |
|
|
206 |
|
function Set_Cookie(name,value,expires,path,domain,secure) { |
207 |
|
document.cookie = name + "=" +escape(value) + |
208 |
|
( (expires) ? ";expires=" + expires.toGMTString() : "") + |
209 |
|
( (path) ? ";path=" + path : "") + |
210 |
|
( (domain) ? ";domain=" + domain : "") + |
211 |
|
( (secure) ? ";secure" : ""); |
212 |
|
} |
213 |
|
|
214 |
|
function Delete_Cookie(name,path,domain) { |
215 |
|
if (Get_Cookie(name)) document.cookie = name + "=" + |
216 |
|
( (path) ? ";path=" + path : "") + |
217 |
|
( (domain) ? ";domain=" + domain : "") + |
218 |
|
";expires=Thu, 01-Jan-70 00:00:01 GMT"; |
219 |
|
} |
220 |
|
|
221 |
|
var table = document.getElementById("DynamicTable"); |
222 |
|
var links = table.getElementsByTagName("a"); |
223 |
|
var cookie = Get_Cookie("##cookie_name##"); |
224 |
|
var new_cookie = 0; |
225 |
|
for (var i = 0; i < links.length; i++) { |
226 |
|
if (links[i].id == "DynMessLink") { |
227 |
|
links[i].onclick = SwitchThis; |
228 |
|
elmref = eval("document.getElementById('" + links[i].name + "_h1')"); |
229 |
|
if (elmref && cookie) { |
230 |
|
if (cookie & 1 << links[i].name) { |
231 |
|
elmref.style.display=''; |
232 |
|
} else { |
233 |
|
elmref.style.display = 'none'; |
234 |
|
} |
235 |
|
} else if(elmref) { |
236 |
|
if (elmref.style.display=='none') { |
237 |
|
elmref.style.display=''; |
238 |
|
new_cookie |= 1 << links[i].name; |
239 |
|
} else { |
240 |
|
elmref.style.display = 'none'; |
241 |
|
//new_cookie &= !( 1 << links[i].name ); |
242 |
|
} |
243 |
|
} |
244 |
|
} |
245 |
|
} |
246 |
|
if (new_cookie) Set_Cookie("##cookie_name##",new_cookie); |
247 |
|
</script> |
248 |
|
HTMLEND |
249 |
|
|
250 |
|
if ($dynamic_js) { |
251 |
|
my $cookie_name = $key; |
252 |
|
$cookie_name =~ s/[^a-zA-Z0-9]//g; |
253 |
|
$html =~ s/##cookie_name##/$cookie_name/g; |
254 |
|
print OUT $html; |
255 |
|
} |
256 |
|
|
257 |
|
print OUT "</body></html>"; |
258 |
close(OUT); |
close(OUT); |
259 |
|
|
260 |
} |
} |
261 |
|
|
262 |
exit; |
exit; |
263 |
|
|
264 |
|
sub do_html { |
265 |
|
my ($desc,$url,$img) = @_; |
266 |
|
if ($dynamic_js) { |
267 |
|
my $html =<<'HTMLEND'; |
268 |
|
<tr bgcolor='#eeeeee' id=##id##_h0> |
269 |
|
<td><a href="#" id=DynMessLink name=##id## >##desc##</a></td> |
270 |
|
</tr> |
271 |
|
<tr id=##id##_h1 style='display:none' bgcolor='#ffffff' > |
272 |
|
<td><a href="##url##"><img src="##img##"</td> |
273 |
|
</tr> |
274 |
|
HTMLEND |
275 |
|
$html =~ s/##desc##/$desc/; |
276 |
|
$html =~ s/##url##/$url/; |
277 |
|
$html =~ s/##img##/$img/; |
278 |
|
$html =~ s/##id##/$dynamic_js/g; |
279 |
|
$dynamic_js++; # increment usage counter |
280 |
|
return $html; |
281 |
|
} else { |
282 |
|
return "$desc<br><a href=\"$url\"><img src=\"$img\"></a><br>\n"; |
283 |
|
} |
284 |
|
} |
285 |
|
|
286 |
sub localHandleTargetInstance { |
sub localHandleTargetInstance { |
287 |
my($Name, $target) = @_; |
my($Name, $target) = @_; |
288 |
|
|
333 |
|
|
334 |
my($dslist); |
my($dslist); |
335 |
|
|
|
my($filename)="$path/$name-$rangeLabel.html"; |
|
|
if (! defined $html{$filename}) { |
|
|
$html{$filename}="<html><head><title>$rangeLabel</title></head><body>"; |
|
|
} |
|
|
my($dir) = dirname($filename); |
|
|
if (! -d $dir) { |
|
|
Info("Making directory $dir to hold file $filename."); |
|
|
Common::Util::MkDir($dir); |
|
|
} |
|
|
|
|
336 |
if (defined($ttRef->{'view'})) |
if (defined($ttRef->{'view'})) |
337 |
{ |
{ |
338 |
my($v); |
my($v); |
347 |
|
|
348 |
$URL = "$gBaseURL?type=png&target=$paramtarget"; |
$URL = "$gBaseURL?type=png&target=$paramtarget"; |
349 |
$URL .= "&dslist=$dslist&range=$paramrange"; |
$URL .= "&dslist=$dslist&range=$paramrange"; |
350 |
my $desc = "view: "; |
my $desc = "$paramtarget $vname"; |
351 |
|
$desc .= " <b>".$target->{'short-desc'}."</b>" if (defined $target->{'short-desc'}); |
352 |
if ($paraminst ne "") { |
if ($paraminst ne "") { |
353 |
$URL .= "&inst=$paraminst"; |
$URL .= "&inst=$paraminst"; |
|
$desc.="$paraminst $paramtarget $vname"; |
|
|
} else { |
|
|
$desc.="$paramtarget $vname"; |
|
354 |
} |
} |
355 |
|
|
356 |
Info("Retrieving graph for $desc"); |
Info("Retrieving graph for $desc"); |
357 |
# getURL($URL,"$path/$name-$vname-$rangeLabel.png"); |
# getURL($URL,"$path/$name-$vname-$rangeLabel.png"); |
358 |
$tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname"; |
$tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname"; |
359 |
$html{$filename}.="$desc<br><a href=\"$tmp_URL\"><img src=$URL></a><br>"; |
$html{"$rangeLabel\t$paramtarget"}.=do_html($desc,$tmp_URL,$URL); |
360 |
} |
} |
361 |
} else { |
} else { |
362 |
$dslist = $ttRef->{'ds'}; |
$dslist = $ttRef->{'ds'}; |
365 |
|
|
366 |
$URL = "$gBaseURL?type=png&target=$paramtarget"; |
$URL = "$gBaseURL?type=png&target=$paramtarget"; |
367 |
$URL .= "&dslist=$dslist&range=$paramrange"; |
$URL .= "&dslist=$dslist&range=$paramrange"; |
368 |
my $desc = "ds: "; |
my $desc ="$paraminst $rangeLabel"; |
369 |
|
$desc .= " <b>".$target->{'short-desc'}."</b>" if (defined $target->{'short-desc'}); |
370 |
if ($paraminst ne "") { |
if ($paraminst ne "") { |
371 |
$URL .= "&inst=$paraminst"; |
$URL .= "&inst=$paraminst"; |
|
$desc.="$paraminst $rangeLabel" |
|
|
} else { |
|
|
$desc.="$paramtarget $rangeLabel"; |
|
372 |
} |
} |
373 |
|
|
374 |
Info("Retrieving graph for $desc"); |
Info("Retrieving graph for $desc"); |
375 |
|
|
376 |
# getURL($URL,"$path/$name-$rangeLabel.png"); |
# getURL($URL,"$path/$name-$rangeLabel.png"); |
377 |
$tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y"; |
$tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y"; |
378 |
$html{$filename}.="$desc:<br><a href=\"$tmp_URL\"><img src=$URL><a/><br>"; |
$html{"$rangeLabel\t$paramtarget"}.=do_html($desc,$tmp_URL,$URL); |
379 |
} |
} |
380 |
} |
} |
381 |
} |
} |