From c6034e4f8386fce38bd26fe3146302a66fb535f8 Mon Sep 17 00:00:00 2001 From: Mahadevan Date: Sat, 9 Oct 2021 16:09:52 +0530 Subject: [PATCH] Add option to omit collection of index definitions. --- cmd/pgmetrics/main.go | 5 +++-- collector/collect.go | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/pgmetrics/main.go b/cmd/pgmetrics/main.go index 3712412..7df03de 100644 --- a/cmd/pgmetrics/main.go +++ b/cmd/pgmetrics/main.go @@ -56,7 +56,7 @@ Collection options: --omit=WHAT do NOT collect the items specified as a comma-separated list of: "tables", "indexes", "sequences", "functions", "extensions", "triggers", - "statements", "log", "citus" + "statements", "log", "citus", "indexdefs" --sql-length=LIMIT collect only first LIMIT characters of all SQL queries (default: 500) --statements-limit=LIMIT collect only utmost LIMIT number of row from @@ -279,7 +279,8 @@ func (o *options) parse() (args []string) { for _, om := range o.CollectConfig.Omit { if om != "tables" && om != "indexes" && om != "sequences" && om != "functions" && om != "extensions" && om != "triggers" && - om != "statements" && om != "log" && om != "citus" { + om != "statements" && om != "log" && om != "citus" && + om != "indexdefs" { fmt.Fprintf(os.Stderr, "unknown item \"%s\" in --omit option\n", om) printTry() os.Exit(2) diff --git a/collector/collect.go b/collector/collect.go index 1581c1d..65851e2 100644 --- a/collector/collect.go +++ b/collector/collect.go @@ -488,7 +488,9 @@ func (c *collector) collectDatabase(o CollectConfig) { } if !arrayHas(o.Omit, "tables") && !arrayHas(o.Omit, "indexes") { c.getIndexes(!o.NoSizes) - c.getIndexDef() + if !arrayHas(o.Omit, "indexdefs") { + c.getIndexDef() + } } if !arrayHas(o.Omit, "sequences") { c.getSequences()