#920 Add metric `uwsgi_overview`.
This commit is contained in:
parent
5f77241a36
commit
d3e58b3422
|
@ -1,13 +1,29 @@
|
||||||
package uwsgi
|
package uwsgi
|
||||||
|
|
||||||
type StatsServer struct {
|
type StatsServer struct {
|
||||||
|
// Tags
|
||||||
Url string
|
Url string
|
||||||
|
Pid int `json:"pid"`
|
||||||
|
Uid int `json:"uid"`
|
||||||
|
Gid int `json:"gid"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
Cwd string `json:"cwd"`
|
||||||
|
|
||||||
|
// Fields
|
||||||
|
ListenQueue int `json:"listen_queue"`
|
||||||
|
ListenQueueErrors int `json:"listen_queue_errors"`
|
||||||
|
SignalQueue int `json:"signal_queue"`
|
||||||
|
Load int `json:"load"`
|
||||||
|
|
||||||
Workers []*Worker `json:"workers"`
|
Workers []*Worker `json:"workers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Worker struct {
|
type Worker struct {
|
||||||
Id int `json:"id"` // Tag
|
// Tags
|
||||||
Pid int `json:"pid"` // Tag
|
Id int `json:"id"`
|
||||||
|
Pid int `json:"pid"`
|
||||||
|
|
||||||
|
// Fields
|
||||||
Accepting int `json:"accepting"`
|
Accepting int `json:"accepting"`
|
||||||
Requests int `json:"requests"`
|
Requests int `json:"requests"`
|
||||||
DeltaRequests int `json:"delta_requests"`
|
DeltaRequests int `json:"delta_requests"`
|
||||||
|
@ -15,11 +31,11 @@ type Worker struct {
|
||||||
Signals int `json:"signals"`
|
Signals int `json:"signals"`
|
||||||
SignalQueue int `json:"signal_queue"`
|
SignalQueue int `json:"signal_queue"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
RSS int `json:"rss"`
|
Rss int `json:"rss"`
|
||||||
VSZ int `json:"vsz"`
|
Vsz int `json:"vsz"`
|
||||||
RunningTime int `json:"running_time"`
|
RunningTime int `json:"running_time"`
|
||||||
LastSpawn int `json:"last_spawn"`
|
LastSpawn int `json:"last_spawn"`
|
||||||
RespawnCount int `json:"respawn_count"`
|
RespawnCount int `json:"respawn_count"`
|
||||||
TX int `json:"tx"`
|
Tx int `json:"tx"`
|
||||||
AvgRT int `json:"avg_rt"`
|
AvgRt int `json:"avg_rt"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,34 @@ func (u *Uwsgi) gatherURL(acc telegraf.Accumulator, url string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u.gatherStatServer(acc, &s)
|
||||||
u.gatherWorkers(acc, &s)
|
u.gatherWorkers(acc, &s)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *Uwsgi) gatherStatServer(acc telegraf.Accumulator, s *StatsServer) error {
|
||||||
|
fields := map[string]interface{}{
|
||||||
|
"listen_queue": s.ListenQueue,
|
||||||
|
"listen_queue_errors": s.ListenQueueErrors,
|
||||||
|
"signal_queue": s.SignalQueue,
|
||||||
|
"load": s.Load,
|
||||||
|
}
|
||||||
|
|
||||||
|
tags := map[string]string{
|
||||||
|
"url": s.Url,
|
||||||
|
"pid": strconv.Itoa(s.Pid),
|
||||||
|
"uid": strconv.Itoa(s.Uid),
|
||||||
|
"gid": strconv.Itoa(s.Gid),
|
||||||
|
"version": s.Version,
|
||||||
|
"cwd": s.Cwd,
|
||||||
|
}
|
||||||
|
acc.AddFields("uwsgi_overview", fields, tags)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error {
|
func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error {
|
||||||
for _, w := range s.Workers {
|
for _, w := range s.Workers {
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
|
@ -77,13 +100,13 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error {
|
||||||
"signals": w.Signals,
|
"signals": w.Signals,
|
||||||
"signal_queue": w.SignalQueue,
|
"signal_queue": w.SignalQueue,
|
||||||
"status": w.Status,
|
"status": w.Status,
|
||||||
"rss": w.RSS,
|
"rss": w.Rss,
|
||||||
"vsz": w.VSZ,
|
"vsz": w.Vsz,
|
||||||
"running_time": w.RunningTime,
|
"running_time": w.RunningTime,
|
||||||
"last_spawn": w.LastSpawn,
|
"last_spawn": w.LastSpawn,
|
||||||
"respawn_count": w.RespawnCount,
|
"respawn_count": w.RespawnCount,
|
||||||
"tx": w.TX,
|
"tx": w.Tx,
|
||||||
"avg_rt": w.AvgRT,
|
"avg_rt": w.AvgRt,
|
||||||
}
|
}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"id": strconv.Itoa(w.Id),
|
"id": strconv.Itoa(w.Id),
|
||||||
|
|
Loading…
Reference in New Issue