Ignore error when utmp is missing (#5742)

This commit is contained in:
Tim Ehlers
2019-06-24 20:48:07 -05:00
committed by Daniel Nelson
parent bd9ddd8cb1
commit a5c94db625
2 changed files with 6 additions and 3 deletions

View File

@@ -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()