From 76dd728c97a8db67ad5582ef2d8cf180c6893da6 Mon Sep 17 00:00:00 2001 From: Thomas Menard Date: Wed, 10 Feb 2016 10:40:48 +0100 Subject: [PATCH] postgres plugin bgwriter stats Add pg_stat_bg_writer stats --- plugins/inputs/postgresql/postgresql.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/inputs/postgresql/postgresql.go b/plugins/inputs/postgresql/postgresql.go index 3a9815af6..e65cbf3a2 100644 --- a/plugins/inputs/postgresql/postgresql.go +++ b/plugins/inputs/postgresql/postgresql.go @@ -95,6 +95,28 @@ func (p *Postgresql) Gather(acc telegraf.Accumulator) error { } } + query = `SELECT * FROM pg_stat_bgwriter` + + rows, err := db.Query(query) + if err != nil { + return err + } + + defer rows.Close() + + // grab the column information from the result + p.OrderedColumns, err = rows.Columns() + if err != nil { + return err + } + + for rows.Next() { + err = p.accRow(rows, acc) + if err != nil { + return err + } + } + return rows.Err() }