20 |
'In Progress/Failures' => '192,64,192', |
'In Progress/Failures' => '192,64,192', |
21 |
'In Progress/Errors' => '255,128,128', |
'In Progress/Errors' => '255,128,128', |
22 |
'Queuing' => '255,255,0', |
'Queuing' => '255,255,0', |
23 |
|
'Queuing/Errors' => '255,192,64', |
24 |
'Aborted' => '255,0,0', |
'Aborted' => '255,0,0', |
25 |
'Failed' => '255,0,0', |
'Failed' => '255,0,0', |
26 |
'Completed' => '64,255,64', |
'Completed' => '64,255,64', |
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 $q=new CGI; |
|
|
|
|
$int_t = m_round($int_t); |
|
40 |
|
|
41 |
my ($from_t,$to_t) = (time()-$int_t,time()); |
my ($from_t,$to_t) = (time()-$int_t,time()); |
42 |
|
|
|
$to_t = param('to_t') if (param('to_t')); |
|
43 |
$from_t = param('from_t') if (param('from_t')); |
$from_t = param('from_t') if (param('from_t')); |
44 |
|
$to_t = param('to_t') if (param('to_t')); |
45 |
|
|
46 |
|
if (param('f-1')) { |
47 |
|
$from_t = $from_t - param('int_f-1') || $int_t; |
48 |
|
} elsif (param('f+1')) { |
49 |
|
$from_t = $from_t + param('int_f+1') || $int_t; |
50 |
|
} elsif (param('t-1')) { |
51 |
|
$to_t = $from_t - param('int_t-1') || $int_t; |
52 |
|
} elsif (param('t+1')) { |
53 |
|
$to_t = $from_t + $int_t; |
54 |
|
} |
55 |
|
|
56 |
|
# time range |
57 |
|
$int_t = m_round($int_t); |
58 |
|
|
59 |
# round to nearest minute |
# round to nearest minute |
60 |
sub m_round { |
sub m_round { |
72 |
# keep count of each status |
# keep count of each status |
73 |
my %count; |
my %count; |
74 |
|
|
75 |
if (param('pic')) { |
if (path_info()) { |
76 |
print "Content-type: image/png\nCache-Control: max-age=3600, must-revalidate\n\n"; |
print "Content-type: image/png\nCache-Control: max-age=86400, must-revalidate\nExpires: ",scalar localtime(time()+24*60*60),"\nLast-Modified: ",scalar localtime(0),"\n"; |
77 |
# create picture using GD |
# create picture using GD |
78 |
use GD; |
use GD; |
79 |
my $im = new GD::Image(1,$height); |
my $im = new GD::Image(1,$height); |
80 |
my $back = $im->colorAllocate(255,255,255); |
my $back = $im->colorAllocate(255,255,255); |
81 |
$im->transparent($back); |
$im->transparent($back); |
82 |
my ($r,$g,$b) = split(/,/,param('pic')); |
my $col = path_info(); $col =~ s,/,,g; |
83 |
my $col = $im->colorAllocate($r,$g,$b); |
my ($r,$g,$b) = split(/,/,$col); |
84 |
|
$col = $im->colorAllocate($r,$g,$b); |
85 |
$im->fill(0,0,$col); |
$im->fill(0,0,$col); |
86 |
|
print "Content-Length: ",length($im->png),"\n\n"; |
87 |
binmode STDOUT; |
binmode STDOUT; |
88 |
print $im->png; |
print $im->png; |
89 |
exit; |
exit; |
90 |
} |
} |
91 |
|
|
92 |
|
# open DBI connection |
93 |
|
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
94 |
|
|
95 |
print "Content-type: text/html |
print "Content-type: text/html |
96 |
Cache-Control: max-age=60, must-revalidate |
Cache-Control: max-age=60, must-revalidate |
97 |
|
|
98 |
<html> |
<html> |
99 |
<head> |
<head> |
100 |
<title>OmniBack Gantt: $from - $to</title> |
<title>OmniBack Gantt: $from - $to</title> |
101 |
<meta HTTP-EQUIV=\"Refresh\" CONTENT=60>"; |
<meta HTTP-EQUIV=\"Refresh\" CONTENT=600>"; |
102 |
if ($use_js) { |
if ($use_js) { |
103 |
print ' |
print ' |
104 |
<script type="text/javascript" language="javascript" src="1k.js"></script> |
<script type="text/javascript" language="javascript" src="1k.js"></script> |
112 |
</script> |
</script> |
113 |
'; |
'; |
114 |
} |
} |
115 |
print "</head><body>"; |
print "</head><body> |
116 |
|
<form action=".$q->url(-relative=>1)." method=get> |
117 |
|
<input type=hidden name=from_t value=$from_t> |
118 |
|
<input type=hidden name=to_t value=$to_t> |
119 |
|
"; |
120 |
|
|
121 |
# all vars ending in *_t have utime in them. |
# all vars ending in *_t have utime in them. |
122 |
# |
# |
123 |
my $len_t = $to_t - $from_t; |
my $len_t = $to_t - $from_t; |
124 |
|
|
125 |
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; |
|
126 |
|
|
127 |
|
|
128 |
sub mknav { |
sub mknav { |
129 |
my $f = shift @_; # from_t |
my $f = shift @_; # from_t |
130 |
my $t = shift @_; # to_t |
my $t = shift @_; # to_t |
131 |
|
my $d = shift @_; # delta |
132 |
my $ch = shift @_; # char |
my $ch = shift @_; # char |
133 |
|
|
134 |
return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
return " |
135 |
|
<select name=int_${d}> |
136 |
|
<option value=".(12*60*60).">12h</option> |
137 |
|
<option value=".(24*60*60).">day</option> |
138 |
|
<option value=".(7*24*60*60).">week</option> |
139 |
|
</select> |
140 |
|
<input type=submit name=$d value=\"$ch\"> |
141 |
|
"; |
142 |
|
#return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
143 |
} |
} |
144 |
|
|
145 |
print "<table cellspacing=0 cellpadding=0>"; |
print "<table cellspacing=0 cellpadding=0>"; |
146 |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
147 |
print mknav(($from_t-$int_t),$to_t,'<small><<</small>'),$from; |
print mknav($from_t,$to_t,'f-1','<<'),$from; |
148 |
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); |
149 |
print "</td><td align=right>"; |
print "</td><td align=right>"; |
150 |
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); |
151 |
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"; |
152 |
|
|
153 |
# draw hour grid |
# draw hour grid |
154 |
sub hour_grid { |
sub hour_grid { |
232 |
|
|
233 |
print STDERR "bar[$col] len:$l s scale:",($len_t/$width)," size:$size px<br> alt:$alt\n" if ($debug); |
print STDERR "bar[$col] len:$l s scale:",($len_t/$width)," size:$size px<br> alt:$alt\n" if ($debug); |
234 |
|
|
235 |
my $html = "<img src=\"".$q->url(-relative=>1)."?pic=$col\" width=\"$size\" height=\"$h\""; |
my $html = "<img src=\"".$q->url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\""; |
236 |
|
|
237 |
if ($use_js && $alt) { |
if ($use_js && $alt) { |
238 |
$html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\""; |
$html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\""; |
253 |
"; |
"; |
254 |
|
|
255 |
my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr; |
my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr; |
256 |
|
print STDERR "sql: $sql\n" if ($debug); |
257 |
|
|
258 |
my %spec; # specification hash |
my %spec; # specification hash |
259 |
|
|
260 |
my $curr_spec; |
my $curr_spec = ""; |
261 |
my $curr_t = $from_t; |
my $curr_t = $from_t; |
262 |
|
|
263 |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
283 |
$len++; |
$len++; |
284 |
} else { |
} else { |
285 |
my $h = $last_var / $max_use * $height; |
my $h = $last_var / $max_use * $height; |
286 |
my $c = 255 - 255 * $last_var / $max_use; |
my $c = 255 - int (255 * $last_var / $max_use); |
287 |
print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1); |
print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1); |
288 |
$len = 0; |
$len = 0; |
289 |
$last_var = $v; |
$last_var = $v; |
290 |
} |
} |
291 |
} |
} |
292 |
my $h = $last_var / $max_use * $height; |
my $h = $last_var / $max_use * $height; |
293 |
my $c = 255 - 255 * $last_var / $max_use; |
my $c = 255 - int (255 * $last_var / $max_use); |
294 |
print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1) if ($len); |
print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1) if ($len); |
295 |
print "</td></tr>"; |
print "</td></tr>"; |
296 |
} |
} |
297 |
|
|
298 |
|
my @line_t; # all seconds for this specification |
299 |
|
my @line_arr = (""); # all segments on line which are not fillers |
300 |
|
|
301 |
|
sub html_spec { |
302 |
|
print "<tr><td>$curr_spec</td><td colspan=2>"; |
303 |
|
|
304 |
|
my $last_var = 0; |
305 |
|
my $len = 0; |
306 |
|
my $i; |
307 |
|
for (my $t=0; $t<=$len_t; $t++) { |
308 |
|
$i = $line_t[$t] || 0; |
309 |
|
if ($i == $last_var) { |
310 |
|
$len++; |
311 |
|
} else { |
312 |
|
if ($last_var == 0) { |
313 |
|
print bar($len); |
314 |
|
} else { |
315 |
|
print bar($len,split(/\t/,$line_arr[$last_var],2)); |
316 |
|
} |
317 |
|
$len = 0; |
318 |
|
$last_var = $i; |
319 |
|
} |
320 |
|
} |
321 |
|
print bar($len,split(/\t/,$line_arr[$i],2)); |
322 |
|
|
323 |
|
print "</td></tr>\n"; |
324 |
|
} |
325 |
|
|
326 |
while(my $row = $sth->fetchrow_hashref) { |
while(my $row = $sth->fetchrow_hashref) { |
327 |
if (!defined $curr_spec || $row->{specification} ne $curr_spec) { |
if ($row->{specification} ne $curr_spec) { |
328 |
|
|
329 |
if ($curr_t < $to_t && $curr_spec) { |
if ($curr_t < $to_t && $curr_spec) { |
330 |
my $t = $to_t - $curr_t; |
my $t = $to_t - $curr_t; |
331 |
print STDERR "[end filler $curr_t:$t]" if ($debug); |
print STDERR "[end filler $curr_t:$t]" if ($debug); |
332 |
print bar($t); |
# print bar($t); |
333 |
} |
} |
334 |
|
|
335 |
print "</td></tr>\n" if ($curr_t != $from_t); |
# print "</td></tr>\n" if ($curr_t != $from_t); |
336 |
|
|
|
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}; |
|
|
} |
|
337 |
|
|
338 |
# init vars for next line |
# init vars for next line |
339 |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
340 |
print "<tr><td>", $row->{specification},"</td><td colspan=2>"; |
|
341 |
|
if ($curr_spec ne "") { |
342 |
|
$curr_spec =~ s/ +/ /g; |
343 |
|
html_spec; |
344 |
|
} |
345 |
|
|
346 |
$curr_t = $from_t; # init timeline |
$curr_t = $from_t; # init timeline |
347 |
$curr_spec = $row->{specification}; |
$curr_spec = $row->{specification}; |
348 |
|
|
349 |
|
@line_t = (); |
350 |
|
@line_arr = ( "" ); |
351 |
|
|
352 |
|
if ($dev && @dev_t && $dev ne $row->{device}) { |
353 |
|
sum_bar("summary for $dev",@dev_t); |
354 |
|
$dev = $row->{device}; |
355 |
|
@dev_t = (); |
356 |
|
} elsif (! $dev) { |
357 |
|
$dev = $row->{device}; |
358 |
|
} |
359 |
} |
} |
360 |
|
|
361 |
my $start_t = str2time($row->{start}); |
my $start_t = str2time($row->{start}); |
365 |
if ($start_t > $curr_t + ($len_t / $width)) { |
if ($start_t > $curr_t + ($len_t / $width)) { |
366 |
my $t = $start_t - $curr_t; |
my $t = $start_t - $curr_t; |
367 |
print STDERR "[middle filler $curr_t:$t]" if ($debug); |
print STDERR "[middle filler $curr_t:$t]" if ($debug); |
368 |
print bar($t); |
# print bar($t); |
369 |
$curr_t = $start_t; |
$curr_t = $start_t; |
370 |
} else { |
} else { |
371 |
# prepend too few seconds to next event |
# prepend too few seconds to next event |
398 |
$row->{type}." <b>".$row->{status}."</b><br>". |
$row->{type}." <b>".$row->{status}."</b><br>". |
399 |
$row->{user_group_host}." <i>".$row->{sessionid}."</i><br>". |
$row->{user_group_host}." <i>".$row->{sessionid}."</i><br>". |
400 |
$row->{device}." on ".$row->{host}; |
$row->{device}." on ".$row->{host}; |
401 |
print bar($len,$row->{status},$alt); |
# print bar($len,$row->{status},$alt); |
402 |
|
|
403 |
|
push @line_arr,$row->{status}."\t".$alt; |
404 |
# store use of devices for each minute |
# store use of devices for each minute |
405 |
for (my $s=0; $s<$len; $s++) { |
for (my $s=0; $s<$len; $s++) { |
406 |
|
$line_t[$curr_t-$from_t+$s] = $#line_arr; |
407 |
$dev_t[$curr_t-$from_t+$s]++; |
$dev_t[$curr_t-$from_t+$s]++; |
408 |
$dev_sum_t[$curr_t-$from_t+$s]++; |
$dev_sum_t[$curr_t-$from_t+$s]++; |
409 |
} |
} |
415 |
} |
} |
416 |
|
|
417 |
if ($curr_t == $from_t) { # no entries in database! |
if ($curr_t == $from_t) { # no entries in database! |
418 |
print "<tr><td></td><td colspan=2>"; |
# print "<tr><td></td><td colspan=2>"; |
419 |
} |
} |
420 |
|
|
421 |
if ($curr_t < $to_t ) { |
if ($curr_t < $to_t ) { |
422 |
my $t = $to_t - $curr_t; |
my $t = $to_t - $curr_t; |
423 |
print STDERR "[last_line filler $curr_t:$t]" if ($debug); |
print STDERR "[last_line filler $curr_t:$t]" if ($debug); |
|
print bar($t); |
|
424 |
} |
} |
425 |
|
|
426 |
undef $sth; |
undef $sth; |
427 |
$dbh->disconnect; |
$dbh->disconnect; |
428 |
|
|
429 |
print "</td></tr>\n"; |
html_spec(); |
430 |
sum_bar("summary for $dev",@dev_t); |
sum_bar("summary for $dev",@dev_t); |
431 |
hour_grid(); |
hour_grid(); |
432 |
sum_bar("summary for all devices",@dev_sum_t); |
sum_bar("summary for all devices",@dev_sum_t); |
434 |
|
|
435 |
|
|
436 |
# label and usage |
# label and usage |
|
$len_t = 50; # disable bar scaling |
|
437 |
|
|
438 |
print "<hr>\nColors for statuses and usage (#):\n"; |
print "<hr>\nColors for statuses and usage (#):\n"; |
439 |
print "<table border=0><tr bgcolor=#e0e0e0><th>status</th><th>#</th><th>color</th></tr>\n"; |
print "<table border=0><tr bgcolor=#e0e0e0><th>status</th><th>#</th><th>color</th></tr>\n"; |
440 |
|
my $max = 0; |
441 |
|
foreach my $status (keys %count) { |
442 |
|
$max = $count{$status} if ($count{$status} > $max); |
443 |
|
} |
444 |
|
$len_t = $max ; # disable bar scaling |
445 |
|
|
446 |
foreach my $status (keys %count) { |
foreach my $status (keys %count) { |
447 |
#foreach my $status (keys %cols) { |
#foreach my $status (keys %cols) { |
448 |
print "<tr bgcolor=#e0e0e0><td><small>$status</small></td><td><small>",$count{$status}*1,"</small></td><td>",bar($count{$status},$status),"</td></tr>\n" if ($status ne ""); |
print "<tr bgcolor=#e0e0e0><td><small>$status</small></td><td><small>",$count{$status}*1,"</small></td><td>",bar($count{$status},$status),"</td></tr>\n" if ($status ne ""); |
451 |
# it will first evaluate bar sub (thus increasing number by one) and |
# it will first evaluate bar sub (thus increasing number by one) and |
452 |
# then display number (wrongly). |
# then display number (wrongly). |
453 |
} |
} |
454 |
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>"; |
|
|
|