\#920 Log core metrics.

This commit is contained in:
Auke Willem Oosterhoff 2016-04-11 16:56:37 +02:00 committed by David Arnold
parent cd995c9638
commit 7dab44c028
2 changed files with 41 additions and 1 deletions

View File

@ -39,7 +39,8 @@ type Worker struct {
Tx int `json:"tx"` Tx int `json:"tx"`
AvgRt int `json:"avg_rt"` AvgRt int `json:"avg_rt"`
Apps []*App `json:"apps"` Apps []*App `json:"apps"`
Cores []*Core `json:"cores"`
} }
type App struct { type App struct {
@ -54,3 +55,17 @@ type App struct {
StartupTime int `json:"startup_time"` StartupTime int `json:"startup_time"`
Exceptions int `json:"exceptions"` 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"`
}

View File

@ -69,6 +69,7 @@ func (u *Uwsgi) gatherServer(acc telegraf.Accumulator, url *url.URL) error {
u.gatherStatServer(acc, &s) u.gatherStatServer(acc, &s)
u.gatherWorkers(acc, &s) u.gatherWorkers(acc, &s)
u.gatherApps(acc, &s) u.gatherApps(acc, &s)
u.gatherCores(acc, &s)
return nil return nil
} }
@ -147,6 +148,30 @@ func (u *Uwsgi) gatherApps(acc telegraf.Accumulator, s *StatsServer) error {
return nil 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() { func init() {
inputs.Add("uwsgi", func() telegraf.Input { return &Uwsgi{} }) inputs.Add("uwsgi", func() telegraf.Input { return &Uwsgi{} })
} }