Skip to content

Commit 7a6d3a2

Browse files
committed
0.3.0: postgresql and phpfpm
1 parent 08c4763 commit 7a6d3a2

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

plugins/haproxy/haproxy.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,13 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) error {
162162
now := time.Now()
163163

164164
for _, row := range result {
165-
165+
fields := make(map[string]interface{})
166+
tags := map[string]string{
167+
"server": host,
168+
"proxy": row[HF_PXNAME],
169+
"sv": row[HF_SVNAME],
170+
}
166171
for field, v := range row {
167-
fields := make(map[string]interface{})
168-
tags := map[string]string{
169-
"server": host,
170-
"proxy": row[HF_PXNAME],
171-
"sv": row[HF_SVNAME],
172-
}
173172
switch field {
174173
case HF_QCUR:
175174
ival, err := strconv.ParseUint(v, 10, 64)

plugins/phpfpm/phpfpm.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,11 @@ func importMetric(r io.Reader, acc plugins.Accumulator, host string) (poolStat,
198198
"url": host,
199199
"pool": pool,
200200
}
201+
fields := make(map[string]interface{})
201202
for k, v := range stats[pool] {
202-
acc.Add(strings.Replace(k, " ", "_", -1), v, tags)
203+
fields[strings.Replace(k, " ", "_", -1)] = v
203204
}
205+
acc.AddFields("phpfpm", fields, tags)
204206
}
205207

206208
return stats, nil

plugins/postgresql/postgresql.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var sampleConfig = `
4242
# to grab metrics for.
4343
#
4444
45-
address = "sslmode=disable"
45+
address = "host=localhost user=postgres sslmode=disable"
4646
4747
# A list of databases to pull metrics about. If not specified, metrics for all
4848
# databases are gathered.
@@ -161,12 +161,14 @@ func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator, serv *Server)
161161

162162
tags := map[string]string{"server": serv.Address, "db": dbname.String()}
163163

164+
fields := make(map[string]interface{})
164165
for col, val := range columnMap {
165166
_, ignore := ignoredColumns[col]
166167
if !ignore {
167-
acc.Add(col, *val, tags)
168+
fields[col] = *val
168169
}
169170
}
171+
acc.AddFields("postgresql", fields, tags)
170172

171173
return nil
172174
}

0 commit comments

Comments
 (0)