From 3fc7bc1ef7b84de1342fa67b92aaa8333b1a946e Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 2 Feb 2016 10:51:15 +0100 Subject: [PATCH] host_linux: Skip everything that isn't a normal process. host_darwin does the same filtering. Not doing this gives us some rather strange entries that likely aren't what we want. Before: {"user":"reboot","terminal":"~","host":"3.10.0-327.4.5.el7.x86_64","started":1454378260} {"user":"LOGIN","terminal":"ttyS0","host":"","started":1454378270} {"user":"LOGIN","terminal":"tty1","host":"","started":1454378270} {"user":"runlevel","terminal":"~","host":"3.10.0-327.4.5.el7.x86_64","started":1454378276} {"user":"root","terminal":"pts/0","host":"vpn","started":1454404513} After: {"user":"root","terminal":"pts/0","host":"vpn","started":1454404513} --- host/host_linux.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/host/host_linux.go b/host/host_linux.go index d7fe992..11c8a4e 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -26,6 +26,9 @@ type LSB struct { Description string } +// from utmp.h +const USER_PROCESS = 7 + func HostInfo() (*HostInfoStat, error) { ret := &HostInfoStat{ OS: runtime.GOOS, @@ -120,6 +123,9 @@ func Users() ([]UserStat, error) { if err != nil { continue } + if u.Type != USER_PROCESS { + continue + } user := UserStat{ User: common.IntToString(u.User[:]), Terminal: common.IntToString(u.Line[:]),