0.3.0: ping, mysql, nginx
This commit is contained in:
parent
7a32fe09d1
commit
a148c9da3b
|
@ -138,6 +138,8 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
servtag = "localhost"
|
servtag = "localhost"
|
||||||
}
|
}
|
||||||
|
tags := map[string]string{"server": servtag}
|
||||||
|
fields := make(map[string]interface{})
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var name string
|
var name string
|
||||||
var val interface{}
|
var val interface{}
|
||||||
|
@ -149,12 +151,10 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
|
||||||
|
|
||||||
var found bool
|
var found bool
|
||||||
|
|
||||||
tags := map[string]string{"server": servtag}
|
|
||||||
|
|
||||||
for _, mapped := range mappings {
|
for _, mapped := range mappings {
|
||||||
if strings.HasPrefix(name, mapped.onServer) {
|
if strings.HasPrefix(name, mapped.onServer) {
|
||||||
i, _ := strconv.Atoi(string(val.([]byte)))
|
i, _ := strconv.Atoi(string(val.([]byte)))
|
||||||
acc.Add(mapped.inExport+name[len(mapped.onServer):], i, tags)
|
fields[mapped.inExport+name[len(mapped.onServer):]] = i
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,16 +170,17 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.Add("queries", i, tags)
|
fields["queries"] = i
|
||||||
case "Slow_queries":
|
case "Slow_queries":
|
||||||
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
|
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.Add("slow_queries", i, tags)
|
fields["slow_queries"] = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
acc.AddFields("mysql", fields, tags)
|
||||||
|
|
||||||
conn_rows, err := db.Query("SELECT user, sum(1) FROM INFORMATION_SCHEMA.PROCESSLIST GROUP BY user")
|
conn_rows, err := db.Query("SELECT user, sum(1) FROM INFORMATION_SCHEMA.PROCESSLIST GROUP BY user")
|
||||||
|
|
||||||
|
@ -193,11 +194,13 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := map[string]string{"server": servtag, "user": user}
|
tags := map[string]string{"server": servtag, "user": user}
|
||||||
|
fields := make(map[string]interface{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
acc.Add("connections", connections, tags)
|
fields["connections"] = connections
|
||||||
|
acc.AddFields("mysql_users", fields, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -127,14 +127,16 @@ func (n *Nginx) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := getTags(addr)
|
tags := getTags(addr)
|
||||||
|
fields := map[string]interface{}{
|
||||||
acc.Add("active", active, tags)
|
"active": active,
|
||||||
acc.Add("accepts", accepts, tags)
|
"accepts": accepts,
|
||||||
acc.Add("handled", handled, tags)
|
"handled": handled,
|
||||||
acc.Add("requests", requests, tags)
|
"requests": requests,
|
||||||
acc.Add("reading", reading, tags)
|
"reading": reading,
|
||||||
acc.Add("writing", writing, tags)
|
"writing": writing,
|
||||||
acc.Add("waiting", waiting, tags)
|
"waiting": waiting,
|
||||||
|
}
|
||||||
|
acc.AddFields("nginx", fields, tags)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,13 @@ func (p *Ping) Gather(acc plugins.Accumulator) error {
|
||||||
}
|
}
|
||||||
// Calculate packet loss percentage
|
// Calculate packet loss percentage
|
||||||
loss := float64(trans-rec) / float64(trans) * 100.0
|
loss := float64(trans-rec) / float64(trans) * 100.0
|
||||||
acc.Add("packets_transmitted", trans, tags)
|
fields := map[string]interface{}{
|
||||||
acc.Add("packets_received", rec, tags)
|
"packets_transmitted": trans,
|
||||||
acc.Add("percent_packet_loss", loss, tags)
|
"packets_received": rec,
|
||||||
acc.Add("average_response_ms", avg, tags)
|
"percent_packet_loss": loss,
|
||||||
|
"average_response_ms": avg,
|
||||||
|
}
|
||||||
|
acc.AddFields("ping", fields, tags)
|
||||||
}(url, acc)
|
}(url, acc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue