Skip to content

Commit

Permalink
Add number of users to 'system' plugin
Browse files Browse the repository at this point in the history
see #235
  • Loading branch information
sparrc committed Mar 9, 2016
1 parent 2f45b8b commit b445c25
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/inputs/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ func (_ *SystemStats) Gather(acc telegraf.Accumulator) error {
return err
}

users, err := host.Users()
if err != nil {
return err
}

fields := map[string]interface{}{
"load1": loadavg.Load1,
"load5": loadavg.Load5,
"load15": loadavg.Load15,
"uptime": hostinfo.Uptime,
"n_users": len(users),
"uptime_format": format_uptime(hostinfo.Uptime),
}
acc.AddFields("system", fields, nil)
Expand Down

0 comments on commit b445c25

Please sign in to comment.