/[omni_gantt]/db2gantt.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /db2gantt.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by dpavlin, Sun Sep 15 19:29:38 2002 UTC revision 1.20 by dpavlin, Mon Sep 16 15:09:19 2002 UTC
# Line 11  use POSIX qw(strftime); Line 11  use POSIX qw(strftime);
11  my $debug = 0;  my $debug = 0;
12    
13  my $width = 600;        # width of bar  my $width = 600;        # width of bar
14  my $height = 19;        # height of bar  my $height = 15;        # height of bar
15  my $use_js = 1;         # use JavaScript pop-up  my $use_js = 1;         # use JavaScript pop-up
16    
17  # status colors  # status colors
# Line 179  sub color_bar { Line 179  sub color_bar {
179          my $col = shift @_ || '240,240,240';    # default color (filler)          my $col = shift @_ || '240,240,240';    # default color (filler)
180          my $alt = shift @_ || undef;          my $alt = shift @_ || undef;
181          my $min_l = shift @_ || 1;          my $min_l = shift @_ || 1;
182            my $h = shift @_ || $height;
183    
184          my $size = $l / ($len_t / $width);          my $size = $l / ($len_t / $width);
185          $fix_s += $size - int($size);          $fix_s += $size - int($size);
# Line 203  sub color_bar { Line 204  sub color_bar {
204    
205          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);
206    
207          my $html = "<img src=\"".$q->url(-relative=>1)."?pic=$col\" width=\"$size\" height=\"$height\"";          my $html = "<img src=\"".$q->url(-relative=>1)."?pic=$col\" width=\"$size\" height=\"$h\"";
208    
209          if ($use_js && $alt) {          if ($use_js && $alt) {
210                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";
# Line 232  my $curr_t = $from_t; Line 233  my $curr_t = $from_t;
233    
234  $sth->execute() || die "sql: $sql ".$dbh->errstr;  $sth->execute() || die "sql: $sql ".$dbh->errstr;
235    
236    my $dev;        # current device
237    my @dev_t;      # all minutes in one hour [1440]
238    my @dev_sum_t;
239    
240    sub sum_bar {
241            my $label = shift @_;
242            my @dev_t = @_;
243            # display device summary
244            my $max_use = 0;
245            for (my $i=0; $i < $len_t; $i++) {
246                    $max_use = $dev_t[$i] if (defined $dev_t[$i] && $dev_t[$i] > $max_use);
247            }
248            print "<tr><td align=right><small>$label [$max_use]</small></td><td colspan=2>";
249            my $last_var = 0;
250            my $len = 0;
251            for (my $i=1; $i<= ($to_t-$from_t); $i++) {
252                    my $v = $dev_t[$i] || 0;
253                    if ($v == $last_var) {
254                            $len++;
255                    } else {
256                            my $h = $last_var / $max_use * $height;
257                            my $c = 255 - 255 * $last_var / $max_use;
258                            print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1);
259                            $len = 0;
260                            $last_var = $v;
261                    }
262            }
263            my $h = $last_var / $max_use * $height;
264            my $c = 255 - 255 * $last_var / $max_use;
265            print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1) if ($len);
266            print "</td></tr>";
267    }
268    
269  while(my $row = $sth->fetchrow_hashref) {  while(my $row = $sth->fetchrow_hashref) {
270          if (!defined $curr_spec || $row->{specification} ne $curr_spec) {          if (!defined $curr_spec || $row->{specification} ne $curr_spec) {
271    
# Line 242  while(my $row = $sth->fetchrow_hashref) Line 276  while(my $row = $sth->fetchrow_hashref)
276                  }                  }
277    
278                  print "</td></tr>\n" if ($curr_t != $from_t);                  print "</td></tr>\n" if ($curr_t != $from_t);
279    
280                    if ($dev && @dev_t && $dev ne $row->{device}) {
281                            sum_bar("summary for $dev",@dev_t);
282                            $dev = $row->{device};
283                            @dev_t = ();
284                    } elsif (! $dev) {
285                            $dev = $row->{device};
286                    }
287    
288                    # init vars for next line
289                  ($fix_s,$fix_d) = (0,0); # init fix vars for bar                  ($fix_s,$fix_d) = (0,0); # init fix vars for bar
290                  print "<tr><td>", $row->{specification},"</td><td colspan=2>";                  print "<tr><td>", $row->{specification},"</td><td colspan=2>";
291    
# Line 292  while(my $row = $sth->fetchrow_hashref) Line 336  while(my $row = $sth->fetchrow_hashref)
336                  $row->{device}."&nbsp;on&nbsp;".$row->{host};                  $row->{device}."&nbsp;on&nbsp;".$row->{host};
337          print bar($len,$row->{status},$alt);          print bar($len,$row->{status},$alt);
338    
339            # store use of devices for each minute
340            for (my $s=0; $s<$len; $s++) {
341                    $dev_t[$curr_t-$from_t+$s]++;
342                    $dev_sum_t[$curr_t-$from_t+$s]++;
343            }
344    
345          $curr_t += $len;          $curr_t += $len;
346    
347  #       print Dumper($row);  #       print Dumper($row);
# Line 312  undef $sth; Line 362  undef $sth;
362  $dbh->disconnect;  $dbh->disconnect;
363    
364  print "</td></tr>\n";  print "</td></tr>\n";
365    sum_bar("summary for $dev",@dev_t);
366  hour_grid();  hour_grid();
367    sum_bar("summary for all devices",@dev_sum_t);
368  print "</table>";  print "</table>";
369    
370    

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.26