From e390de089b7ba557f8f20b91968092e788a05f01 Mon Sep 17 00:00:00 2001 From: Darold Gilles Date: Tue, 5 Aug 2014 20:25:28 +0200 Subject: [PATCH] Add a global regex definition array named @session_closed_msg to add regex that match fatal error messages that do not generate disconnection line in pg log. --- pgbadger | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pgbadger b/pgbadger index 1832c0a..2142c6b 100755 --- a/pgbadger +++ b/pgbadger @@ -181,6 +181,14 @@ my $ssh_user = ''; my $ssh_timeout = 10; my $ssh_options = "-o ConnectTimeout=$ssh_timeout -o PreferredAuthentications=hostbased,publickey"; +# List of regex that match fatal error message that do not +# generate disconnection line in log. This is to prevent +# sessions in the sessions charts to increase continually. +# See issue #176 on github +my @session_closed_msg = ( + qr/^(database|role) "[^"]+" does not exist$/, + qr/^no pg_hba.conf entry for/, +); my $sql_prettified; @@ -8476,6 +8484,13 @@ sub parse_log_prefix } } +sub is_session_closed +{ + map { return 1 if ($_[0] =~ $_); } @session_closed_msg; + + return 0; +} + sub parse_query { @@ -8497,7 +8512,7 @@ sub parse_query # Remove session failure from current workload because there is no disconnection entry if ( ($prefix_vars{'t_loglevel'} eq 'FATAL') - && ($prefix_vars{'t_query'} =~ /^(database|role) "[^"]+" does not exist$/)) + && &is_session_closed($prefix_vars{'t_query'}) ) { delete $current_sessions{$prefix_vars{'t_pid'}} if (!$disable_session); if ($extension eq 'tsung') { -- 2.40.0