From d3e58b3422a9c40f7a7445cb32138f83a86ba3df Mon Sep 17 00:00:00 2001 From: Auke Willem Oosterhoff Date: Wed, 6 Apr 2016 17:14:49 +0200 Subject: [PATCH] #920 Add metric `uwsgi_overview`. --- plugins/inputs/uwsgi/stat_types.go | 28 +++++++++++++++++++++------ plugins/inputs/uwsgi/uwsgi.go | 31 ++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/plugins/inputs/uwsgi/stat_types.go b/plugins/inputs/uwsgi/stat_types.go index 2493ff577..9270a64e6 100644 --- a/plugins/inputs/uwsgi/stat_types.go +++ b/plugins/inputs/uwsgi/stat_types.go @@ -1,13 +1,29 @@ package uwsgi type StatsServer struct { + // Tags 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"` } type Worker struct { - Id int `json:"id"` // Tag - Pid int `json:"pid"` // Tag + // Tags + Id int `json:"id"` + Pid int `json:"pid"` + + // Fields Accepting int `json:"accepting"` Requests int `json:"requests"` DeltaRequests int `json:"delta_requests"` @@ -15,11 +31,11 @@ type Worker struct { Signals int `json:"signals"` SignalQueue int `json:"signal_queue"` Status string `json:"status"` - RSS int `json:"rss"` - VSZ int `json:"vsz"` + Rss int `json:"rss"` + Vsz int `json:"vsz"` RunningTime int `json:"running_time"` LastSpawn int `json:"last_spawn"` RespawnCount int `json:"respawn_count"` - TX int `json:"tx"` - AvgRT int `json:"avg_rt"` + Tx int `json:"tx"` + AvgRt int `json:"avg_rt"` } diff --git a/plugins/inputs/uwsgi/uwsgi.go b/plugins/inputs/uwsgi/uwsgi.go index 7a5bdc0df..de5ae7746 100644 --- a/plugins/inputs/uwsgi/uwsgi.go +++ b/plugins/inputs/uwsgi/uwsgi.go @@ -62,11 +62,34 @@ func (u *Uwsgi) gatherURL(acc telegraf.Accumulator, url string) error { return err } + u.gatherStatServer(acc, &s) u.gatherWorkers(acc, &s) 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 { for _, w := range s.Workers { fields := map[string]interface{}{ @@ -77,13 +100,13 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error { "signals": w.Signals, "signal_queue": w.SignalQueue, "status": w.Status, - "rss": w.RSS, - "vsz": w.VSZ, + "rss": w.Rss, + "vsz": w.Vsz, "running_time": w.RunningTime, "last_spawn": w.LastSpawn, "respawn_count": w.RespawnCount, - "tx": w.TX, - "avg_rt": w.AvgRT, + "tx": w.Tx, + "avg_rt": w.AvgRt, } tags := map[string]string{ "id": strconv.Itoa(w.Id),