5 eval '(exit $?0)' && eval 'exec @PERL@ -S $0 ${1+"$@"}'
6 & eval 'exec @PERL@ -S $0 $argv:q'
10 use lib '@amperldir@';
17 delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV', 'PATH'};
18 $ENV{'PATH'} = "/bin:/usr/bin:/usr/sbin:/sbin"; # force known path
20 $confdir="@CONFIG_DIR@";
22 $prefix=$prefix; # avoid warnings about possible typo
23 $exec_prefix="@exec_prefix@";
24 $exec_prefix=$exec_prefix; # ditto
27 my $Amanda_process = Amanda::Process->new(0);
28 $Amanda_process->load_ps_table();
50 my $opt_locale_independent_date_format;
53 print "amstatus [--file amdump_file]\n";
54 print " [--summary] [--dumping] [--waitdumping] [--waittaper]\n";
55 print " [--dumpingtape] [--writingtape] [--finished] [--failed]\n";
56 print " [--estimate] [--gestimate] [--stats] [--date]\n";
57 print " [--locale-independent-date-format]\n";
58 print " [--config] <config>\n";
62 Getopt::Long::Configure(qw{ bundling });
64 'summary' => \$opt_summary,
65 'stats|statistics' => \$opt_stats,
66 'dumping|d' => \$opt_dumping,
67 'waitdumping|wdumping' => \$opt_waitdumping,
68 'waittaper|wtaper' => \$opt_waittaper,
69 'dumpingtape|dtape' => \$opt_dumpingtape,
70 'writingtape|wtape' => \$opt_writingtape,
71 'finished' => \$opt_finished,
72 'failed|error' => \$opt_failed,
73 'estimate' => \$opt_estimate,
74 'gestimate|gettingestimate' => \$opt_gestimate,
76 'config|c:s' => \$opt_config,
77 'file:s' => \$opt_file,
78 'locale-independent-date-format' => \$opt_locale_independent_date_format,
82 if( defined $opt_config ) {
94 #untaint user input $ARGV[0]
96 if ($conf =~ /^([\w.-]+)$/) { # $1 is untainted
99 die "filename '$conf' has invalid characters.\n";
102 if ( ! -e "$confdir/$conf" ) {
103 print "Configuration directory '$confdir/$conf' doesn't exist\n";
106 if ( ! -d "$confdir/$conf" ) {
107 print "Configuration directory '$confdir/$conf' is not a directory\n";
114 chdir "$confdir/$conf";
116 $logdir=`$sbindir/amgetconf logdir`;
119 $errfile="$logdir/amdump";
121 $nb_options = defined( $opt_summary ) +
122 defined( $opt_stats ) +
123 defined( $opt_dumping ) +
124 defined( $opt_waitdumping ) +
125 defined( $opt_waittaper ) +
126 defined( $opt_dumpingtape ) +
127 defined( $opt_writingtape ) +
128 defined( $opt_finished ) +
129 defined( $opt_estimate ) +
130 defined( $opt_gestimate ) +
131 defined( $opt_failed );
133 if($nb_options == 0 ) {
137 $opt_waitdumping = 1;
139 $opt_dumpingtape = 1;
140 $opt_writingtape = 1;
147 $unit=`$sbindir/amgetconf displayunit`;
149 $unit =~ tr/A-Z/a-z/;
154 elsif($unit eq 'm') {
157 elsif($unit eq 'g') {
158 $unitdivisor = 1024*1024;
160 elsif($unit eq 't') {
161 $unitdivisor = 1024*1024*1024;
170 if( defined $opt_file) {
171 if( $opt_file =~ m,^/, ) {
172 $errfile = $opt_file;
174 $errfile = "$pwd/$opt_file";
175 $errfile = "$logdir/$opt_file" if ( ! (-f $errfile ));
179 $errfile="$logdir/amflush" if(! (-f $errfile));
181 if (-f "$logdir/amflush.1" && -f "$logdir/amdump.1" &&
182 -M "$logdir/amflush.1" < -M "$logdir/amdump.1") {
183 $errfile="$logdir/amflush.1";
185 $errfile="$logdir/amdump.1";
191 open(AMDUMP,"<$errfile") || die("$errfile: $!");
192 print "Using $errfile\n";
194 my $taper_status_file;
196 $start_degraded_mode = 0;
198 $label = ""; # -w fodder
199 $origsize = 0; # -w fodder
202 $status_taper = "Searching for a new tape";
206 @dumpers_active = ();
208 $ntpartition{$nb_tape} = 0;
209 $ntsize{$nb_tape} = 0;
210 $ntesize{$nb_tape} = 0;
212 $driver_finished = 0;
213 $generating_schedule = 0;
215 while($lineX = <AMDUMP>) {
217 $lineX =~ s/[:\s]+$//g; #remove separator at end of line
218 next if $lineX eq "";
219 @line = "ewords('[:\s]+', 0, $lineX);
220 next if !defined $line[0];
222 if($line[0] eq "amdump" || $line[0] eq "amflush") {
223 if ($line[1] eq "start" && $line[2] eq "at") {
225 $datestr =~ s/.*start at //g;
226 if (!defined $opt_locale_independent_date_format) {
227 print "From " . $datestr . "\n";
229 } elsif($line[1] eq "datestamp") {
230 $gdatestamp = $line[2];
231 if(!defined $datestamp{$gdatestamp}) {
232 $datestamp{$gdatestamp} = 1;
233 push @datestamp, $gdatestamp;
235 } elsif($line[1] eq "starttime") {
236 $starttime=&set_starttime($line[2]);
237 } elsif($line[1] eq "starttime-locale-independent") {
238 if (defined $opt_locale_independent_date_format) {
239 printf "From " . $line[2] . " " . $line[3] . ":" . $line[4] . ":" . $line[5] . " " . $line[6] . "\n";
242 if($line[0] eq "amflush") {
245 } elsif($line[0] eq "planner") {
246 if($line[1] eq "timestamp") {
247 $gdatestamp = $line[2];
248 if(!defined $datestamp{$gdatestamp}) {
249 $datestamp{$gdatestamp} = 1;
250 push @datestamp, $gdatestamp;
253 elsif($line[1] eq "FAILED") {
254 #2:host 3:disk 4:datestamp 5:level 6:errmsg
258 $hostpart=&make_hostpart($host,$partition,$datestamp);
259 $dump_started{$hostpart}=-1;
260 $level{$hostpart}=$line[5];
261 $error{$hostpart}="planner: " . $line[6];
262 } elsif($line[1] eq "time") {
263 if($line[3] eq "got") {
264 if($line[4] eq "result") {
266 $partition = $line[9];
267 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
268 $estimate{$hostpart}=1;
269 $level{$hostpart}=$line[10];
270 $line[12] =~ /(\d+)K/;
271 $esize{$hostpart}=$1 / $unitdivisor;
272 $partialestimate{$hostpart}=0;
273 $getest{$hostpart} = "";
274 } elsif($line[4] eq "partial") {
276 $partition = $line[10];
277 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
279 $line[13] =~ /(-?\d+)K/;
282 $line[16] =~ /(-?\d+)K/;
285 $line[19] =~ /(-?\d+)K/;
287 if($size1 > 0 || $size2 > 0 || $size3 > 0) {
288 $estimate{$hostpart}=1;
289 $level{$hostpart}=$line[11];
290 $esize{$hostpart}=$size1 / $unitdivisor;
291 $partialestimate{$hostpart}=1;
292 if($size1 > 0) { $getest{$hostpart} =~ s/:$level1://; }
293 if($size2 > 0) { $getest{$hostpart} =~ s/:$level2://; }
294 if($size3 > 0) { $getest{$hostpart} =~ s/:$level3://; }
295 if($getest{$hostpart} eq "") {$partialestimate{$hostpart}=0;}
298 } elsif($line[3] eq "getting" &&
299 $line[4] eq "estimates" &&
300 $line[5] eq "took") {
304 } elsif($line[0] eq "setup_estimate") {
306 $partition = $line[2];
307 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
308 $estimate{$hostpart}=0;
310 $degr_level{$hostpart}=-1;
312 $dump_started{$hostpart}=0;
313 $dump_finished{$hostpart}=0;
314 $taper_started{$hostpart}=0;
315 $taper_finished{$hostpart}=0;
316 $partialestimate{$hostpart}=0;
317 $error{$hostpart}="";
318 if($line[7] eq "last_level") {
319 $getest{$hostpart}="";
323 if($level1 != -1) { $getest{$hostpart} .= ":$level1:" };
324 if($level2 != -1) { $getest{$hostpart} .= ":$level2:" };
325 if($level3 != -1) { $getest{$hostpart} .= ":$level3:" };
327 } elsif($line[0] eq "GENERATING" &&
328 $line[1] eq "SCHEDULE") {
329 $generating_schedule=1;
330 } elsif($line[0] eq "--------") {
331 if ($generating_schedule == 1) {
332 $generating_schedule = 2;
333 } elsif ($generating_schedule == 2) {
334 $generating_schedule = 3;
336 } elsif($line[0] eq "DUMP") {
337 if($generating_schedule == 2 ) {
339 $partition = $line[3];
340 $datestamp = $line[4];
341 $hostpart=&make_hostpart($host,$partition,$datestamp);
342 $level{$hostpart}=$line[6];
343 $esize=$line[14]; #compressed size
344 $esize=32 if $esize<32;
345 $esize{$hostpart}=$esize / $unitdivisor;
346 if(!defined($line[25])) {
347 $degr_level{$hostpart}=-1;
349 $degr_level{$hostpart}=$line[17];
350 $esize=$line[25]; #compressed size
351 $esize=32 if $esize<32;
352 $degr_size{$hostpart}=$esize / $unitdivisor;
355 } elsif($line[0] eq "FLUSH") {
357 $partition = $line[2];
358 $datestamp = $line[3];
360 $holding_file = $line[5];
361 $hostpart=&make_hostpart($host,$partition,$datestamp);
363 $dump_finished{$hostpart}=0;
364 $holding_file{$hostpart}=$holding_file;
365 $level{$hostpart}=$level;
366 } elsif($line[0] eq "driver") {
367 if($line[1] eq "pid") {
369 if (! $Amanda_process->process_alive($pid, "driver")) {
373 elsif($line[1] eq "start" && $line[2] eq "time") {
374 $start_time=$line[3];
375 $current_time=$line[3];
376 $dumpers_active[0]=0;
380 elsif($line[1] eq "tape" && $line[2] eq "size") {
381 $lineX =~ /^driver: start time (\S+)/;
382 $tape_size = $line[3] / $unitdivisor;
384 elsif($line[1] eq "adding" &&
385 $line[2] eq "holding" &&
386 $line[3] eq "disk") {
387 $holding_space += $line[8];
389 elsif($line[1] eq "send-cmd" && $line[2] eq "time") {
390 #print "send-cmd: " , $line[5] . " " . $line[6] . " " . $line[7] . "\n" if defined $line[5] && defined $line[6] && defined $line[7];
391 $current_time = $line[3];
392 if($line[5] =~ /dumper\d*/) {
394 if($line[6] eq "PORT-DUMP") {
395 #7:handle 8:port 9:host 10:amfeatures 11:disk 12:device 13:level ...
397 $partition = $line[11];
398 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
400 $dump_started{$hostpart}=1;
401 $dump_time{$hostpart}=$current_time;
402 $dump_finished{$hostpart}=0;
403 if( $level{$hostpart} != $line[13] &&
404 $degr_level{$hostpart} == $line[13]) {
405 $level{$hostpart}=$degr_level{$hostpart};
406 $esize{$hostpart}=$degr_size{$hostpart};
408 if(! defined($busy_time{$dumper})) {
409 $busy_time{$dumper}=0;
411 $running_dumper{$dumper} = $hostpart;
412 $error{$hostpart}="";
413 $size{$hostpart} = 0;
415 if(! defined($dumpers_active[$dumpers_active])) {
416 $dumpers_active[$dumpers_active]=0;
418 if(! defined($dumpers_held[$dumpers_active])) {
419 $dumpers_held[$dumpers_active]={};
423 elsif($line[5] =~ /chunker\d*/) {
424 if($line[6] eq "PORT-WRITE") {
426 $partition=$line[11];
427 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
429 $serial{$serial}=$hostpart;
430 $holding_file{$hostpart}=$line[8];
431 #$chunk_started{$hostpart}=1;
432 $chunk_time{$hostpart}=$current_time;
433 #$chunk_finished{$hostpart}=0;
434 $size{$hostpart} = 0;
436 elsif($line[6] eq "CONTINUE") {
437 #7:handle 8:filename 9:chunksize 10:use
439 $hostpart=$serial{$serial};
440 if($hostpart ne "") {
441 $dump_roomq{$hostpart}=undef;
442 $error{$hostpart}="";
446 elsif($line[5] =~ /taper/) {
447 if($line[6] eq "START-TAPER") {
449 $gdatestamp=$line[8];
450 if(!defined $datestamp{$gdatestamp}) {
451 $datestamp{$gdatestamp} = 1;
452 push @datestamp, $gdatestamp;
454 $status_taper = "Searching for a new tape";
456 elsif($line[6] eq "NEW-TAPE") {
458 $status_taper = "Searching for a new tape";
460 elsif($line[6] eq "NO-NEW-TAPE") {
461 #7:name 8:handle 9:errmsg
464 $status_taper = $error;
466 elsif($line[6] eq "FILE-WRITE") {
467 #7:name 8:handle 9:filename 10:host 11:disk 12:level 13:datestamp 14:splitsize
470 $partition=$line[11];
472 $ldatestamp=$line[13];
473 $status_taper = "Writing $host:$partition";
474 if(!defined $datestamp{$ldatestamp}) {
475 $datestamp{$ldatestamp} = 1;
476 push @datestamp, $ldatestamp;
478 $hostpart=&make_hostpart($host,$partition,$ldatestamp);
479 $serial{$serial}=$hostpart;
480 if(!defined $level{$hostpart}) {
481 $level{$hostpart} = $level;
483 $taper_started{$hostpart}=1;
484 $taper_finished{$hostpart}=0;
485 $taper_time{$hostpart}=$current_time;
488 elsif($line[6] eq "PORT-WRITE") {
489 #7:name 8:handle 9:host 10:disk 11:level 12:datestamp 13:splitsize 14:diskbuffer 15:fallback_splitsize
492 $partition=$line[10];
494 $ldatestamp=$line[12];
495 $status_taper = "Writing $host:$partition";
496 $hostpart=&make_hostpart($host,$partition,$ldatestamp);
497 $serial{$serial}=$hostpart;
498 $taper_started{$hostpart}=1;
499 $taper_finished{$hostpart}=0;
500 $taper_time{$hostpart}=$current_time;
501 $size{$hostpart} = 0;
506 elsif($line[1] eq "result" && $line[2] eq "time") {
507 #print "result: " , $line[5] . " " . $line[6] . " " . $line[7] . "\n" if defined $line[5] && defined $line[6] && defined $line[7];
508 $current_time = $line[3];
509 if($line[5] =~ /dumper\d+/) {
510 if($line[6] eq "FAILED" || $line[6] eq "TRY-AGAIN") {
514 $hostpart=$serial{$serial};
515 if ($taper_started{$hostpart} == 1) {
516 $dump_finished{$hostpart}=-1;
518 $dump_finished{$hostpart}=-3;
520 $busy_time{$line[5]}+=($current_time-$dump_time{$hostpart});
521 $running_dumper{$line[5]} = "0";
522 $dump_time{$hostpart}=$current_time;
523 $error{$hostpart}="dumper: $error";
527 elsif($line[6] eq "DONE") {
528 #7:handle 8:origsize 9:size ...
530 $origsize=$line[8] / $unitdivisor;
531 $outputsize=$line[9] / $unitdivisor;
532 $hostpart=$serial{$serial};
533 $size{$hostpart}=$outputsize;
534 $dump_finished{$hostpart}=1;
535 $busy_time{$line[5]}+=($current_time-$dump_time{$hostpart});
536 $running_dumper{$line[5]} = "0";
537 $dump_time{$hostpart}=$current_time;
538 $error{$hostpart}="";
541 elsif($line[6] eq "ABORT-FINISHED") {
544 $hostpart=$serial{$serial};
545 $dump_started{$hostpart}=0;
546 if ($taper_started{$hostpart} == 1) {
547 $dump_finished{$hostpart}=-1;
549 $dump_finished{$hostpart}=-3;
551 $busy_time{$line[5]}+=($current_time-$dump_time{$hostpart});
552 $running_dumper{$line[5]} = "0";
553 $dump_time{$hostpart}=$current_time;
554 $error{$hostpart}="dumper: (aborted)";
558 elsif($line[5] =~ /chunker\d+/) {
559 if($line[6] eq "DONE" || $line[6] eq "PARTIAL") {
562 $outputsize=$line[8] / $unitdivisor;
563 $hostpart=$serial{$serial};
564 $size{$hostpart}=$outputsize;
565 if ($line[6] eq "DONE") {
566 $dump_finished{$hostpart}=1;
568 $dump_finished{$hostpart}=-3;
570 $busy_time{$line[5]}+=($current_time-$chunk_time{$hostpart});
571 $running_dumper{$line[5]} = "0";
572 $chunk_time{$hostpart}=$current_time;
573 if ($line[6] eq "PARTIAL") {
574 $partial{$hostpart} = 1;
577 $partial{$hostpart} = 0;
578 $error{$hostpart}="";
581 elsif($line[6] eq "FAILED") {
583 $hostpart=$serial{$serial};
584 $dump_finished{$hostpart}=-1;
585 $busy_time{$line[5]}+=($current_time-$chunk_time{$hostpart});
586 $running_dumper{$line[5]} = "0";
587 $chunk_time{$hostpart}=$current_time;
588 $error{$hostpart}="chunker: " .$line[8] if $error{$hostpart} eq "";
590 elsif($line[6] eq "RQ-MORE-DISK") {
593 $hostpart=$serial{$serial};
594 $dump_roomq{$hostpart}=1;
595 $error{$hostpart}="(waiting for holding disk space)";
598 elsif($line[5] eq "taper") {
599 if($line[6] eq "DONE" || $line[6] eq "PARTIAL") {
600 #7:handle 8:label 9:filenum 10:errstr
603 $status_taper = "Idle";
604 $hostpart=$serial{$serial};
605 $line[10] =~ /sec (\S+) (kb|bytes) (\d+) kps/;
607 $size=$3 / $unitdivisor;
609 $size=$3 / ( $unitdivisor * 1024);
611 $taper_finished{$hostpart}=1;
612 $busy_time{"taper"}+=($current_time-$taper_time{$hostpart});
613 $taper_time{$hostpart}=$current_time;
614 if(!defined $size{$hostpart}) {
615 $size{$hostpart}=$size;
617 $ntpartition{$nb_tape}++;
618 $ntsize{$nb_tape} += $size{$hostpart} - $ntchunk_size;
619 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
620 $ntesize{$nb_tape} += $esize{$hostpart} - $ntchunk_size;
623 $ntesize{$nb_tape} += $size{$hostpart} - $ntchunk_size;
625 if ($line[6] eq "PARTIAL") {
626 $partial{$hostpart} = 1;
629 $partial{$hostpart} = 0;
631 if ($ntchunk_size > 0) {
632 $ntchunk{$nb_tape}++;
634 undef $taper_status_file;
636 elsif($line[6] eq "PARTDONE") {
637 #7:handle 8:label 9:filenum 10:ksize 11:errstr
639 $hostpart=$serial{$serial};
640 #$line[11] =~ /.*kb (\d*) kps/;
641 #$size=$1 / $unitdivisor;
642 $size=$line[10] / $unitdivisor;
643 $tapedsize{$hostpart} += $size;
644 $ntchunk{$nb_tape}++;
645 $ntsize{$nb_tape} += $size;
646 $ntesize{$nb_tape} += $size;
647 $ntchunk_size += $size;
649 elsif($line[6] eq "REQUEST-NEW-TAPE") {
652 $old_status_taper = $status_taper;
653 $status_taper = "Asking for a new tape";
654 $hostpart=$serial{$serial};
655 if (defined $hostpart) {
656 $olderror{$hostpart} = $error{$hostpart};
657 $error{$hostpart} = "waiting for a new tape";
660 elsif($line[6] eq "NEW-TAPE") {
663 $status_taper = $old_status_taper;
664 $hostpart=$serial{$serial};
665 if (defined $hostpart) {
666 $error{$hostpart} = $olderror{$hostpart};
669 elsif($line[6] eq "TAPER-OK") {
671 $status_taper = "Idle";
673 elsif($line[6] eq "TAPE-ERROR") {
676 $status_taper = $error;
677 $exit_status |= $STATUS_TAPE;
678 undef $taper_status_file;
680 elsif($line[6] eq "FAILED") {
681 #7:handle 8:INPUT- 9:TAPE- 10:input_message 11:tape_message
683 $hostpart=$serial{$serial};
684 if(defined $hostpart) {
685 if($line[9] eq "TAPE-ERROR") {
687 $taper_finished{$hostpart} = -2;
688 $status_taper = $error;
692 $taper_finished{$hostpart} = -1;
693 $status_taper = "Idle";
695 $busy_time{"taper"}+=($current_time-$taper_time{$hostpart});
696 $taper_time{$hostpart}=$current_time;
697 $error{$hostpart}="$error";
699 undef $taper_status_file;
703 elsif($line[1] eq "finished-cmd" && $line[2] eq "time") {
704 $current_time=$line[3];
705 if($line[4] =~ /dumper\d+/) {
708 elsif($line[1] eq "dump" && $line[2] eq "failed") {
709 #3:handle 4: 5: 6:"too many dumper retry"
711 $hostpart=$serial{$serial};
712 $dump_started{$hostpart}=-1;
713 $dump_finished{$hostpart}=-2;
714 $error{$hostpart} .= "(" . $line[6] . ")";
716 elsif($line[1] eq "tape" && $line[2] eq "failed") {
717 #3:handle 4: 5: 6:"too many dumper retry"
719 $hostpart=$serial{$serial};
720 $taper_started{$hostpart}=-1;
721 $taper_finished{$hostpart}=-2;
722 $error{$hostpart} .= "(" . $line[6] . ")";
724 elsif($line[1] eq "state" && $line[2] eq "time") {
725 #3:time 4:"free" 5:"kps" 6:free 7:"space" 8:space 9:"taper" 10:taper 11:"idle-dumpers" 12:idle-dumpers 13:"qlen" 14:"tapeq" 15:tapeq 16:"runq" 17:runq 18:"roomq" 19:roomq 20:"wakeup" 21:wakeup 22:"driver-idle" 23:driver-idle
726 $current_time=$line[3];
727 $idle_dumpers=$line[12];
729 $free{"kps"} = $line[6];
730 $free{"space"} = $line[8];
731 $qlen{"tapeq"} = $line[15];
732 $qlen{"runq"} = $line[17];
733 $qlen{"roomq"} = $line[19];
735 if(defined($dumpers_active)) {
736 if($status_driver ne "") {
737 $dumpers_active[$dumpers_active_prev]
738 +=$current_time-$state_time_prev;
739 $dumpers_held[$dumpers_active_prev]{$status_driver}
740 +=$current_time-$state_time_prev;
742 $state_time_prev=$current_time;
743 $dumpers_active_prev=$dumpers_active;
744 $status_driver=$line[23];
745 if(! defined($dumpers_held[$dumpers_active]{$status_driver})) {
746 $dumpers_held[$dumpers_active]{$status_driver}=0;
750 elsif($line[1] eq "FINISHED") {
751 $driver_finished = 1;
754 elsif($line[0] eq "dump") {
755 if($line[1] eq "of" &&
756 $line[2] eq "driver" &&
757 $line[3] eq "schedule" &&
758 $line[4] eq "after" &&
759 $line[5] eq "start" &&
760 $line[6] eq "degraded" &&
761 $line[7] eq "mode") {
762 $start_degraded_mode=1;
765 elsif($line[0] eq "taper") {
766 if($line[1] eq "wrote") {
767 #1:"wrote" 2:"label" 3:label
770 $ntlabel{$nb_tape} = $label;
771 $ntpartition{$nb_tape} = 0;
772 $ntsize{$nb_tape} = 0;
773 $ntesize{$nb_tape} = 0;
775 elsif($line[1] eq "status" && $line[2] eq "file") {
776 #1:"status" #2:"file:" #3:hostname #4:diskname #5:filename
777 $taper_status_file = $line[5];
780 elsif($line[0] eq "splitting" &&
781 $line[1] eq "chunk" &&
782 $line[2] eq "that" &&
783 $line[3] eq "started" &&
785 $line[6] eq "after") {
786 $line[7] =~ /(\d*)kb/;
788 $ntchunk{$nb_tape}++;
789 $ntsize{$nb_tape} += $size / $unitdivisor;
790 $ntesize{$nb_tape} += $size / $unitdivisor;
791 $ntchunk_size += $size / $unitdivisor;
794 #print "Ignoring: $lineX\n";
800 if(defined $current_time) {
801 for ($d = 0; $d < $#dumpers_active; $d++) {
802 $the_dumper = "dumper$d";
803 if(defined($running_dumper{$the_dumper}) &&
804 $running_dumper{$the_dumper} ne "0") {
805 $busy_time{$the_dumper}+=($current_time-$dump_time{$running_dumper{$the_dumper}});
849 foreach $host (sort @hosts) {
850 foreach $partition (sort @$host) {
851 foreach $datestamp (sort @datestamp) {
852 $hostpart=&make_hostpart($host,$partition,$datestamp);
853 next if(!defined $estimate{$hostpart} && !defined $flush{$hostpart});
854 if(length("$host:$partition") > $maxnamelength) {
855 $maxnamelength = length("$host:$partition");
861 foreach $host (sort @hosts) {
862 foreach $partition (sort @$host) {
863 $qpartition = Amanda::Util::quote_string($partition);
864 foreach $datestamp (sort @datestamp) {
865 $hostpart=&make_hostpart($host,$partition,$datestamp);
866 next if(!defined $estimate{$hostpart} && !defined $flush{$hostpart});
868 if( (!defined $size{$hostpart} || $size{$hostpart} == 0) &&
869 defined $holding_file{$hostpart}) {
870 $size{$hostpart} = &dump_size($holding_file{$hostpart}) / (1024 * $unitdivisor);
873 if($estimate_done != 1 && !defined $flush{$hostpart}) {
874 if(defined $estimate{$hostpart}) {
875 if($estimate{$hostpart} != 1) {
876 if( defined $opt_gestimate ||
877 defined $opt_failed && $dead_run != 0) {
878 printf "%8s ", $datestamp if defined $opt_date;
879 printf "%-${maxnamelength}s", "$host:$qpartition";
882 print " failed: killed while";
883 $exit_status |= $STATUS_FAILED;
885 print " getting estimate\n";
889 if(defined $opt_estimate ||
890 (defined $opt_gestimate && $partialestimate{$hostpart} == 1) ||
891 (defined $opt_failed && $dead_run != 0 && $partialestimate{$hostpart} == 1)) {
892 printf "%8s ", $datestamp if defined $opt_date;
893 printf "%-${maxnamelength}s", "$host:$qpartition";
894 printf "%2d ", $level{$hostpart};
895 printf "%9d$unit", $esize{$hostpart};
896 if($partialestimate{$hostpart} == 1) {
898 print " failed: killed while";
899 $exit_status |= $STATUS_FAILED;
903 print " estimate done\n";
906 $estsize += $esize{$hostpart};
911 if(defined $estimate{$hostpart}) {
912 if($estimate{$hostpart} == 1) {
914 $estsize += $esize{$hostpart};
916 elsif (!defined $dump_started{$hostpart} || $dump_started{$hostpart} == 0) {
917 if( defined $opt_failed) {
918 printf "%8s ", $datestamp if defined $opt_date;
919 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
920 printf " no estimate\n";
922 $exit_status |= $STATUS_FAILED;
924 $fsize+=$esize{$hostpart};
929 $flsize += $size{$hostpart};
932 if(defined $taper_started{$hostpart} &&
933 $taper_started{$hostpart}==1 &&
934 $dump_finished{$hostpart}!=-3) {
935 if(defined $dump_started{$hostpart} &&
936 $dump_started{$hostpart} == 1 &&
937 $dump_finished{$hostpart} == -1) {
938 if(defined $opt_failed) {
939 printf "%8s ", $datestamp if defined $opt_date;
940 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
941 printf "%9d$unit", $esize{$hostpart};
942 print " dump to tape failed: " . $error{$hostpart};
945 $exit_status |= $STATUS_FAILED;
947 $fsize+=$esize{$hostpart};
948 } elsif(defined $dump_started{$hostpart} &&
949 $dump_started{$hostpart} == 1 &&
950 $dump_finished{$hostpart} == 0 &&
951 $taper_started{$hostpart} == 1) {
952 if( defined $opt_dumpingtape ||
953 defined $opt_failed && $dead_run != 0) {
954 printf "%8s ", $datestamp if defined $opt_date;
955 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
956 printf "%9d$unit", $esize{$hostpart};
958 print " failed: killed while";
959 $exit_status |= $STATUS_FAILED;
961 print " dumping to tape";
962 $size = $tapedsize{$hostpart};
963 if ($taper_status_file && -f $taper_status_file &&
964 open FF, "<$taper_status_file") {
968 $value = $line / ($unitdivisor * 1024);
970 $size = $value if (!defined($size) || $value > $size);
976 printf " (%d$unit done (%0.2f%%))", $size, 100.0 * $size/$esize{$hostpart};
979 if( defined $starttime ) {
980 print " (", &showtime($taper_time{$hostpart}), ")";
985 $dtesize += $esize{$hostpart};
987 elsif($taper_finished{$hostpart} == 0) {
988 if( defined $opt_writingtape ||
989 defined $opt_failed && $dead_run != 0) {
990 printf "%8s ", $datestamp if defined $opt_date;
991 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
992 printf "%9d$unit", $size{$hostpart};
994 print " failed: killed while";
995 $exit_status |= $STATUS_FAILED;
998 print " writing to tape";
1001 print " flushing to tape";
1003 $size = $tapedsize{$hostpart};
1004 if ($taper_status_file && -f $taper_status_file &&
1005 open FF, "<$taper_status_file") {
1007 if (defined $line) {
1009 $value = $line / ($unitdivisor * 1024);
1011 $size = $value if (!defined($size) || $value > $size);
1016 if(defined($size)) {
1017 printf " (%d$unit done (%0.2f%%))", $size, 100.0 * $size/$size{$hostpart};
1019 if( defined $starttime ) {
1020 print " (", &showtime($taper_time{$hostpart}), ")";
1022 print ", ", $error{$hostpart} if (defined($error{$hostpart}) &&
1023 $error{$hostpart} ne "");
1027 $tasize += $size{$hostpart};
1028 if(defined $esize{$hostpart}) {
1029 $taesize += $esize{$hostpart};
1032 $taesize += $size{$hostpart};
1034 if (defined $dump_finished{$hostpart} && $dump_finished{$hostpart} == 1) {
1036 $dsize += $size{$hostpart};
1037 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
1038 $desize += $esize{$hostpart};
1040 $desize += $size{$hostpart};
1044 elsif($taper_finished{$hostpart} < 0) {
1046 if(defined $size{$hostpart}) {
1047 $xsize = $size{$hostpart};
1049 elsif(defined $esize{$hostpart}) {
1050 $xsize = $esize{$hostpart};
1056 if(defined $esize{$hostpart}) {
1057 $exsize += $esize{$hostpart};
1063 if( defined $opt_failed ||
1064 (defined $opt_waittaper && ($taper_finished{$hostpart} == -1))) {
1065 printf "%8s ", $datestamp if defined $opt_date;
1066 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1067 printf "%9d$unit", $xsize;
1068 if($in_flush == 0) {
1069 print " failed to tape";
1072 print " failed to flush";
1074 print ": ",$error{$hostpart} if defined $error{$hostpart};
1076 print " (will retry)" unless $taper_finished{$hostpart} < -1;
1077 if( defined $starttime ) {
1078 print " (", &showtime($taper_time{$hostpart}), ")";
1082 $exit_status |= $STATUS_TAPE;
1086 $tfesize += $exsize;
1088 if($in_flush == 0) {
1091 $twesize += $exsize;
1097 if (defined $dump_finished{$hostpart} && $dump_finished{$hostpart} == 1) {
1099 $dsize += $size{$hostpart};
1100 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
1101 $desize += $esize{$hostpart};
1103 $desize += $size{$hostpart};
1107 elsif($taper_finished{$hostpart} == 1) {
1108 if( defined $opt_finished ) {
1109 printf "%8s ", $datestamp if defined $opt_date;
1110 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1111 printf "%9d$unit", $size{$hostpart};
1112 if($in_flush == 0) {
1118 if( defined $starttime ) {
1119 print " (", &showtime($taper_time{$hostpart}), ")";
1121 if(defined $partial{$hostpart} && $partial{$hostpart} == 1) {
1123 $exit_status |= $STATUS_FAILED;
1127 if (defined $dump_finished{$hostpart} && $dump_finished{$hostpart} == 1) {
1129 $dsize += $size{$hostpart};
1130 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
1131 $desize += $esize{$hostpart};
1133 $desize += $size{$hostpart};
1137 $tsize += $size{$hostpart};
1138 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
1139 $tesize += $esize{$hostpart};
1142 $tesize += $size{$hostpart};
1146 printf "%8s ", $datestamp if defined $opt_date;
1147 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1148 print " unknown state TAPER\n";
1151 elsif(defined $dump_started{$hostpart}) {
1152 if($dump_started{$hostpart} == -1) {
1153 if( defined $opt_failed ) {
1154 printf "%8s ", $datestamp if defined $opt_date;
1155 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1156 printf "failed: " . $error{$hostpart} . "\n";
1158 $exit_status |= $STATUS_FAILED;
1161 $fsize+=$esize{$hostpart};
1163 elsif($dump_started{$hostpart} == 0) {
1164 if($estimate{$hostpart} == 1) {
1165 if( defined $opt_waitdumping ) {
1166 printf "%8s ", $datestamp if defined $opt_date;
1167 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1168 printf "%9d$unit", $esize{$hostpart};
1170 print " failed: process terminated while";
1171 $exit_status |= $STATUS_FAILED;
1173 print " waiting for dumping $error{$hostpart}\n";
1175 if($driver_finished == 1) {
1176 $exit_status |= $STATUS_MISSING;
1179 $wsize += $esize{$hostpart};
1182 elsif($dump_started{$hostpart} == 1 &&
1183 ($dump_finished{$hostpart} == -1 ||
1184 $dump_finished{$hostpart} == -3)) {
1185 if( defined $opt_failed ) {
1186 printf "%8s ", $datestamp if defined $opt_date;
1187 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1188 print "backup failed: ", $error{$hostpart};
1189 if( defined $starttime ) {
1190 print " (", &showtime($dump_time{$hostpart}), ")";
1194 $exit_status |= $STATUS_FAILED;
1196 $fsize+=$esize{$hostpart};
1198 elsif($dump_started{$hostpart} == 1 &&
1199 $dump_finished{$hostpart} == 0) {
1200 if( defined $opt_dumping ||
1201 defined $opt_failed && $dead_run != 0) {
1202 printf "%8s ", $datestamp if defined $opt_date;
1203 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1204 printf "%9d$unit", $esize{$hostpart};
1206 print " failed: killed while";
1207 $exit_status |= $STATUS_FAILED;
1209 printf " dumping %8d$unit", $size{$hostpart};
1210 if($size{$hostpart} != 0) {
1211 printf " (%6.2f%%)", (100.0*$size{$hostpart})/$esize{$hostpart};
1213 if( defined $starttime ) {
1214 print " (", &showtime($dump_time{$hostpart}), ")";
1216 if(defined $dump_roomq{$hostpart}) {
1217 print " " . $error{$hostpart};
1222 $dusize += $size{$hostpart};
1223 $duesize += $esize{$hostpart};
1225 elsif($dump_finished{$hostpart} == 1 &&
1226 $taper_started{$hostpart} != 1) {
1227 if( defined $opt_waittaper ) {
1228 printf "%8s ", $datestamp if defined $opt_date;
1229 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1230 printf "%9d$unit", $size{$hostpart};
1232 if( defined $starttime ) {
1233 print " (", &showtime($dump_time{$hostpart}), ")";
1237 print " process terminated while";
1239 print " waiting for writing to tape";
1240 if(defined $partial{$hostpart} && $partial{$hostpart} == 1) {
1242 $exit_status |= $STATUS_FAILED;
1247 $dsize += $size{$hostpart};
1248 $desize += $esize{$hostpart};
1250 $twsize += $size{$hostpart};
1251 $twesize += $esize{$hostpart};
1254 printf "%8s ", $datestamp if defined $opt_date;
1255 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1256 print " unknown state DUMPER\n";
1259 elsif(defined $flush{$hostpart}) {
1260 if( defined $opt_waittaper ) {
1261 printf "%8s ", $datestamp if defined $opt_date;
1262 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1263 printf "%9d$unit", $size{$hostpart};
1265 print " process terminated while";
1267 print " waiting to flush";
1268 if(defined $partial{$hostpart} && $partial{$hostpart} == 1) {
1270 $exit_status |= $STATUS_FAILED;
1275 $wfsize += $size{$hostpart};
1277 elsif(defined $level{$hostpart}) {
1278 printf "%8s ", $datestamp if defined $opt_date;
1279 printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
1280 print " unknown state\n";
1287 if (defined $opt_summary) {
1289 print "SUMMARY part real estimated\n";
1290 print " size size\n";
1291 printf "partition : %3d\n", $nb_partition;
1292 printf "estimated : %3d %20d$unit\n", $epartition , $estsize;
1293 printf "flush : %3d %9d$unit\n", $flpartition, $flsize;
1294 printf "failed : %3d %20d$unit (%6.2f%%)\n",
1295 $fpartition , $fsize,
1296 $estsize ? ($fsize * 1.0 / $estsize) * 100 : 0.0;
1297 printf "wait for dumping: %3d %20d$unit (%6.2f%%)\n",
1298 $wpartition , $wsize,
1299 $estsize ? ($wsize * 1.0 / $estsize) * 100 : 0.0;
1300 if(defined($dtsize)) {
1301 printf "dumping to tape : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1302 $dtpartition, $dtsize, $dtesize,
1303 $dtsize ? ($dtsize * 1.0 / $dtesize) * 100 : 0.0,
1304 $estsize ? ($dtesize * 1.0 / $estsize) * 100 : 0.0;
1306 printf "dumping to tape : %3d %20d$unit (%6.2f%%)\n",
1307 $dtpartition, $dtesize,
1308 $estsize ? ($dtesize * 1.0 / $estsize) * 100 : 0.0;
1310 printf "dumping : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1311 $dupartition, $dusize, $duesize,
1312 $duesize ? ($dusize * 1.0 / $duesize) * 100 : 0.0,
1313 $estsize ? ($dusize * 1.0 / $estsize) * 100 : 0.0;
1314 printf "dumped : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1315 $dpartition , $dsize , $desize,
1316 $desize ? ($dsize * 1.0 / $desize) * 100 : 0.0,
1317 $estsize ? ($dsize * 1.0 / $estsize) * 100 : 0.0;
1318 printf "wait for writing: %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1319 $twpartition, $twsize, $twesize,
1320 $twesize ? ($twsize * 1.0 / $twesize) * 100 : 0.0,
1321 $estsize ? ($twsize * 1.0 / $estsize) * 100 : 0.0;
1322 printf "wait to flush : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1323 $wfpartition, $wfsize, $wfsize, 100, 0;
1324 printf "writing to tape : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1325 $tapartition, $tasize, $taesize,
1326 $taesize ? ($tasize * 1.0 / $taesize) * 100 : 0.0,
1327 $estsize ? ($tasize * 1.0 / $estsize) * 100 : 0.0;
1328 printf "failed to tape : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1329 $tfpartition, $tfsize, $tfesize,
1330 $tfesize ? ($tfsize * 1.0 / $tfesize) * 100 : 0.0,
1331 $estsize ? ($tfsize * 1.0 / $estsize) * 100 : 0.0;
1332 printf "taped : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1333 $tpartition , $tsize , $tesize,
1334 $tesize ? ($tsize * 1.0 / $tesize) * 100 : 0.0,
1335 ($estsize+$flsize) ? ($tsize * 1.0 / ($estsize + $flsize)) * 100 : 0.0;
1336 if($nb_tape > 1 || $tape_size != 0) {
1337 for($i=1; $i <= $nb_tape; $i++) {
1338 if($tape_size != 0) {
1339 printf " tape %-3d : %3d %9d$unit %9d$unit (%6.2f%%) %s",
1340 $i, $ntpartition{$i}, $ntsize{$i}, $ntesize{$i}, 100*$ntsize{$i}/$tape_size, $ntlabel{$i};
1343 printf " tape %-3d : %3d %9d$unit %9d$unit %s",
1344 $i, $ntpartition{$i}, $ntsize{$i}, $ntesize{$i}, $ntlabel{$i};
1346 if(defined($ntchunk{$i}) && $ntchunk{$i} > 0) {
1347 printf " (%d chunks)", $ntchunk{$i};
1352 if($idle_dumpers == 0) {
1353 printf "all dumpers active\n";
1356 $c1 = ($idle_dumpers == 1) ? "" : "s";
1357 $c2 = ($idle_dumpers < 10) ? " " : "";
1358 $c3 = ($idle_dumpers == 1) ? " " : "";
1359 printf "%d dumper%s idle%s %s: %s\n", $idle_dumpers, $c1, $c2, $c3, $status_driver;
1362 printf "taper status: $status_taper\n";
1363 if (defined $qlen{"tapeq"}) {
1364 printf "taper qlen: %d\n", $qlen{"tapeq"};
1366 if (defined ($free{"kps"})) {
1367 printf "network free kps: %9d\n", $free{"kps"};
1369 if (defined ($free{"space"})) {
1370 if ($holding_space) {
1371 $hs = ($free{"space"} * 1.0 / $holding_space) * 100;
1375 printf "holding space : %9d$unit (%6.2f%%)\n", ($free{"space"}/$unitdivisor), $hs;
1379 if(defined $opt_stats) {
1380 if(defined($current_time) && $current_time != $start_time) {
1381 $total_time=$current_time-$start_time;
1382 foreach $key (sort byprocess keys %busy_time) {
1383 printf "%8s busy : %8s (%6.2f%%)\n",
1384 $key, &busytime($busy_time{$key}),
1385 ($busy_time{$key} * 1.0 / $total_time) * 100;
1387 for ($d = 0; $d <= $#dumpers_active; $d++) {
1388 $l = sprintf "%2d dumper%s busy%s : %8s (%6.2f%%)",
1389 $d, ($d == 1) ? "" : "s", ($d == 1) ? " " : "",
1390 &busytime($dumpers_active[$d]),
1391 ($dumpers_active[$d] * 1.0 / $total_time) * 100;
1394 $s2 = " " x length($l);
1395 $r = $dumpers_held[$d];
1396 foreach $key (sort valuesort keys %$r) {
1398 unless $dumpers_held[$d]{$key} >= 1;
1399 printf "%s%20s: %8s (%6.2f%%)\n",
1402 &busytime($dumpers_held[$d]{$key}),
1403 ($dumpers_held[$d]{$key} * 1.0 / $dumpers_active[$d]) * 100;
1415 sub make_hostpart() {
1416 local($host,$partition,$datestamp) = @_;
1418 if(! defined($hosts{$host})) {
1423 foreach $pp (sort @$host) {
1424 $new_part = 0 if ($pp eq $partition);
1426 push @$host, $partition if $new_part==1;
1428 my($hostpart) = "$host$partition$datestamp";
1429 if(!defined $datestamp{$datestamp}) {
1430 $datestamp{$datestamp} = 1;
1431 push @datestamp, $datestamp;
1438 my(@tmp_a) = split(/(\d*)$/, $a, 2);
1439 my(@tmp_b) = split(/(\d*)$/, $b, 2);
1440 return ($tmp_a[0] cmp $tmp_b[0]) || ($tmp_a[1] <=> $tmp_b[1]);
1444 $r->{$b} <=> $r->{$a};
1448 local($filename) = @_;
1451 local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
1452 $atime,$mtime,$ctime,$blksize,$blocks);
1453 while ($filename ne "") {
1454 $filename = "$filename.tmp" if (!(-e "$filename"));
1455 $filename = "/dev/null" if (!(-e "$filename"));
1456 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
1457 $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
1458 $size=$size-32768 if $size > 32768;
1460 open(DUMP,$filename);
1463 if(/^CONT_FILENAME=(.*)$/) { $filename = $1; last }
1464 last if /^To restore, position tape at start of file and run/;
1479 @MoY = ('Jan','Feb','Mar','Apr','May','Jun',
1480 'Jul','Aug','Sep','Oct','Nov','Dec');
1482 # Preset an array of values in case some parts are not passed as
1483 # arguments. This lets the date, etc, be omitted and default to
1492 # See if this argument looks like a month name.
1498 $month = $month + 1;
1505 # See if this is a day of the month.
1507 if ($a =~ /^\d+$/ && $a >= 1 && $a <= 32) {
1512 # See if the next argument looks like a time.
1514 if ($a =~ /^(\d+):(\d+)/) {
1517 if ($a =~ /^(\d+):(\d+):(\d+)/) {
1523 # See if this is a year.
1525 if ($a =~ /^\d\d\d\d$/ && $a >= 1900) {
1531 $time = &timelocal (@tl);
1536 sub set_starttime() {
1541 # Preset an array of values in case some parts are not passed as
1542 # arguments. This lets the date, etc, be omitted and default to
1548 $tl[5] = substr($date, 0, 4) if(length($date) >= 4);
1549 $tl[4] = substr($date, 4, 2)-1 if(length($date) >= 6);
1550 $tl[3] = substr($date, 6, 2) if(length($date) >= 8);
1551 $tl[2] = substr($date, 8, 2) if(length($date) >= 10);
1552 $tl[1] = substr($date, 10, 2) if(length($date) >= 12);
1553 $tl[0] = substr($date, 12, 2) if(length($date) >= 14);
1555 $time = &timelocal (@tl);
1563 my($oneday)=24*60*60;
1565 @now=localtime($starttime+$delta);
1566 if($delta > $oneday) {
1567 $result=sprintf("%d+",$delta/$oneday);
1571 $result.=sprintf("%d:%02d:%02d",$now[2],$now[1],$now[0]);
1577 my($oneday)=24*60*60;
1579 if($busy > $oneday) {
1580 $days=int($busy/$oneday);
1581 $result=sprintf("%d+",$busy/$oneday);
1582 $busy-=$days*$oneday;
1586 $hours=int($busy/60/60);
1587 $busy-=$hours*60*60;
1588 $minutes=int($busy/60);
1591 $result.=sprintf("%d:%02d:%02d",$hours,$minutes,$seconds);