diff --git a/bin/pt-agent b/bin/pt-agent index 860b7b5e..ec83a93d 100755 --- a/bin/pt-agent +++ b/bin/pt-agent @@ -4971,15 +4971,14 @@ sub start_online_logging { ); }; if ( my $e = $EVAL_ERROR ) { - if ( $n_errors > 10 ) { - my $ts = ts(time, 1); # 1=UTC - warn "$ts WARNING $n_errors consecutive errors, no more " - . "error messages will be printed until log entries " - . "are sent successfully again.\n"; - } - else { + if ( ++$n_errors < 10 ) { warn "Error sending log entry to API: $e"; - $n_errors++; + if ( $n_errors >= 10 ) { + my $ts = ts(time, 1); # 1=UTC + warn "$ts WARNING $n_errors consecutive errors, no more " + . "error messages will be printed until log entries " + . "are sent successfully again.\n"; + } } } else { diff --git a/lib/Percona/Agent/Logger.pm b/lib/Percona/Agent/Logger.pm index 8ced4d37..e0f3d352 100644 --- a/lib/Percona/Agent/Logger.pm +++ b/lib/Percona/Agent/Logger.pm @@ -183,15 +183,14 @@ sub start_online_logging { }; if ( my $e = $EVAL_ERROR ) { # Safegaurd: don't spam the agent log file with errors. - if ( $n_errors > 10 ) { - my $ts = ts(time, 1); # 1=UTC - warn "$ts WARNING $n_errors consecutive errors, no more " - . "error messages will be printed until log entries " - . "are sent successfully again.\n"; - } - else { + if ( ++$n_errors < 10 ) { warn "Error sending log entry to API: $e"; - $n_errors++; + if ( $n_errors >= 10 ) { + my $ts = ts(time, 1); # 1=UTC + warn "$ts WARNING $n_errors consecutive errors, no more " + . "error messages will be printed until log entries " + . "are sent successfully again.\n"; + } } } else {