\#920 Log core metrics.

This commit is contained in:
Auke Willem Oosterhoff 2016-04-11 16:56:37 +02:00
parent 290fdeb283
commit 755332a458
2 changed files with 41 additions and 1 deletions

View File

@ -40,6 +40,7 @@ type Worker struct {
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

@ -65,6 +65,7 @@ func (u *Uwsgi) gatherURL(acc telegraf.Accumulator, url string) 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
} }
@ -143,6 +144,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{} })
} }