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{} }) }