Skip to content

Commit

Permalink
First part of review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzhul committed May 16, 2018
1 parent 131eba1 commit 8ead219
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
5 changes: 4 additions & 1 deletion plugins/inputs/pgbouncer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ Specify address via a url matching:

`postgres://[pqgotest[:password]]@localhost[/dbname]?sslmode=[disable|verify-ca|verify-full]`

All connection parameters are optional. Without the dbname parameter, the driver will default to a database with the same name as the user. This dbname is just for instantiating a connection with the server and doesn't restrict the databases we are trying to grab metrics for.
All connection parameters are optional.

Without the dbname parameter, the driver will default to a database with the same name as the user.
This dbname is just for instantiating a connection with the server and doesn't restrict the databases we are trying to grab metrics for.

### Configuration example
```
Expand Down
17 changes: 4 additions & 13 deletions plugins/inputs/pgbouncer/pgbouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ var sampleConfig = `
##
## All connection parameters are optional.
##
## Without the dbname parameter, the driver will default to a database
## with the same name as the user. This dbname is just for instantiating a
## connection with the server and doesn't restrict the databases we are trying
## to grab metrics for.
##
address = "host=localhost user=pgbouncer sslmode=disable"
`

Expand All @@ -43,10 +38,6 @@ func (p *PgBouncer) Description() string {
return "Read metrics from one or many pgbouncer servers"
}

func (p *PgBouncer) IgnoredColumns() map[string]bool {
return ignoredColumns
}

func (p *PgBouncer) Gather(acc telegraf.Accumulator) error {
var (
err error
Expand All @@ -69,7 +60,7 @@ func (p *PgBouncer) Gather(acc telegraf.Accumulator) error {
}

for rows.Next() {
err = p.accRow(rows, acc, columns)
err = p.accRow("pgbouncer", rows, acc, columns)
if err != nil {
return err
}
Expand All @@ -90,7 +81,7 @@ func (p *PgBouncer) Gather(acc telegraf.Accumulator) error {
}

for poolRows.Next() {
err = p.accRow(poolRows, acc, columns)
err = p.accRow("pgbouncer_pools", poolRows, acc, columns)
if err != nil {
return err
}
Expand All @@ -103,7 +94,7 @@ type scanner interface {
Scan(dest ...interface{}) error
}

func (p *PgBouncer) accRow(row scanner, acc telegraf.Accumulator, columns []string) error {
func (p *PgBouncer) accRow(measurement string, row scanner, acc telegraf.Accumulator, columns []string) error {
var columnVars []interface{}
var dbname bytes.Buffer

Expand Down Expand Up @@ -147,7 +138,7 @@ func (p *PgBouncer) accRow(row scanner, acc telegraf.Accumulator, columns []stri
fields[col] = *val
}
}
acc.AddFields("pgbouncer", fields, tags)
acc.AddFields(measurement, fields, tags)

return nil
}
Expand Down

0 comments on commit 8ead219

Please sign in to comment.