Merge pull request #19 from sherifzain/master
Fixed: differentiate stats gathered from multiple servers/instances
This commit is contained in:
commit
1fe0791a74
|
@ -89,7 +89,7 @@ func (p *Postgresql) gatherServer(serv *Server, acc plugins.Accumulator) error {
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err := p.accRow(rows, acc)
|
err := p.accRow(rows, acc, serv.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (p *Postgresql) gatherServer(serv *Server, acc plugins.Accumulator) error {
|
||||||
for _, name := range serv.Databases {
|
for _, name := range serv.Databases {
|
||||||
row := db.QueryRow(`SELECT * FROM pg_stat_database WHERE datname=$1`, name)
|
row := db.QueryRow(`SELECT * FROM pg_stat_database WHERE datname=$1`, name)
|
||||||
|
|
||||||
err := p.accRow(row, acc)
|
err := p.accRow(row, acc, serv.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ type scanner interface {
|
||||||
Scan(dest ...interface{}) error
|
Scan(dest ...interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator) error {
|
func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator, server string) error {
|
||||||
var ignore interface{}
|
var ignore interface{}
|
||||||
var name string
|
var name string
|
||||||
var commit, rollback, read, hit int64
|
var commit, rollback, read, hit int64
|
||||||
|
@ -135,7 +135,7 @@ func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := map[string]string{"db": name}
|
tags := map[string]string{"server": server, "db": name}
|
||||||
|
|
||||||
acc.Add("xact_commit", commit, tags)
|
acc.Add("xact_commit", commit, tags)
|
||||||
acc.Add("xact_rollback", rollback, tags)
|
acc.Add("xact_rollback", rollback, tags)
|
||||||
|
|
|
@ -157,11 +157,12 @@ func (g *Redis) gatherServer(addr string, acc plugins.Accumulator) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tags := map[string]string{"host": addr}
|
||||||
val := strings.TrimSpace(parts[1])
|
val := strings.TrimSpace(parts[1])
|
||||||
|
|
||||||
ival, err := strconv.ParseUint(val, 10, 64)
|
ival, err := strconv.ParseUint(val, 10, 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
acc.Add(metric, ival, nil)
|
acc.Add(metric, ival, tags)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +171,7 @@ func (g *Redis) gatherServer(addr string, acc plugins.Accumulator) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.Add(metric, fval, nil)
|
acc.Add(metric, fval, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue