diff --git a/host/host_linux.go b/host/host_linux.go index b84000c..14893a4 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -132,7 +132,7 @@ func Uptime() (uint64, error) { } func Users() ([]UserStat, error) { - utmpfile := "/var/run/utmp" + utmpfile := common.HostVar("run/utmp") file, err := os.Open(utmpfile) if err != nil { diff --git a/internal/common/common.go b/internal/common/common.go index 1ef9e27..fcee6be 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -316,6 +316,10 @@ func HostEtc(combineWith ...string) string { return GetEnv("HOST_ETC", "/etc", combineWith...) } +func HostVar(combineWith ...string) string { + return GetEnv("HOST_VAR", "/var", combineWith...) +} + // https://gist.github.com/kylelemons/1525278 func Pipeline(cmds ...*exec.Cmd) ([]byte, []byte, error) { // Require at least one command