28 |
'Completed/Failure' => '128,0,128', |
'Completed/Failure' => '128,0,128', |
29 |
'Mount Request' => '128,128,255', |
'Mount Request' => '128,128,255', |
30 |
'Mount/Errors' => '255,64,128', |
'Mount/Errors' => '255,64,128', |
31 |
|
'Mount/Failures' => '255,128,192', |
32 |
); |
); |
33 |
|
|
34 |
my $int_t = (12 * 60 * 60); # interval to display on one screen |
my $int_t = (12 * 60 * 60); # interval to display on one screen |
36 |
|
|
37 |
#--- no user servicable parts below this line |
#--- no user servicable parts below this line |
38 |
|
|
39 |
# time range |
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
40 |
|
my $q=new CGI; |
|
$int_t = m_round($int_t); |
|
41 |
|
|
42 |
my ($from_t,$to_t) = (time()-$int_t,time()); |
my ($from_t,$to_t) = (time()-$int_t,time()); |
43 |
|
|
|
$to_t = param('to_t') if (param('to_t')); |
|
44 |
$from_t = param('from_t') if (param('from_t')); |
$from_t = param('from_t') if (param('from_t')); |
45 |
|
$to_t = param('to_t') if (param('to_t')); |
46 |
|
|
47 |
|
if (param('f-1')) { |
48 |
|
$from_t = $from_t - param('int_f-1') || $int_t; |
49 |
|
} elsif (param('f+1')) { |
50 |
|
$from_t = $from_t + param('int_f+1') || $int_t; |
51 |
|
} elsif (param('t-1')) { |
52 |
|
$to_t = $from_t - param('int_t-1') || $int_t; |
53 |
|
} elsif (param('t+1')) { |
54 |
|
$to_t = $from_t + $int_t; |
55 |
|
} |
56 |
|
|
57 |
|
# time range |
58 |
|
$int_t = m_round($int_t); |
59 |
|
|
60 |
# round to nearest minute |
# round to nearest minute |
61 |
sub m_round { |
sub m_round { |
82 |
$im->transparent($back); |
$im->transparent($back); |
83 |
my $col = path_info(); $col =~ s,/,,g; |
my $col = path_info(); $col =~ s,/,,g; |
84 |
my ($r,$g,$b) = split(/,/,$col); |
my ($r,$g,$b) = split(/,/,$col); |
85 |
my $col = $im->colorAllocate($r,$g,$b); |
$col = $im->colorAllocate($r,$g,$b); |
86 |
$im->fill(0,0,$col); |
$im->fill(0,0,$col); |
87 |
print "Content-Length: ",length($im->png),"\n\n"; |
print "Content-Length: ",length($im->png),"\n\n"; |
88 |
binmode STDOUT; |
binmode STDOUT; |
110 |
</script> |
</script> |
111 |
'; |
'; |
112 |
} |
} |
113 |
print "</head><body>"; |
print "</head><body> |
114 |
|
<form action=".$q->url(-relative=>1)." method=get> |
115 |
|
<input type=hidden name=from_t value=$from_t> |
116 |
|
<input type=hidden name=to_t value=$to_t> |
117 |
|
"; |
118 |
|
|
119 |
# all vars ending in *_t have utime in them. |
# all vars ending in *_t have utime in them. |
120 |
# |
# |
121 |
my $len_t = $to_t - $from_t; |
my $len_t = $to_t - $from_t; |
122 |
|
|
123 |
die "interval must be positive and bigger than 1 sec !" if ($len_t < 1); |
die "interval must be positive and bigger than 1 sec !" if (abs($len_t) < 1); |
|
|
|
|
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
|
|
my $q=new CGI; |
|
124 |
|
|
125 |
|
|
126 |
sub mknav { |
sub mknav { |
127 |
my $f = shift @_; # from_t |
my $f = shift @_; # from_t |
128 |
my $t = shift @_; # to_t |
my $t = shift @_; # to_t |
129 |
|
my $d = shift @_; # delta |
130 |
my $ch = shift @_; # char |
my $ch = shift @_; # char |
131 |
|
|
132 |
return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
return " |
133 |
|
<select name=int_${d}> |
134 |
|
<option value=".(12*60*60).">12h</option> |
135 |
|
<option value=".(24*60*60).">day</option> |
136 |
|
<option value=".(7*24*60*60).">week</option> |
137 |
|
</select> |
138 |
|
<input type=submit name=$d value=\"$ch\"> |
139 |
|
"; |
140 |
|
#return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
141 |
} |
} |
142 |
|
|
143 |
print "<table cellspacing=0 cellpadding=0>"; |
print "<table cellspacing=0 cellpadding=0>"; |
144 |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
145 |
print mknav(($from_t-$int_t),$to_t,'<small><<</small>'),$from; |
print mknav($from_t,$to_t,'f-1','<<'),$from; |
146 |
print mknav(($from_t+$int_t),$to_t,'<small>>></small>') if ($from_t+$int_t < $to_t); |
print mknav($from_t,$to_t,'f+1','>>') if ($from_t+$int_t < $to_t); |
147 |
print "</td><td align=right>"; |
print "</td><td align=right>"; |
148 |
print mknav($from_t,($to_t-$int_t),'<small><<</small>') if ($to_t-$int_t > $from_t); |
print mknav($from_t,$to_t,'t-1','<<') if ($to_t+$int_t > $from_t); |
149 |
print $to,mknav($from_t,($to_t+$int_t),'<small>>></small>'),"</td></tr>\n"; |
print $to,mknav($from_t,$to_t,'t+1','>>'),"</td></tr>\n"; |
150 |
|
|
151 |
# draw hour grid |
# draw hour grid |
152 |
sub hour_grid { |
sub hour_grid { |
254 |
|
|
255 |
my %spec; # specification hash |
my %spec; # specification hash |
256 |
|
|
257 |
my $curr_spec; |
my $curr_spec = ""; |
258 |
my $curr_t = $from_t; |
my $curr_t = $from_t; |
259 |
|
|
260 |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
292 |
print "</td></tr>"; |
print "</td></tr>"; |
293 |
} |
} |
294 |
|
|
295 |
|
my @line_t; # all seconds for this specification |
296 |
|
my @line_arr = (""); # all segments on line which are not fillers |
297 |
|
|
298 |
|
sub html_spec { |
299 |
|
print "<tr><td>$curr_spec</td><td colspan=2>"; |
300 |
|
|
301 |
|
my $last_var = 0; |
302 |
|
my $len = 0; |
303 |
|
my $i; |
304 |
|
for (my $t=0; $t<=$len_t; $t++) { |
305 |
|
$i = $line_t[$t] || 0; |
306 |
|
if ($i == $last_var) { |
307 |
|
$len++; |
308 |
|
} else { |
309 |
|
if ($last_var == 0) { |
310 |
|
print bar($len); |
311 |
|
} else { |
312 |
|
print bar($len,split(/\t/,$line_arr[$last_var],2)); |
313 |
|
} |
314 |
|
$len = 0; |
315 |
|
$last_var = $i; |
316 |
|
} |
317 |
|
} |
318 |
|
print bar($len,split(/\t/,$line_arr[$i],2)); |
319 |
|
|
320 |
|
print "</td></tr>\n"; |
321 |
|
} |
322 |
|
|
323 |
while(my $row = $sth->fetchrow_hashref) { |
while(my $row = $sth->fetchrow_hashref) { |
324 |
if (!defined $curr_spec || $row->{specification} ne $curr_spec) { |
if ($row->{specification} ne $curr_spec) { |
325 |
|
|
326 |
if ($curr_t < $to_t && $curr_spec) { |
if ($curr_t < $to_t && $curr_spec) { |
327 |
my $t = $to_t - $curr_t; |
my $t = $to_t - $curr_t; |
328 |
print STDERR "[end filler $curr_t:$t]" if ($debug); |
print STDERR "[end filler $curr_t:$t]" if ($debug); |
329 |
print bar($t); |
# print bar($t); |
330 |
} |
} |
331 |
|
|
332 |
print "</td></tr>\n" if ($curr_t != $from_t); |
# print "</td></tr>\n" if ($curr_t != $from_t); |
333 |
|
|
|
if ($dev && @dev_t && $dev ne $row->{device}) { |
|
|
sum_bar("summary for $dev",@dev_t); |
|
|
$dev = $row->{device}; |
|
|
@dev_t = (); |
|
|
} elsif (! $dev) { |
|
|
$dev = $row->{device}; |
|
|
} |
|
334 |
|
|
335 |
# init vars for next line |
# init vars for next line |
336 |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
337 |
print "<tr><td>", $row->{specification},"</td><td colspan=2>"; |
|
338 |
|
html_spec if ($curr_spec ne ""); |
339 |
|
|
340 |
$curr_t = $from_t; # init timeline |
$curr_t = $from_t; # init timeline |
341 |
$curr_spec = $row->{specification}; |
$curr_spec = $row->{specification}; |
342 |
|
|
343 |
|
@line_t = (); |
344 |
|
@line_arr = ( "" ); |
345 |
|
|
346 |
|
if ($dev && @dev_t && $dev ne $row->{device}) { |
347 |
|
sum_bar("summary for $dev",@dev_t); |
348 |
|
$dev = $row->{device}; |
349 |
|
@dev_t = (); |
350 |
|
} elsif (! $dev) { |
351 |
|
$dev = $row->{device}; |
352 |
|
} |
353 |
} |
} |
354 |
|
|
355 |
my $start_t = str2time($row->{start}); |
my $start_t = str2time($row->{start}); |
359 |
if ($start_t > $curr_t + ($len_t / $width)) { |
if ($start_t > $curr_t + ($len_t / $width)) { |
360 |
my $t = $start_t - $curr_t; |
my $t = $start_t - $curr_t; |
361 |
print STDERR "[middle filler $curr_t:$t]" if ($debug); |
print STDERR "[middle filler $curr_t:$t]" if ($debug); |
362 |
print bar($t); |
# print bar($t); |
363 |
$curr_t = $start_t; |
$curr_t = $start_t; |
364 |
} else { |
} else { |
365 |
# prepend too few seconds to next event |
# prepend too few seconds to next event |
392 |
$row->{type}." <b>".$row->{status}."</b><br>". |
$row->{type}." <b>".$row->{status}."</b><br>". |
393 |
$row->{user_group_host}." <i>".$row->{sessionid}."</i><br>". |
$row->{user_group_host}." <i>".$row->{sessionid}."</i><br>". |
394 |
$row->{device}." on ".$row->{host}; |
$row->{device}." on ".$row->{host}; |
395 |
print bar($len,$row->{status},$alt); |
# print bar($len,$row->{status},$alt); |
396 |
|
|
397 |
|
push @line_arr,$row->{status}."\t".$alt; |
398 |
# store use of devices for each minute |
# store use of devices for each minute |
399 |
for (my $s=0; $s<$len; $s++) { |
for (my $s=0; $s<$len; $s++) { |
400 |
|
$line_t[$curr_t-$from_t+$s] = $#line_arr; |
401 |
$dev_t[$curr_t-$from_t+$s]++; |
$dev_t[$curr_t-$from_t+$s]++; |
402 |
$dev_sum_t[$curr_t-$from_t+$s]++; |
$dev_sum_t[$curr_t-$from_t+$s]++; |
403 |
} |
} |
409 |
} |
} |
410 |
|
|
411 |
if ($curr_t == $from_t) { # no entries in database! |
if ($curr_t == $from_t) { # no entries in database! |
412 |
print "<tr><td></td><td colspan=2>"; |
# print "<tr><td></td><td colspan=2>"; |
413 |
} |
} |
414 |
|
|
415 |
if ($curr_t < $to_t ) { |
if ($curr_t < $to_t ) { |
416 |
my $t = $to_t - $curr_t; |
my $t = $to_t - $curr_t; |
417 |
print STDERR "[last_line filler $curr_t:$t]" if ($debug); |
print STDERR "[last_line filler $curr_t:$t]" if ($debug); |
|
print bar($t); |
|
418 |
} |
} |
419 |
|
|
420 |
undef $sth; |
undef $sth; |
421 |
$dbh->disconnect; |
$dbh->disconnect; |
422 |
|
|
423 |
print "</td></tr>\n"; |
html_spec(); |
424 |
sum_bar("summary for $dev",@dev_t); |
sum_bar("summary for $dev",@dev_t); |
425 |
hour_grid(); |
hour_grid(); |
426 |
sum_bar("summary for all devices",@dev_sum_t); |
sum_bar("summary for all devices",@dev_sum_t); |
440 |
# it will first evaluate bar sub (thus increasing number by one) and |
# it will first evaluate bar sub (thus increasing number by one) and |
441 |
# then display number (wrongly). |
# then display number (wrongly). |
442 |
} |
} |
443 |
print "</table>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a> or see <a href=\"db2gantt_help.html\">help</a>.</p></body></html>"; |
print "</table></form>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a> or see <a href=\"db2gantt_help.html\">help</a>.</p></body></html>"; |
444 |
|
|