Added the actual pt-diskstats tool.

Missing a doc overhaul and tests, but this deals with most of the
feature upgrades in the blueprint.

The shell version of pt-diskstats is now in bin has pt-diskstats-shell,
in case that's needed.
This commit is contained in:
Brian Fraser
2011-12-16 13:40:22 -03:00
parent 7b12dbec64
commit 13c9c5b0bb
21 changed files with 20466 additions and 613 deletions

View File

@@ -47,7 +47,7 @@ my %actions = (
'S' => \&group_by,
'i' => \&hide_inactive_disks,
'd' => get_new_value_for( "redisplay_interval", "Enter a new redisplay interval in seconds: " ),
'z' => get_new_value_for( "interval", "Enter a new interval between samples in seconds: " ),
'z' => get_new_value_for( "sample_time", "Enter a new interval between samples in seconds: " ),
'c' => get_new_x_regex( "column_regex", "Enter a column pattern: " ),
'/' => get_new_x_regex( "device_regex", "Enter a disk/device pattern: " ),
'q' => sub { return 'last' },
@@ -85,6 +85,10 @@ sub run_interactive {
filter_zeroed_rows => 0,
);
for my $re_key ( grep { $opts{$_} } qw( column_regex device_regex ) ) {
$opts{$re_key} = qr/$opts{$re_key}/i;
}
my ($tmp_fh, $filename, $child_pid, $child_fh);
# Here's a big crux of the program. If we have a filename, we don't
@@ -139,6 +143,7 @@ sub run_interactive {
if ( $args{filename} ) {
group_by(
header_cb => sub { shift->print_header(@_) },
select_obj => $sel,
options => \%opts,
filehandle => $tmp_fh,
@@ -243,7 +248,7 @@ sub group_by {
$obj->group_by(
filehandle => $args{filehandle},
# Only print the header once, as if in interactive.
header_cb => sub {
header_cb => $args{header_cb} || sub {
my $print_header;
return sub {
unless ($print_header++) {
@@ -263,13 +268,13 @@ sub help {
my $mode = $object_to_option{ref($obj)};
my ($column_re) = regexp_pattern( $obj->column_regex() );
my ($device_re) = regexp_pattern( $obj->device_regex() );
my $interval = $obj->interval() || '(none)';
my $interval = $obj->sample_time() || '(none)';
my $disp_int = $args{options}->{display_interval} || '(none)';
my $inact_disk = $obj->filter_zeroed_rows() || '';
for my $re ( $column_re, $device_re ) {
$re =~ s/^\Q(?=)\E$//;
$re ||= '(none)';
$re =~ s/^\Q(?=)\E$//;
}
print <<"HELP";
@@ -327,7 +332,7 @@ sub get_input {
sub hide_inactive_disks {
my (%args) = @_;
my $new_val = get_input("Filter inactive rows? (Leave blank for 'No') ");
my $new_val = !!get_input("Filter inactive rows? (Leave blank for 'No') ");
$args{options}->{filter_zeroed_rows} = $new_val;
$args{options}->{obj}->filter_zeroed_rows($new_val);