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() }