diff --git a/plugins/inputs/system/README.md b/plugins/inputs/system/README.md index efaa8a17f..d5bcd7b03 100644 --- a/plugins/inputs/system/README.md +++ b/plugins/inputs/system/README.md @@ -13,7 +13,7 @@ and number of users logged in. It is similar to the unix `uptime` command. #### Permissions: The `n_users` field requires read access to `/var/run/utmp`, and may require -the `telegraf` user to be added to the `utmp` group on some systems. +the `telegraf` user to be added to the `utmp` group on some systems. If this file does not exist `n_users` will be skipped. ### Metrics: diff --git a/plugins/inputs/system/system.go b/plugins/inputs/system/system.go index 5c68870bb..faf44f03e 100644 --- a/plugins/inputs/system/system.go +++ b/plugins/inputs/system/system.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "fmt" + "log" "os" "runtime" "strings" @@ -44,8 +45,10 @@ func (_ *SystemStats) Gather(acc telegraf.Accumulator) error { users, err := host.Users() if err == nil { fields["n_users"] = len(users) - } else if !os.IsPermission(err) { - return err + } else if os.IsNotExist(err) { + log.Printf("D! [inputs.system] Error reading users: %v", err) + } else if os.IsPermission(err) { + log.Printf("D! [inputs.system] %v", err) } now := time.Now()