Merge branch '#920' of github.com:OrangeTux/telegraf into #920

This commit is contained in:
= 2016-04-14 20:00:46 +02:00
commit 9644a1000b
2 changed files with 85 additions and 5 deletions

View File

@ -20,13 +20,14 @@ type StatsServer struct {
type Worker struct { type Worker struct {
// Tags // Tags
Id int `json:"id"` WorkerId int `json:"id"`
Pid int `json:"pid"` Pid int `json:"pid"`
// Fields // Fields
Accepting int `json:"accepting"` Accepting int `json:"accepting"`
Requests int `json:"requests"` Requests int `json:"requests"`
DeltaRequests int `json:"delta_requests"` DeltaRequests int `json:"delta_requests"`
Exceptions int `json:"exceptions"`
HarakiriCount int `json:"harakiri_count"` HarakiriCount int `json:"harakiri_count"`
Signals int `json:"signals"` Signals int `json:"signals"`
SignalQueue int `json:"signal_queue"` SignalQueue int `json:"signal_queue"`
@ -38,4 +39,34 @@ type Worker struct {
RespawnCount int `json:"respawn_count"` RespawnCount int `json:"respawn_count"`
Tx int `json:"tx"` Tx int `json:"tx"`
AvgRt int `json:"avg_rt"` AvgRt int `json:"avg_rt"`
Apps []*App `json:"apps"`
Cores []*Core `json:"cores"`
}
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"`
}
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

@ -68,6 +68,8 @@ 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.gatherCores(acc, &s)
return nil return nil
} }
@ -100,6 +102,7 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error {
"requests": w.Requests, "requests": w.Requests,
"accepting": w.Accepting, "accepting": w.Accepting,
"delta_request": w.DeltaRequests, "delta_request": w.DeltaRequests,
"exceptions": w.Exceptions,
"harakiri_count": w.HarakiriCount, "harakiri_count": w.HarakiriCount,
"signals": w.Signals, "signals": w.Signals,
"signal_queue": w.SignalQueue, "signal_queue": w.SignalQueue,
@ -113,7 +116,7 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error {
"avg_rt": w.AvgRt, "avg_rt": w.AvgRt,
} }
tags := map[string]string{ tags := map[string]string{
"id": strconv.Itoa(w.Id), "worker_id": strconv.Itoa(w.WorkerId),
"url": s.Url, "url": s.Url,
"pid": strconv.Itoa(w.Pid), "pid": strconv.Itoa(w.Pid),
} }
@ -124,6 +127,52 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error {
return nil 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 (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{} })
} }