269 |
print "</td></tr>"; |
print "</td></tr>"; |
270 |
} |
} |
271 |
|
|
272 |
|
my @line_t; # all seconds for this specification |
273 |
|
my @line_arr = (""); # all segments on line which are not fillers |
274 |
|
|
275 |
|
sub html_spec { |
276 |
|
print "<tr><td>$curr_spec</td><td colspan=2>"; |
277 |
|
|
278 |
|
my $last_var = 0; |
279 |
|
my $len = 0; |
280 |
|
my $i; |
281 |
|
for (my $t=0; $t<=$len_t; $t++) { |
282 |
|
$i = $line_t[$t] || 0; |
283 |
|
if ($i == $last_var) { |
284 |
|
$len++; |
285 |
|
} else { |
286 |
|
if ($last_var == 0) { |
287 |
|
print bar($len); |
288 |
|
} else { |
289 |
|
print bar($len,split(/\t/,$line_arr[$last_var],2)); |
290 |
|
} |
291 |
|
$len = 0; |
292 |
|
$last_var = $i; |
293 |
|
} |
294 |
|
} |
295 |
|
print bar($len,split(/\t/,$line_arr[$i],2)); |
296 |
|
|
297 |
|
print "</td></tr>\n"; |
298 |
|
} |
299 |
|
|
300 |
while(my $row = $sth->fetchrow_hashref) { |
while(my $row = $sth->fetchrow_hashref) { |
301 |
if (!defined $curr_spec || $row->{specification} ne $curr_spec) { |
if ($row->{specification} ne $curr_spec) { |
302 |
|
|
303 |
if ($curr_t < $to_t && $curr_spec) { |
if ($curr_t < $to_t && $curr_spec) { |
304 |
my $t = $to_t - $curr_t; |
my $t = $to_t - $curr_t; |
305 |
print STDERR "[end filler $curr_t:$t]" if ($debug); |
print STDERR "[end filler $curr_t:$t]" if ($debug); |
306 |
print bar($t); |
# print bar($t); |
307 |
} |
} |
308 |
|
|
309 |
print "</td></tr>\n" if ($curr_t != $from_t); |
# print "</td></tr>\n" if ($curr_t != $from_t); |
310 |
|
|
|
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}; |
|
|
} |
|
311 |
|
|
312 |
# init vars for next line |
# init vars for next line |
313 |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
314 |
print "<tr><td>", $row->{specification},"</td><td colspan=2>"; |
|
315 |
|
html_spec if ($curr_spec ne ""); |
316 |
|
|
317 |
$curr_t = $from_t; # init timeline |
$curr_t = $from_t; # init timeline |
318 |
$curr_spec = $row->{specification}; |
$curr_spec = $row->{specification}; |
319 |
|
|
320 |
|
@line_t = (); |
321 |
|
@line_arr = ( "" ); |
322 |
|
|
323 |
|
if ($dev && @dev_t && $dev ne $row->{device}) { |
324 |
|
sum_bar("summary for $dev",@dev_t); |
325 |
|
$dev = $row->{device}; |
326 |
|
@dev_t = (); |
327 |
|
} elsif (! $dev) { |
328 |
|
$dev = $row->{device}; |
329 |
|
} |
330 |
} |
} |
331 |
|
|
332 |
my $start_t = str2time($row->{start}); |
my $start_t = str2time($row->{start}); |
336 |
if ($start_t > $curr_t + ($len_t / $width)) { |
if ($start_t > $curr_t + ($len_t / $width)) { |
337 |
my $t = $start_t - $curr_t; |
my $t = $start_t - $curr_t; |
338 |
print STDERR "[middle filler $curr_t:$t]" if ($debug); |
print STDERR "[middle filler $curr_t:$t]" if ($debug); |
339 |
print bar($t); |
# print bar($t); |
340 |
$curr_t = $start_t; |
$curr_t = $start_t; |
341 |
} else { |
} else { |
342 |
# prepend too few seconds to next event |
# prepend too few seconds to next event |
369 |
$row->{type}." <b>".$row->{status}."</b><br>". |
$row->{type}." <b>".$row->{status}."</b><br>". |
370 |
$row->{user_group_host}." <i>".$row->{sessionid}."</i><br>". |
$row->{user_group_host}." <i>".$row->{sessionid}."</i><br>". |
371 |
$row->{device}." on ".$row->{host}; |
$row->{device}." on ".$row->{host}; |
372 |
print bar($len,$row->{status},$alt); |
# print bar($len,$row->{status},$alt); |
373 |
|
|
374 |
|
push @line_arr,$row->{status}."\t".$alt; |
375 |
# store use of devices for each minute |
# store use of devices for each minute |
376 |
for (my $s=0; $s<$len; $s++) { |
for (my $s=0; $s<$len; $s++) { |
377 |
|
$line_t[$curr_t-$from_t+$s] = $#line_arr; |
378 |
$dev_t[$curr_t-$from_t+$s]++; |
$dev_t[$curr_t-$from_t+$s]++; |
379 |
$dev_sum_t[$curr_t-$from_t+$s]++; |
$dev_sum_t[$curr_t-$from_t+$s]++; |
380 |
} |
} |
386 |
} |
} |
387 |
|
|
388 |
if ($curr_t == $from_t) { # no entries in database! |
if ($curr_t == $from_t) { # no entries in database! |
389 |
print "<tr><td></td><td colspan=2>"; |
# print "<tr><td></td><td colspan=2>"; |
390 |
} |
} |
391 |
|
|
392 |
if ($curr_t < $to_t ) { |
if ($curr_t < $to_t ) { |
393 |
my $t = $to_t - $curr_t; |
my $t = $to_t - $curr_t; |
394 |
print STDERR "[last_line filler $curr_t:$t]" if ($debug); |
print STDERR "[last_line filler $curr_t:$t]" if ($debug); |
|
print bar($t); |
|
395 |
} |
} |
396 |
|
|
397 |
undef $sth; |
undef $sth; |
398 |
$dbh->disconnect; |
$dbh->disconnect; |
399 |
|
|
400 |
print "</td></tr>\n"; |
html_spec(); |
401 |
sum_bar("summary for $dev",@dev_t); |
sum_bar("summary for $dev",@dev_t); |
402 |
hour_grid(); |
hour_grid(); |
403 |
sum_bar("summary for all devices",@dev_sum_t); |
sum_bar("summary for all devices",@dev_sum_t); |