From 290fdeb283fb667e19fc620fec63eb546e9fc0bf Mon Sep 17 00:00:00 2001 From: Auke Willem Oosterhoff Date: Mon, 11 Apr 2016 16:37:58 +0200 Subject: [PATCH 1/3] Log apps metrics. --- plugins/inputs/uwsgi/stat_types.go | 19 +++++++++++++++++-- plugins/inputs/uwsgi/uwsgi.go | 29 ++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/plugins/inputs/uwsgi/stat_types.go b/plugins/inputs/uwsgi/stat_types.go index 9270a64e6..0d72c04b7 100644 --- a/plugins/inputs/uwsgi/stat_types.go +++ b/plugins/inputs/uwsgi/stat_types.go @@ -20,8 +20,8 @@ type StatsServer struct { type Worker struct { // Tags - Id int `json:"id"` - Pid int `json:"pid"` + WorkerId int `json:"id"` + Pid int `json:"pid"` // Fields Accepting int `json:"accepting"` @@ -38,4 +38,19 @@ type Worker struct { RespawnCount int `json:"respawn_count"` Tx int `json:"tx"` AvgRt int `json:"avg_rt"` + + Apps []*App `json:"apps"` +} + +type App struct { + // Tags + AppId int `json:"id"` + MountPoint string `json:"mountpoint"` + Chdir string `json:"chdir"` + + // Fields + Modifier1 int `json:"modifier1"` + Requests int `json:"requests"` + StartupTime int `json:"startup_time"` + Exceptions int `json:"exceptions"` } diff --git a/plugins/inputs/uwsgi/uwsgi.go b/plugins/inputs/uwsgi/uwsgi.go index de5ae7746..a41f52e0a 100644 --- a/plugins/inputs/uwsgi/uwsgi.go +++ b/plugins/inputs/uwsgi/uwsgi.go @@ -64,6 +64,7 @@ func (u *Uwsgi) gatherURL(acc telegraf.Accumulator, url string) error { u.gatherStatServer(acc, &s) u.gatherWorkers(acc, &s) + u.gatherApps(acc, &s) return nil } @@ -109,9 +110,9 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error { "avg_rt": w.AvgRt, } tags := map[string]string{ - "id": strconv.Itoa(w.Id), - "url": s.Url, - "pid": strconv.Itoa(w.Pid), + "worker_id": strconv.Itoa(w.WorkerId), + "url": s.Url, + "pid": strconv.Itoa(w.Pid), } acc.AddFields("uwsgi_workers", fields, tags) @@ -120,6 +121,28 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error { return nil } +func (u *Uwsgi) gatherApps(acc telegraf.Accumulator, s *StatsServer) error { + for _, w := range s.Workers { + for _, a := range w.Apps { + fields := map[string]interface{}{ + "modifier1": a.Modifier1, + "requests": a.Requests, + "startup_time": a.StartupTime, + "exceptions": a.Exceptions, + } + tags := map[string]string{ + "app_id": strconv.Itoa(a.AppId), + "worker_id": strconv.Itoa(w.WorkerId), + "mountpoint": a.MountPoint, + "chdir": a.Chdir, + } + acc.AddFields("uwsgi_apps", fields, tags) + } + } + + return nil +} + func init() { inputs.Add("uwsgi", func() telegraf.Input { return &Uwsgi{} }) } From 755332a458d557ed2346736a0471716c9338e9d5 Mon Sep 17 00:00:00 2001 From: Auke Willem Oosterhoff Date: Mon, 11 Apr 2016 16:56:37 +0200 Subject: [PATCH 2/3] \#920 Log core metrics. --- plugins/inputs/uwsgi/stat_types.go | 17 ++++++++++++++++- plugins/inputs/uwsgi/uwsgi.go | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/uwsgi/stat_types.go b/plugins/inputs/uwsgi/stat_types.go index 0d72c04b7..a3795e950 100644 --- a/plugins/inputs/uwsgi/stat_types.go +++ b/plugins/inputs/uwsgi/stat_types.go @@ -39,7 +39,8 @@ type Worker struct { Tx int `json:"tx"` AvgRt int `json:"avg_rt"` - Apps []*App `json:"apps"` + Apps []*App `json:"apps"` + Cores []*Core `json:"cores"` } type App struct { @@ -54,3 +55,17 @@ type App struct { StartupTime int `json:"startup_time"` Exceptions int `json:"exceptions"` } + +type Core struct { + // Tags + CoreId int `json:"id"` + + // Fields + Requests int `json:"requests"` + StaticRequests int `json:"static_requests"` + RoutedRequests int `json:"routed_requests"` + OffloadedRequests int `json:"offloaded_requests"` + WriteErrors int `json:"write_errors"` + ReadErrors int `json:"read_errors"` + InRequest int `json:"in_request"` +} diff --git a/plugins/inputs/uwsgi/uwsgi.go b/plugins/inputs/uwsgi/uwsgi.go index a41f52e0a..fd719d56f 100644 --- a/plugins/inputs/uwsgi/uwsgi.go +++ b/plugins/inputs/uwsgi/uwsgi.go @@ -65,6 +65,7 @@ func (u *Uwsgi) gatherURL(acc telegraf.Accumulator, url string) error { u.gatherStatServer(acc, &s) u.gatherWorkers(acc, &s) u.gatherApps(acc, &s) + u.gatherCores(acc, &s) return nil } @@ -143,6 +144,30 @@ func (u *Uwsgi) gatherApps(acc telegraf.Accumulator, s *StatsServer) error { return nil } +func (u *Uwsgi) gatherCores(acc telegraf.Accumulator, s *StatsServer) error { + for _, w := range s.Workers { + for _, c := range w.Cores { + fields := map[string]interface{}{ + "requests": c.Requests, + "static_requests": c.StaticRequests, + "routed_requests": c.RoutedRequests, + "offloaded_requests": c.OffloadedRequests, + "write_errors": c.WriteErrors, + "read_errors": c.ReadErrors, + "in_request": c.InRequest, + } + tags := map[string]string{ + "core_id": strconv.Itoa(c.CoreId), + "worker_id": strconv.Itoa(w.WorkerId), + } + acc.AddFields("uwsgi_cores", fields, tags) + } + + } + + return nil +} + func init() { inputs.Add("uwsgi", func() telegraf.Input { return &Uwsgi{} }) } From a577420536714f9f08d537fb0b002474b3d92157 Mon Sep 17 00:00:00 2001 From: Auke Willem Oosterhoff Date: Thu, 14 Apr 2016 13:09:07 +0200 Subject: [PATCH 3/3] #920 Add exception count per worker. --- plugins/inputs/uwsgi/stat_types.go | 1 + plugins/inputs/uwsgi/uwsgi.go | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/inputs/uwsgi/stat_types.go b/plugins/inputs/uwsgi/stat_types.go index a3795e950..3537b1219 100644 --- a/plugins/inputs/uwsgi/stat_types.go +++ b/plugins/inputs/uwsgi/stat_types.go @@ -27,6 +27,7 @@ type Worker struct { Accepting int `json:"accepting"` Requests int `json:"requests"` DeltaRequests int `json:"delta_requests"` + Exceptions int `json:"exceptions"` HarakiriCount int `json:"harakiri_count"` Signals int `json:"signals"` SignalQueue int `json:"signal_queue"` diff --git a/plugins/inputs/uwsgi/uwsgi.go b/plugins/inputs/uwsgi/uwsgi.go index fd719d56f..cb7b8307d 100644 --- a/plugins/inputs/uwsgi/uwsgi.go +++ b/plugins/inputs/uwsgi/uwsgi.go @@ -98,6 +98,7 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error { "requests": w.Requests, "accepting": w.Accepting, "delta_request": w.DeltaRequests, + "exceptions": w.Exceptions, "harakiri_count": w.HarakiriCount, "signals": w.Signals, "signal_queue": w.SignalQueue,