0.3.0: postgresql and phpfpm

This commit is contained in:
Cameron Sparr 2015-12-18 17:09:01 -07:00
parent 9c5321c538
commit 64a832467e
3 changed files with 13 additions and 10 deletions

View File

@ -162,14 +162,13 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) error {
now := time.Now() now := time.Now()
for _, row := range result { for _, row := range result {
for field, v := range row {
fields := make(map[string]interface{}) fields := make(map[string]interface{})
tags := map[string]string{ tags := map[string]string{
"server": host, "server": host,
"proxy": row[HF_PXNAME], "proxy": row[HF_PXNAME],
"sv": row[HF_SVNAME], "sv": row[HF_SVNAME],
} }
for field, v := range row {
switch field { switch field {
case HF_QCUR: case HF_QCUR:
ival, err := strconv.ParseUint(v, 10, 64) ival, err := strconv.ParseUint(v, 10, 64)

View File

@ -198,9 +198,11 @@ func importMetric(r io.Reader, acc plugins.Accumulator, host string) (poolStat,
"url": host, "url": host,
"pool": pool, "pool": pool,
} }
fields := make(map[string]interface{})
for k, v := range stats[pool] { for k, v := range stats[pool] {
acc.Add(strings.Replace(k, " ", "_", -1), v, tags) fields[strings.Replace(k, " ", "_", -1)] = v
} }
acc.AddFields("phpfpm", fields, tags)
} }
return stats, nil return stats, nil

View File

@ -42,7 +42,7 @@ var sampleConfig = `
# to grab metrics for. # to grab metrics for.
# #
address = "sslmode=disable" address = "host=localhost user=postgres sslmode=disable"
# A list of databases to pull metrics about. If not specified, metrics for all # A list of databases to pull metrics about. If not specified, metrics for all
# databases are gathered. # databases are gathered.
@ -161,12 +161,14 @@ func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator, serv *Server)
tags := map[string]string{"server": serv.Address, "db": dbname.String()} tags := map[string]string{"server": serv.Address, "db": dbname.String()}
fields := make(map[string]interface{})
for col, val := range columnMap { for col, val := range columnMap {
_, ignore := ignoredColumns[col] _, ignore := ignoredColumns[col]
if !ignore { if !ignore {
acc.Add(col, *val, tags) fields[col] = *val
} }
} }
acc.AddFields("postgresql", fields, tags)
return nil return nil
} }