Skip to content

Commit

Permalink
Fix panic if pool_mode column does not exist (#6000)
Browse files Browse the repository at this point in the history
(cherry picked from commit 049d364)
  • Loading branch information
danielnelson committed Jun 20, 2019
1 parent 28d56a8 commit 42c9d03
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions plugins/inputs/pgbouncer/pgbouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package pgbouncer

import (
"bytes"
"github.com/influxdata/telegraf/plugins/inputs/postgresql"

// register in driver.
_ "github.com/jackc/pgx/stdlib"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/inputs/postgresql"
_ "github.com/jackc/pgx/stdlib" // register driver
)

type PgBouncer struct {
Expand Down Expand Up @@ -98,12 +96,16 @@ func (p *PgBouncer) Gather(acc telegraf.Accumulator) error {
return err
}

if s, ok := (*columnMap["user"]).(string); ok && s != "" {
tags["user"] = s
if user, ok := columnMap["user"]; ok {
if s, ok := (*user).(string); ok && s != "" {
tags["user"] = s
}
}

if s, ok := (*columnMap["pool_mode"]).(string); ok && s != "" {
tags["pool_mode"] = s
if poolMode, ok := columnMap["pool_mode"]; ok {
if s, ok := (*poolMode).(string); ok && s != "" {
tags["pool_mode"] = s
}
}

fields := make(map[string]interface{})
Expand Down

0 comments on commit 42c9d03

Please sign in to comment.