]> granicus.if.org Git - pgbadger/commitdiff
Add --exclude-db option to compute report about everything except the specified datab...
authorGilles Darold <gilles@darold.net>
Tue, 25 Sep 2018 03:52:23 +0000 (05:52 +0200)
committerGilles Darold <gilles@darold.net>
Tue, 25 Sep 2018 03:52:23 +0000 (05:52 +0200)
README
doc/pgBadger.pod
pgbadger

diff --git a/README b/README
index 1f176c7ca934a3cd94197930bbeca10f8e15ca68..3d31596f2916d59f647fb8f38bbe1f413a5c7f3a 100644 (file)
--- a/README
+++ b/README
@@ -122,8 +122,12 @@ SYNOPSIS
         --include-time  regex  : only timestamps matching the given regex will be
                                  included in the report. Example: "2013-04-12 .*"
                                  You can use this option multiple times.
+        --exclude-db name      : exclude entries for the specified database from
+                                 report. Example: "pg_dump". Can be used multiple
+                                 time.
         --exclude-appname name : exclude entries for the specified application name
-                                 from report. Example: "pg_dump".
+                                 from report. Example: "pg_dump". Can be used multiple
+                                 time.
         --exclude-line regex   : pgBadger will start to exclude any log entry that
                                  will match the given regex. Can be used multiple
                                  time.
index 288aa11c6615791560108974dae250c9769c62d1..dd61ce5a4efbeba3149fe8db4c3d490e7c4caf0d 100644 (file)
@@ -124,8 +124,12 @@ Options:
     --include-time  regex  : only timestamps matching the given regex will be
                             included in the report. Example: "2013-04-12 .*"
                              You can use this option multiple times.
+    --exclude-db name      : exclude entries for the specified database from
+                            report. Example: "pg_dump". Can be used multiple
+                            time.
     --exclude-appname name : exclude entries for the specified application name
-                            from report. Example: "pg_dump".
+                            from report. Example: "pg_dump". Can be used multiple
+                            time.
     --exclude-line regex   : pgBadger will start to exclude any log entry that
                             will match the given regex. Can be used multiple
                             time.
index 02c72d00c263390e18616107da81bde7a6c738f7..b167d147e2dd8c91c2d89b6e5f6a657bc531b539 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -259,6 +259,7 @@ my @dbclient                = ();
 my @dbappname               = ();
 my @exclude_user            = ();
 my @exclude_appname         = ();
+my @exclude_db              = ();
 my @exclude_line            = ();
 my $ident                   = '';
 my $top                     = 0;
@@ -455,6 +456,7 @@ my $result = GetOptions(
        "image-format=s"           => \$img_format,
        "exclude-query=s"          => \@exclude_query,
        "exclude-file=s"           => \$exclude_file,
+       "exclude-db=s"             => \@exclude_db,
        "exclude-appname=s"        => \@exclude_appname,
        "include-query=s"          => \@include_query,
        "exclude-line=s"           => \@exclude_line,
@@ -1798,8 +1800,12 @@ Options:
     --include-time  regex  : only timestamps matching the given regex will be
                             included in the report. Example: "2013-04-12 .*"
                              You can use this option multiple times.
+    --exclude-db name      : exclude entries for the specified database from
+                            report. Example: "pg_dump". Can be used multiple
+                            time.
     --exclude-appname name : exclude entries for the specified application name
-                            from report. Example: "pg_dump".
+                            from report. Example: "pg_dump". Can be used multiple
+                            time.
     --exclude-line regex   : pgBadger will start to exclude any log entry that
                             will match the given regex. Can be used multiple
                             time.
@@ -12534,6 +12540,13 @@ sub compute_arg_list
        @exclude_appname = ();
        push(@exclude_appname, @tmp);
 
+       @tmp = ();
+       foreach my $v (@exclude_db) {
+               push(@tmp, split(/,/, $v));
+       }
+       @exclude_db = ();
+       push(@exclude_db, @tmp);
+
        @tmp = ();
        foreach my $v (@exclude_line) {
                push(@tmp, split(/,/, $v));
@@ -12609,6 +12622,14 @@ sub validate_log_line
                        return 0;
                }
        }
+       if ($#exclude_db >= 0) {
+
+               # Log line matches the excluded db
+               if ($prefix_vars{'t_dbname'} && grep(/^\Q$prefix_vars{'t_dbname'}\E$/i, @exclude_db)) {
+                       delete $current_sessions{$prefix_vars{'t_pid'}};
+                       return 0;
+               }
+       }
        if ($#exclude_user >= 0) {
 
                # Log line matches the excluded dbuser