mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-22 10:58:42 +00:00
Don't warn about invalid lines, just debug them. Anchor TS pattern. Unset --sample-time unless --group-by sample.
This commit is contained in:
@@ -1934,10 +1934,7 @@ sub parse_diskstats_line {
|
|||||||
my ( $self, $line, $block_size ) = @_;
|
my ( $self, $line, $block_size ) = @_;
|
||||||
|
|
||||||
my @dev_stats = split ' ', $line;
|
my @dev_stats = split ' ', $line;
|
||||||
if ( @dev_stats != 14 ) {
|
return unless @dev_stats == 14;
|
||||||
PTDEBUG && _d("Ignoring short diskstats line:", $line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $read_bytes = $dev_stats[READ_SECTORS] * $block_size;
|
my $read_bytes = $dev_stats[READ_SECTORS] * $block_size;
|
||||||
my $written_bytes = $dev_stats[WRITTEN_SECTORS] * $block_size;
|
my $written_bytes = $dev_stats[WRITTEN_SECTORS] * $block_size;
|
||||||
@@ -2002,7 +1999,8 @@ sub _parse_and_load_diskstats {
|
|||||||
$new_cur->{$dev} = $dev_stats;
|
$new_cur->{$dev} = $dev_stats;
|
||||||
$self->add_ordered_dev($dev);
|
$self->add_ordered_dev($dev);
|
||||||
}
|
}
|
||||||
elsif ( my ($new_ts) = $line =~ /TS\s+([0-9]+(?:\.[0-9]+)?)/ ) {
|
elsif ( my ($new_ts) = $line =~ /^TS\s+([0-9]+(?:\.[0-9]+)?)/ ) {
|
||||||
|
PTDEBUG && _d("Timestamp:", $line);
|
||||||
if ( $current_ts && %$new_cur ) {
|
if ( $current_ts && %$new_cur ) {
|
||||||
$self->_handle_ts_line($current_ts, $new_cur, $sample_callback);
|
$self->_handle_ts_line($current_ts, $new_cur, $sample_callback);
|
||||||
$new_cur = {};
|
$new_cur = {};
|
||||||
@@ -2010,8 +2008,7 @@ sub _parse_and_load_diskstats {
|
|||||||
$current_ts = $new_ts;
|
$current_ts = $new_ts;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chomp($line);
|
PTDEBUG && _d("Ignoring unknown diskstats line:", $line);
|
||||||
warn "Line $INPUT_LINE_NUMBER: [$line] isn't in the diskstats format";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2019,6 +2016,7 @@ sub _parse_and_load_diskstats {
|
|||||||
$self->_handle_ts_line($current_ts, $new_cur, $sample_callback);
|
$self->_handle_ts_line($current_ts, $new_cur, $sample_callback);
|
||||||
$new_cur = {};
|
$new_cur = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return $INPUT_LINE_NUMBER;
|
return $INPUT_LINE_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3218,6 +3216,11 @@ sub main {
|
|||||||
$o->get_specs();
|
$o->get_specs();
|
||||||
$o->get_opts();
|
$o->get_opts();
|
||||||
|
|
||||||
|
# --sample-time only applies to --group-by sample.
|
||||||
|
if ( $o->get('group-by') !~ m/sample/i ) {
|
||||||
|
$o->set('sample-time', undef);
|
||||||
|
}
|
||||||
|
|
||||||
if ( !$o->get('help') ) {
|
if ( !$o->get('help') ) {
|
||||||
if ( !$o->get('columns') ) {
|
if ( !$o->get('columns') ) {
|
||||||
$o->save_error("A regex pattern for --devices must be specified");
|
$o->save_error("A regex pattern for --devices must be specified");
|
||||||
|
@@ -461,10 +461,7 @@ sub parse_diskstats_line {
|
|||||||
|
|
||||||
# Since we assume that device names can't have spaces.
|
# Since we assume that device names can't have spaces.
|
||||||
my @dev_stats = split ' ', $line;
|
my @dev_stats = split ' ', $line;
|
||||||
if ( @dev_stats != 14 ) {
|
return unless @dev_stats == 14;
|
||||||
PTDEBUG && _d("Ignoring short diskstats line:", $line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $read_bytes = $dev_stats[READ_SECTORS] * $block_size;
|
my $read_bytes = $dev_stats[READ_SECTORS] * $block_size;
|
||||||
my $written_bytes = $dev_stats[WRITTEN_SECTORS] * $block_size;
|
my $written_bytes = $dev_stats[WRITTEN_SECTORS] * $block_size;
|
||||||
@@ -567,7 +564,8 @@ sub _parse_and_load_diskstats {
|
|||||||
$new_cur->{$dev} = $dev_stats;
|
$new_cur->{$dev} = $dev_stats;
|
||||||
$self->add_ordered_dev($dev);
|
$self->add_ordered_dev($dev);
|
||||||
}
|
}
|
||||||
elsif ( my ($new_ts) = $line =~ /TS\s+([0-9]+(?:\.[0-9]+)?)/ ) {
|
elsif ( my ($new_ts) = $line =~ /^TS\s+([0-9]+(?:\.[0-9]+)?)/ ) {
|
||||||
|
PTDEBUG && _d("Timestamp:", $line);
|
||||||
if ( $current_ts && %$new_cur ) {
|
if ( $current_ts && %$new_cur ) {
|
||||||
$self->_handle_ts_line($current_ts, $new_cur, $sample_callback);
|
$self->_handle_ts_line($current_ts, $new_cur, $sample_callback);
|
||||||
$new_cur = {};
|
$new_cur = {};
|
||||||
@@ -575,8 +573,7 @@ sub _parse_and_load_diskstats {
|
|||||||
$current_ts = $new_ts;
|
$current_ts = $new_ts;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chomp($line);
|
PTDEBUG && _d("Ignoring unknown diskstats line:", $line);
|
||||||
warn "Line $INPUT_LINE_NUMBER: [$line] isn't in the diskstats format";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,7 +581,7 @@ sub _parse_and_load_diskstats {
|
|||||||
$self->_handle_ts_line($current_ts, $new_cur, $sample_callback);
|
$self->_handle_ts_line($current_ts, $new_cur, $sample_callback);
|
||||||
$new_cur = {};
|
$new_cur = {};
|
||||||
}
|
}
|
||||||
# Seems like this could be useful.
|
|
||||||
return $INPUT_LINE_NUMBER;
|
return $INPUT_LINE_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -215,7 +215,7 @@ $obj->set_column_regex(qr/./);
|
|||||||
is(
|
is(
|
||||||
$header,
|
$header,
|
||||||
q{%5s %-10s busy},
|
q{%5s %-10s busy},
|
||||||
""
|
"Header"
|
||||||
);
|
);
|
||||||
|
|
||||||
($header, $rows, $cols) = $obj->design_print_formats(
|
($header, $rows, $cols) = $obj->design_print_formats(
|
||||||
@@ -226,7 +226,7 @@ is(
|
|||||||
is(
|
is(
|
||||||
$header,
|
$header,
|
||||||
$all_columns_format,
|
$all_columns_format,
|
||||||
""
|
"All columns format"
|
||||||
);
|
);
|
||||||
|
|
||||||
throws_ok( sub { $obj->design_print_formats( columns => {} ) },
|
throws_ok( sub { $obj->design_print_formats( columns => {} ) },
|
||||||
@@ -335,10 +335,10 @@ my $output = output(
|
|||||||
stderr => 1,
|
stderr => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
like(
|
is(
|
||||||
$output,
|
$output,
|
||||||
qr/isn't in the diskstats format/,
|
"",
|
||||||
"->parse_from and friends fail on malformed data"
|
"Doesn't die parsing unknown line"
|
||||||
);
|
);
|
||||||
|
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
|
Reference in New Issue
Block a user