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 |
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); |
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()\""; |
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 |
|
|
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 |
|
|
330 |
my $alt = $row->{start}." - ".$row->{finish}."<br>"; |
my $alt = $row->{start}." - ".$row->{finish}."<br>"; |
331 |
$alt =~ s/:\d\d\.\d+//g; |
$alt =~ s/:\d\d\.\d+//g; |
332 |
$alt =~ s/\s+/ /g; |
$alt =~ s/\s+/ /g; |
333 |
$alt .= $row->{type}." <b>".$row->{status}."</b><br>". |
$alt .= $row->{specification}."<br>". |
334 |
$row->{user_group_host}." <i>".$row->{sessionid}."</i><br>". |
$row->{type}." <b>".$row->{status}."</b><br>". |
335 |
$row->{device}." on ".$row->{host}; |
$row->{user_group_host}." <i>".$row->{sessionid}."</i><br>". |
336 |
$alt .= "-- ".$row->{specification}; |
$row->{device}." on ".$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); |
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 |
|
|