From 7dab44c028e7f4ecdbaa27ebc25c9ae1dc34afd9 Mon Sep 17 00:00:00 2001 From: Auke Willem Oosterhoff Date: Mon, 11 Apr 2016 16:56:37 +0200 Subject: [PATCH] \#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 54236bf45..06917a247 100644 --- a/plugins/inputs/uwsgi/uwsgi.go +++ b/plugins/inputs/uwsgi/uwsgi.go @@ -69,6 +69,7 @@ func (u *Uwsgi) gatherServer(acc telegraf.Accumulator, url *url.URL) error { u.gatherStatServer(acc, &s) u.gatherWorkers(acc, &s) u.gatherApps(acc, &s) + u.gatherCores(acc, &s) return nil } @@ -147,6 +148,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{} }) }