📄 amstatus.pl
字号:
$exit_status |= $STATUS_TAPE; $tfpartition++; $tfsize += $xsize; $tfesize += $exsize; if($in_flush == 0) { $twpartition++; $twsize += $xsize; $twesize += $exsize; } else { $wfpartition++; $wfsize += $xsize; } } elsif($taper_finished{$hostpart} == 1) { if( defined $opt_finished ) { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; printf "%9d$unit", $size{$hostpart}; if($in_flush == 0) { print " finished"; } else { print " flushed"; } if( defined $starttime ) { print " (", &showtime($taper_time{$hostpart}), ")"; } if(defined $partial{$hostpart} && $partial{$hostpart} == 1) { print ", PARTIAL"; $exit_status |= $STATUS_FAILED; } print "\n"; } $tpartition++; $tsize += $size{$hostpart}; if(defined $esize{$hostpart} && $esize{$hostpart} > 1) { $tesize += $esize{$hostpart}; } else { $tesize += $size{$hostpart}; } } else { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; print " unknown state TAPER\n"; } } elsif(defined $dump_started{$hostpart}) { if($dump_started{$hostpart} == -1) { if( defined $opt_failed ) { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; printf " " . $error{$hostpart} . "\n"; } $exit_status |= $STATUS_FAILED; $fpartition++; $fsize+=$esize{$hostpart}; } elsif($dump_started{$hostpart} == 0) { if($estimate{$hostpart} == 1) { if( defined $opt_waitdumping ) { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; printf "%9d$unit", $esize{$hostpart}; print " wait for dumping $error{$hostpart}\n"; } if($driver_finished == 1) { $exit_status |= $STATUS_MISSING; } $wpartition++; $wsize += $esize{$hostpart}; } } elsif($dump_started{$hostpart} == 1 && $dump_finished{$hostpart} == -1) { if( defined $opt_failed ) { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; print " ", $error{$hostpart}; if( defined $starttime ) { print " (", &showtime($dump_time{$hostpart}), ")"; } print "\n"; } $exit_status |= $STATUS_FAILED; $fpartition++; $fsize+=$esize{$hostpart}; } elsif($dump_started{$hostpart} == 1 && $dump_finished{$hostpart} != 1) { if( defined $opt_dumping ) { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; printf "%9d$unit", $esize{$hostpart}; printf " dumping %8d$unit", $size{$hostpart}; if($size{$hostpart} != 0) { printf " (%6.2f%%)", (100.0*$size{$hostpart})/$esize{$hostpart}; } if( defined $starttime ) { print " (", &showtime($dump_time{$hostpart}), ")"; } if(defined $dump_roomq{$hostpart}) { print " " . $error{$hostpart}; } print "\n"; } $dupartition++; $dusize += $size{$hostpart}; $duesize += $esize{$hostpart}; } elsif($dump_finished{$hostpart} == 1 && $taper_started{$hostpart} != 1) { if( defined $opt_waittaper ) { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; printf "%9d$unit", $size{$hostpart}; print " dump done"; if( defined $starttime ) { print " (", &showtime($dump_time{$hostpart}), ")"; } print ", wait for writing to tape"; if(defined $partial{$hostpart} && $partial{$hostpart} == 1) { print ", PARTIAL"; $exit_status |= $STATUS_FAILED; } print "\n"; } $dpartition++; $dsize += $size{$hostpart}; $desize += $esize{$hostpart}; $twpartition++; $twsize += $size{$hostpart}; $twesize += $esize{$hostpart}; } else { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; print " unknown state DUMPER\n"; } } elsif(defined $flush{$hostpart}) { if( defined $opt_waittaper ) { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; printf "%9d$unit", $size{$hostpart}; print " waiting to flush"; if(defined $partial{$hostpart} && $partial{$hostpart} == 1) { print ", PARTIAL"; $exit_status |= $STATUS_FAILED; } print "\n"; } $wfpartition++; $wfsize += $size{$hostpart}; } elsif(defined $level{$hostpart}) { printf "%8s ", $datestamp if defined $opt_date; printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart}; print " unknown state\n"; } } } }}if (defined $opt_summary) { print "\n"; print "SUMMARY part real estimated\n"; print " size size\n"; printf "partition : %3d\n", $nb_partition; printf "estimated : %3d %20d$unit\n", $epartition , $estsize; printf "flush : %3d %9d$unit\n", $flpartition, $flsize; printf "failed : %3d %20d$unit (%6.2f%%)\n", $fpartition , $fsize, $estsize ? ($fsize * 1.0 / $estsize) * 100 : 0.0; printf "wait for dumping: %3d %20d$unit (%6.2f%%)\n", $wpartition , $wsize, $estsize ? ($wsize * 1.0 / $estsize) * 100 : 0.0; printf "dumping to tape : %3d %20d$unit (%6.2f%%)\n", $dtpartition, $dtesize, $estsize ? ($dtesize * 1.0 / $estsize) * 100 : 0.0; printf "dumping : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n", $dupartition, $dusize, $duesize, $duesize ? ($dusize * 1.0 / $duesize) * 100 : 0.0, $estsize ? ($dusize * 1.0 / $estsize) * 100 : 0.0; printf "dumped : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n", $dpartition , $dsize , $desize, $desize ? ($dsize * 1.0 / $desize) * 100 : 0.0, $estsize ? ($dsize * 1.0 / $estsize) * 100 : 0.0; printf "wait for writing: %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n", $twpartition, $twsize, $twesize, $twesize ? ($twsize * 1.0 / $twesize) * 100 : 0.0, $estsize ? ($twsize * 1.0 / $estsize) * 100 : 0.0; printf "wait to flush : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n", $wfpartition, $wfsize, $wfsize, 100, 0; printf "writing to tape : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n", $tapartition, $tasize, $taesize, $taesize ? ($tasize * 1.0 / $taesize) * 100 : 0.0, $estsize ? ($tasize * 1.0 / $estsize) * 100 : 0.0; printf "failed to tape : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n", $tfpartition, $tfsize, $tfesize, $tfesize ? ($tfsize * 1.0 / $tfesize) * 100 : 0.0, $estsize ? ($tfsize * 1.0 / $estsize) * 100 : 0.0; printf "taped : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n", $tpartition , $tsize , $tesize, $tesize ? ($tsize * 1.0 / $tesize) * 100 : 0.0, ($estsize+$flsize) ? ($tsize * 1.0 / ($estsize + $flsize)) * 100 : 0.0; if($nb_tape > 1 || $tape_size != 0) { for($i=1; $i <= $nb_tape; $i++) { if($tape_size != 0) { printf " tape %-3d : %3d %9d$unit %9d$unit (%6.2f%%) %s", $i, $ntpartition{$i}, $ntsize{$i}, $ntesize{$i}, 100*$ntsize{$i}/$tape_size, $ntlabel{$i}; } else { printf " tape %-3d : %3d %9d$unit %9d$unit %s", $i, $ntpartition{$i}, $ntsize{$i}, $ntesize{$i}, $ntlabel{$i}; } if(defined($ntchunk{$i}) && $ntchunk{$i} > 0) { printf " (%d chunks)", $ntchunk{$i}; } print "\n"; } } if($idle_dumpers == 0) { printf "all dumpers active\n"; } else { $c1 = ($idle_dumpers == 1) ? "" : "s"; $c2 = ($idle_dumpers < 10) ? " " : ""; $c3 = ($idle_dumpers == 1) ? " " : ""; printf "%d dumper%s idle%s %s: %s\n", $idle_dumpers, $c1, $c2, $c3, $status_driver; } if($status_taper eq "writing" && defined($qlen{"tapeq:"})) { printf "taper writing, tapeq: %d\n", $qlen{"tapeq:"}; } else { printf "taper idle\n"; } if (defined ($free{"kps:"})) { printf "network free kps: %9d\n", $free{"kps:"}; } if (defined ($free{"space:"})) { if ($holding_space) { $hs = ($free{"space:"} * 1.0 / $holding_space) * 100; } else { $hs = 0.0; } printf "holding space : %9d$unit (%6.2f%%)\n", ($free{"space:"}/$unitdivisor), $hs; }}if(defined $opt_stats) { if(defined($current_time) && $current_time != $start_time) { $total_time=$current_time-$start_time; foreach $key (sort byprocess keys %busy_time) { printf "%8s busy : %8s (%6.2f%%)\n", $key, &busytime($busy_time{$key}), ($busy_time{$key} * 1.0 / $total_time) * 100; } for ($d = 0; $d <= $#dumpers_active; $d++) { $l = sprintf "%2d dumper%s busy%s : %8s (%6.2f%%)", $d, ($d == 1) ? "" : "s", ($d == 1) ? " " : "", &busytime($dumpers_active[$d]), ($dumpers_active[$d] * 1.0 / $total_time) * 100; print $l; $s1 = ""; $s2 = " " x length($l); $r = $dumpers_held[$d]; foreach $key (sort valuesort keys %$r) { next unless $dumpers_held[$d]{$key} >= 1; printf "%s%20s: %8s (%6.2f%%)\n", $s1, $key, &busytime($dumpers_held[$d]{$key}), ($dumpers_held[$d]{$key} * 1.0 / $dumpers_active[$d]) * 100; $s1 = $s2; } if ($s1 eq "") { print "\n"; } } }}exit $exit_status;sub make_hostpart() { local($host,$partition,$datestamp) = @_; if(! defined($hosts{$host})) { push @hosts, $host; $hosts{$host}=1; } my($new_part) = 1; foreach $pp (sort @$host) { $new_part = 0 if ($pp eq $partition); } push @$host, $partition if $new_part==1; my($hostpart) = "$host$partition$datestamp"; if(!defined $datestamp{$datestamp}) { $datestamp{$datestamp} = 1; push @datestamp, $datestamp; } return $hostpart;}sub byprocess() { my(@tmp_a) = split(/(\d*)$/, $a, 2); my(@tmp_b) = split(/(\d*)$/, $b, 2); return ($tmp_a[0] cmp $tmp_b[0]) || ($tmp_a[1] <=> $tmp_b[1]);} sub valuesort() { $r->{$b} <=> $r->{$a};}sub dump_size() { local($filename) = @_; local($size); local($dsize) = 0; local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks); while ($filename ne "") { $filename = "$filename.tmp" if (!(-e "$filename")); $filename = "/dev/null" if (!(-e "$filename")); ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename); $size=$size-32768 if $size > 32768; $dsize += $size; open(DUMP,$filename); $filename = ""; while(<DUMP>) { if(/^CONT_FILENAME=(.*)$/) { $filename = $1; last } last if /^To restore, position tape at start of file and run/; } close(DUMP); } return $dsize;}sub unctime() { my (@MoY); my (@tl); my ($a); my ($m); my ($month); my ($time); @MoY = ('Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'); # Preset an array of values in case some parts are not passed as # arguments. This lets the date, etc, be omitted and default to # today. @tl = localtime; foreach $a (@_) { next if ($a eq ''); # See if this argument looks like a month name. $month = 0; foreach $m (@MoY) { last if ($m eq $a); $month = $month + 1; } if ($month < 12) { $tl[4] = $month; next; } # See if this is a day of the month. if ($a =~ /^\d+$/ && $a >= 1 && $a <= 32) { $tl[3] = $a; next; } # See if the next argument looks like a time. if ($a =~ /^(\d+):(\d+)/) { $tl[2] = $1; $tl[1] = $2; if ($a =~ /^(\d+):(\d+):(\d+)/) { $tl[0] = $3; } next; } # See if this is a year. if ($a =~ /^\d\d\d\d$/ && $a >= 1900) { $tl[5] = $a; next; } } $time = &timelocal (@tl); return $time;}sub set_starttime() { my (@tl); my ($time); my ($date); # Preset an array of values in case some parts are not passed as # arguments. This lets the date, etc, be omitted and default to # today. ($date)=@_; @tl = localtime; $tl[5] = substr($date, 0, 4) if(length($date) >= 4); $tl[4] = substr($date, 4, 2)-1 if(length($date) >= 6); $tl[3] = substr($date, 6, 2) if(length($date) >= 8); $tl[2] = substr($date, 8, 2) if(length($date) >= 10); $tl[1] = substr($date, 10, 2) if(length($date) >= 12); $tl[0] = substr($date, 12, 2) if(length($date) >= 14); $time = &timelocal (@tl); return $time;}sub showtime() { my($delta)=shift; my($oneday)=24*60*60; @now=localtime($starttime+$delta); if($delta > $oneday) { $result=sprintf("%d+",$delta/$oneday); } else { $result=""; } $result.=sprintf("%d:%02d:%02d",$now[2],$now[1],$now[0]); return $result;}sub busytime() { my($busy)=shift; my($oneday)=24*60*60; if($busy > $oneday) { $days=int($busy/$oneday); $result=sprintf("%d+",$busy/$oneday); $busy-=$days*$oneday; } else { $result=""; } $hours=int($busy/60/60); $busy-=$hours*60*60; $minutes=int($busy/60); $busy-=$minutes*60; $seconds=$busy; $result.=sprintf("%d:%02d:%02d",$hours,$minutes,$seconds); return $result;}sub usage() { print "amstatus [--config] config [--file amdump_file]\n"; print " [--summary] [--dumping] [--waitdumping] [--waittaper]\n"; print " [--dumpingtape] [--writingtape] [--finished] [--failed]\n"; print " [--estimate] [--gestimate] [--stats] [--date] [--locale-independent-date-format]\n"; exit 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -