10 |
|
|
11 |
my $debug = 0; |
my $debug = 0; |
12 |
|
|
13 |
|
# comment out following field if you don't want links to omni reports |
14 |
|
# or haven't installed repgen.pl |
15 |
|
my $repgen_url="/omni/"; # URL to pages with rptgen.pl |
16 |
|
|
17 |
my $width = 600; # width of bar |
my $width = 600; # width of bar |
18 |
my $height = 15; # height of bar |
my $height = 15; # height of bar |
19 |
my $use_js = 1; # use JavaScript pop-up |
my $use_js = 1; # use JavaScript pop-up |
32 |
'Completed/Failure' => '128,0,128', |
'Completed/Failure' => '128,0,128', |
33 |
'Mount Request' => '128,128,255', |
'Mount Request' => '128,128,255', |
34 |
'Mount/Errors' => '255,64,128', |
'Mount/Errors' => '255,64,128', |
35 |
|
'Mount/Failures' => '255,128,192', |
36 |
); |
); |
37 |
|
|
38 |
my $int_t = (12 * 60 * 60); # interval to display on one screen |
my $int_t = (12 * 60 * 60); # interval to display on one screen |
40 |
|
|
41 |
#--- no user servicable parts below this line |
#--- no user servicable parts below this line |
42 |
|
|
43 |
# time range |
my $q=new CGI; |
|
|
|
|
$int_t = m_round($int_t); |
|
44 |
|
|
45 |
my ($from_t,$to_t) = (time()-$int_t,time()); |
my ($from_t,$to_t) = (time()-$int_t,time()); |
46 |
|
|
|
$to_t = param('to_t') if (param('to_t')); |
|
47 |
$from_t = param('from_t') if (param('from_t')); |
$from_t = param('from_t') if (param('from_t')); |
48 |
|
$to_t = param('to_t') if (param('to_t')); |
49 |
|
|
50 |
|
if (param('f-1')) { |
51 |
|
$from_t = $from_t - param('int_f-1') || $int_t; |
52 |
|
} elsif (param('f+1')) { |
53 |
|
$from_t = $from_t + param('int_f+1') || $int_t; |
54 |
|
} elsif (param('t-1')) { |
55 |
|
$to_t = $from_t - param('int_t-1') || $int_t; |
56 |
|
} elsif (param('t+1')) { |
57 |
|
$to_t = $from_t + $int_t; |
58 |
|
} |
59 |
|
|
60 |
|
# time range |
61 |
|
$int_t = m_round($int_t); |
62 |
|
|
63 |
# round to nearest minute |
# round to nearest minute |
64 |
sub m_round { |
sub m_round { |
85 |
$im->transparent($back); |
$im->transparent($back); |
86 |
my $col = path_info(); $col =~ s,/,,g; |
my $col = path_info(); $col =~ s,/,,g; |
87 |
my ($r,$g,$b) = split(/,/,$col); |
my ($r,$g,$b) = split(/,/,$col); |
88 |
my $col = $im->colorAllocate($r,$g,$b); |
$col = $im->colorAllocate($r,$g,$b); |
89 |
$im->fill(0,0,$col); |
$im->fill(0,0,$col); |
90 |
print "Content-Length: ",length($im->png),"\n\n"; |
print "Content-Length: ",length($im->png),"\n\n"; |
91 |
binmode STDOUT; |
binmode STDOUT; |
93 |
exit; |
exit; |
94 |
} |
} |
95 |
|
|
96 |
|
# open DBI connection |
97 |
|
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
98 |
|
|
99 |
print "Content-type: text/html |
print "Content-type: text/html |
100 |
Cache-Control: max-age=60, must-revalidate |
Cache-Control: max-age=60, must-revalidate |
101 |
|
|
116 |
</script> |
</script> |
117 |
'; |
'; |
118 |
} |
} |
119 |
print "</head><body>"; |
print "</head><body> |
120 |
|
<form action=".$q->url(-relative=>1)." method=get> |
121 |
|
<input type=hidden name=from_t value=$from_t> |
122 |
|
<input type=hidden name=to_t value=$to_t> |
123 |
|
"; |
124 |
|
|
125 |
# all vars ending in *_t have utime in them. |
# all vars ending in *_t have utime in them. |
126 |
# |
# |
127 |
my $len_t = $to_t - $from_t; |
my $len_t = $to_t - $from_t; |
128 |
|
|
129 |
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; |
|
130 |
|
|
131 |
|
|
132 |
sub mknav { |
sub mknav { |
133 |
my $f = shift @_; # from_t |
my $f = shift @_; # from_t |
134 |
my $t = shift @_; # to_t |
my $t = shift @_; # to_t |
135 |
|
my $d = shift @_; # delta |
136 |
my $ch = shift @_; # char |
my $ch = shift @_; # char |
137 |
|
|
138 |
return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
return " |
139 |
|
<select name=int_${d}> |
140 |
|
<option value=".(12*60*60).">12h</option> |
141 |
|
<option value=".(24*60*60).">day</option> |
142 |
|
<option value=".(7*24*60*60).">week</option> |
143 |
|
</select> |
144 |
|
<input type=submit name=$d value=\"$ch\"> |
145 |
|
"; |
146 |
|
#return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
147 |
} |
} |
148 |
|
|
149 |
print "<table cellspacing=0 cellpadding=0>"; |
print "<table cellspacing=0 cellpadding=0>"; |
150 |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
151 |
print mknav(($from_t-$int_t),$to_t,'<small><<</small>'),$from; |
print mknav($from_t,$to_t,'f-1','<<'),$from; |
152 |
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); |
153 |
print "</td><td align=right>"; |
print "</td><td align=right>"; |
154 |
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); |
155 |
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"; |
156 |
|
|
157 |
# draw hour grid |
# draw hour grid |
158 |
sub hour_grid { |
sub hour_grid { |
236 |
|
|
237 |
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); |
238 |
|
|
239 |
my $html = "<img src=\"".$q->url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\""; |
my $html; |
240 |
|
|
241 |
|
my ($html_end, $img_end) = ("",""); |
242 |
|
if ($repgen_url && $alt =~ m#(\d\d\d\d)/(\d\d)/(\d\d)-(\d+)#) { |
243 |
|
$html .= "<a href=\"$repgen_url/$1-$2-$3-$4.html\">"; |
244 |
|
$html_end .= "</a>"; |
245 |
|
$img_end .= " border=0"; |
246 |
|
} |
247 |
|
|
248 |
|
$html .= "<img src=\"".$q->url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\""; |
249 |
|
|
250 |
if ($use_js && $alt) { |
if ($use_js && $alt) { |
251 |
$html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\""; |
$html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\""; |
252 |
} elsif ($alt) { |
} elsif ($alt) { |
253 |
$html .= " alt=\"$alt\""; |
$html .= " alt=\"$alt\""; |
254 |
} |
} |
255 |
$html .= ">"; |
$html .= "$img_end>$html_end"; |
256 |
|
|
257 |
return($html); |
return($html); |
258 |
} |
} |
266 |
"; |
"; |
267 |
|
|
268 |
my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr; |
my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr; |
269 |
|
print STDERR "sql: $sql\n" if ($debug); |
270 |
|
|
271 |
my %spec; # specification hash |
my %spec; # specification hash |
272 |
|
|
273 |
my $curr_spec; |
my $curr_spec = ""; |
274 |
my $curr_t = $from_t; |
my $curr_t = $from_t; |
275 |
|
|
276 |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
302 |
$last_var = $v; |
$last_var = $v; |
303 |
} |
} |
304 |
} |
} |
305 |
|
# fix division by zero |
306 |
|
$max_use++ if ($max_use == 0); |
307 |
my $h = $last_var / $max_use * $height; |
my $h = $last_var / $max_use * $height; |
308 |
my $c = 255 - int (255 * $last_var / $max_use); |
my $c = 255 - int (255 * $last_var / $max_use); |
309 |
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); |
353 |
# init vars for next line |
# init vars for next line |
354 |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
355 |
|
|
356 |
html_spec if ($curr_spec ne ""); |
if ($curr_spec ne "") { |
357 |
|
$curr_spec =~ s/ +/ /g; |
358 |
|
html_spec; |
359 |
|
} |
360 |
|
|
361 |
$curr_t = $from_t; # init timeline |
$curr_t = $from_t; # init timeline |
362 |
$curr_spec = $row->{specification}; |
$curr_spec = $row->{specification}; |
449 |
|
|
450 |
|
|
451 |
# label and usage |
# label and usage |
|
$len_t = 50; # disable bar scaling |
|
452 |
|
|
453 |
print "<hr>\nColors for statuses and usage (#):\n"; |
print "<hr>\nColors for statuses and usage (#):\n"; |
454 |
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"; |
455 |
|
my $max = 0; |
456 |
|
foreach my $status (keys %count) { |
457 |
|
$max = $count{$status} if ($count{$status} > $max); |
458 |
|
} |
459 |
|
$len_t = $max ; # disable bar scaling |
460 |
|
|
461 |
foreach my $status (keys %count) { |
foreach my $status (keys %count) { |
462 |
#foreach my $status (keys %cols) { |
#foreach my $status (keys %cols) { |
463 |
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 ""); |
466 |
# it will first evaluate bar sub (thus increasing number by one) and |
# it will first evaluate bar sub (thus increasing number by one) and |
467 |
# then display number (wrongly). |
# then display number (wrongly). |
468 |
} |
} |
469 |
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>"; |
|
|
|