(plugin) database::postgres - mode hit-ratio wrong calc (#4176)
This commit is contained in:
parent
6332bf9241
commit
59e8e2422a
|
@ -84,11 +84,11 @@ sub run {
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach my $row (@{$result}) {
|
foreach my $row (@{$result}) {
|
||||||
$new_datas->{$$row[2] . '_blks_hit'} = $row->[0];
|
$new_datas->{$row->[2] . '_blks_hit'} = $row->[0];
|
||||||
$new_datas->{$$row[2] . '_blks_read'} = $row->[1];
|
$new_datas->{$row->[2] . '_blks_read'} = $row->[1];
|
||||||
|
|
||||||
if (defined($self->{option_results}->{exclude}) && $row->[2] !~ /$self->{option_results}->{exclude}/) {
|
if (defined($self->{option_results}->{exclude}) && $row->[2] !~ /$self->{option_results}->{exclude}/) {
|
||||||
$self->{output}->output_add(long_msg => "Skipping database '" . $$row[2] . '"');
|
$self->{output}->output_add(long_msg => "Skipping database '" . $row->[2] . '"');
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,15 +96,15 @@ sub run {
|
||||||
my $old_blks_read = $self->{statefile_cache}->get(name => $row->[2] . '_blks_read');
|
my $old_blks_read = $self->{statefile_cache}->get(name => $row->[2] . '_blks_read');
|
||||||
|
|
||||||
next if (!defined($old_blks_hit) || !defined($old_blks_read));
|
next if (!defined($old_blks_hit) || !defined($old_blks_read));
|
||||||
$old_blks_hit = 0 if ($$row[0] <= $old_blks_hit);
|
$old_blks_hit = 0 if ($row->[0] < $old_blks_hit);
|
||||||
$old_blks_read = 0 if ($$row[1] <= $old_blks_read);
|
$old_blks_read = 0 if ($row->[1] < $old_blks_read);
|
||||||
|
|
||||||
$database_check++;
|
$database_check++;
|
||||||
my %prcts = ();
|
my %prcts = ();
|
||||||
my $total_read_requests = $new_datas->{$$row[2] . '_blks_hit'} - $old_blks_hit;
|
my $total_read_requests = $new_datas->{$row->[2] . '_blks_hit'} - $old_blks_hit;
|
||||||
my $total_read_disk = $new_datas->{$$row[2] . '_blks_read'} - $old_blks_read;
|
my $total_read_disk = $new_datas->{$row->[2] . '_blks_read'} - $old_blks_read;
|
||||||
$prcts{hitratio_now} = (($total_read_requests + $total_read_disk) == 0) ? 100 : $total_read_requests * 100 / ($total_read_requests + $total_read_disk);
|
$prcts{hitratio_now} = (($total_read_requests + $total_read_disk) == 0) ? 100 : $total_read_requests * 100 / ($total_read_requests + $total_read_disk);
|
||||||
$prcts{hitratio} = (($new_datas->{$$row[2] . '_blks_hit'} + + $new_datas->{$$row[2] . '_blks_read'}) == 0) ? 100 : $new_datas->{$$row[2] . '_blks_hit'} * 100 / ($new_datas->{$$row[2] . '_blks_hit'} + $new_datas->{$$row[2] . '_blks_read'});
|
$prcts{hitratio} = (($new_datas->{$row->[2] . '_blks_hit'} + + $new_datas->{$row->[2] . '_blks_read'}) == 0) ? 100 : $new_datas->{$row->[2] . '_blks_hit'} * 100 / ($new_datas->{$$row[2] . '_blks_hit'} + $new_datas->{$row->[2] . '_blks_read'});
|
||||||
|
|
||||||
my $exit_code = $self->{perfdata}->threshold_check(value => $prcts{'hitratio' . ((defined($self->{option_results}->{lookback})) ? '' : '_now' )}, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
my $exit_code = $self->{perfdata}->threshold_check(value => $prcts{'hitratio' . ((defined($self->{option_results}->{lookback})) ? '' : '_now' )}, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
|
|
Loading…
Reference in New Issue