]> granicus.if.org Git - pgbadger/commitdiff
Adding new option --exclude-file to exclude specific commands with regex stated in...
authorDarold Gilles <gilles@darold.net>
Mon, 13 Aug 2012 20:44:27 +0000 (22:44 +0200)
committerDarold Gilles <gilles@darold.net>
Mon, 13 Aug 2012 20:44:27 +0000 (22:44 +0200)
README
doc/pgBadger.pod
pgbadger

diff --git a/README b/README
index b855b5d5d241f4bfa75f05357d0c1ea4c7e6aa04..5f838c9013a579e7ceab24186a96dd8ab40bb402 100644 (file)
--- a/README
+++ b/README
@@ -39,7 +39,7 @@ SYNOPSIS
         -t | --top number      : number of query to store/display. Default: 20
         -u | --dbuser username : only report what concern the given user
         -v | --verbose         : enable verbose or debug mode. Disabled by default.
-        -w | -watch-mode       : only report errors just like logwatch could do.
+        -w | --watch-mode      : only report errors just like logwatch could do.
         -x | --extension       : output format. Values: text or html. Default: html
         -z | --zcat exec_path  : set the full path to the zcat program. Use it if
                                  zcat is not on your path or you want to use gzcat.
@@ -47,6 +47,8 @@ SYNOPSIS
         --exclude-query regex  : any query matching the given regex will be excluded
                                  from the report. For example: "^(VACUUM|COMMIT)"
                                  you can use this option multiple time.
+        --exclude_file filename: path of the file which contains all the regex to use
+                                 to exclude queries from the report. One regex per line.
         --disable-error        : do not generate error report.
         --disable-hourly       : do not generate hourly reports.
         --disable-type         : do not generate query type report.
index bb0aff54b68c92d3e935d84b8ca353b03d59c81c..05a79b2e9064cbf35169939f831354b00cffd340 100644 (file)
@@ -42,7 +42,7 @@ Options:
     -t | --top number      : number of query to store/display. Default: 20
     -u | --dbuser username : only report what concern the given user
     -v | --verbose         : enable verbose or debug mode. Disabled by default.
-    -w | -watch-mode       : only report errors just like logwatch could do.
+    -w | --watch-mode      : only report errors just like logwatch could do.
     -x | --extension       : output format. Values: text or html. Default: html
     -z | --zcat exec_path  : set the full path to the zcat program. Use it if
                              zcat is not on your path or you want to use gzcat.
@@ -50,6 +50,8 @@ Options:
     --exclude-query regex  : any query matching the given regex will be excluded
                              from the report. For example: "^(VACUUM|COMMIT)"
                              you can use this option multiple time.
+    --exclude_file filename: path of the file which contains all the regex to use
+                             to exclude queries from the report. One regex per line.
     --disable-error        : do not generate error report.
     --disable-hourly       : do not generate hourly reports.
     --disable-type         : do not generate query type report.
index e002f8987e4fb11627cd094138e2d9c88ec2d80c..8cc5b5abcd0ce7a40f65f5b5af700ecba19abe9c 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -64,6 +64,7 @@ my $quiet               = 0;
 my $progress            = 0;
 my $error_only          = 0;
 my @exclude_query       = ();
+my $exclude_file        = '';
 my $disable_error       = 0;
 my $disable_hourly      = 0;
 my $disable_type        = 0;
@@ -119,6 +120,7 @@ my $result = GetOptions(
        "w|watch-mode!"       => \$error_only,
        "v|verbose!"          => \$debug,
        "exclude-query=s"     => \@exclude_query,
+       "exclude-file=s"      => \$exclude_file,
        "disable-error!"      => \$disable_error,
        "disable-hourly!"     => \$disable_hourly,
        "disable-type!"       => \$disable_type,
@@ -229,6 +231,19 @@ if ($error_only && $disable_error) {
 $regex_prefix_dbname = 'db=([^,]*)'   if (!$regex_prefix_dbname);
 $regex_prefix_dbuser = 'user=([^,]*)' if (!$regex_prefix_dbuser);
 
+# Loading excluded query from file if any
+if ($exclude_file) {
+       open(IN, "$exclude_file") or die "FATAL: can't read file $exclude_file: $!\n";
+       my @exclq = <IN>;
+       close(IN);
+       chomp(@exclq);
+       map { s/\r//; } @exclq;
+       foreach my $r (@exclq) {
+               &check_regex($r, '--exclude-file');
+       }
+       push(@exclude_query, @exclq);
+}
+
 # Testing regex syntaxe
 if ($#exclude_query >= 0) {
        foreach my $r (@exclude_query) {
@@ -684,7 +699,7 @@ Options:
     -t | --top number      : number of query to store/display. Default: 20
     -u | --dbuser username : only report what concern the given user
     -v | --verbose         : enable verbose or debug mode. Disabled by default.
-    -w | -watch-mode       : only report errors just like logwatch could do.
+    -w | --watch-mode      : only report errors just like logwatch could do.
     -x | --extension       : output format. Values: text or html. Default: html
     -z | --zcat exec_path  : set the full path to the zcat program. Use it if
                             zcat is not on your path or you want to use gzcat.
@@ -692,6 +707,8 @@ Options:
     --exclude-query regex  : any query matching the given regex will be excluded
                             from the report. For example: "^(VACUUM|COMMIT)"
                             you can use this option multiple time.
+    --exclude_file filename: path of the file which contains all the regex to use
+                            to exclude queries from the report. One regex per line.
     --disable-error        : do not generate error report.
     --disable-hourly       : do not generate hourly reports.
     --disable-type         : do not generate query type report.