mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-12 19:29:30 +08:00
Merge pull request #139 from rburchell/master
host_linux: Skip everything that isn't a normal process.
This commit is contained in:
commit
cc040ddf72
@ -17,6 +17,9 @@ import (
|
|||||||
"github.com/shirou/gopsutil/internal/common"
|
"github.com/shirou/gopsutil/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// from utmpx.h
|
||||||
|
const USER_PROCESS = 7
|
||||||
|
|
||||||
func HostInfo() (*HostInfoStat, error) {
|
func HostInfo() (*HostInfoStat, error) {
|
||||||
ret := &HostInfoStat{
|
ret := &HostInfoStat{
|
||||||
OS: runtime.GOOS,
|
OS: runtime.GOOS,
|
||||||
@ -103,7 +106,7 @@ func Users() ([]UserStat, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if u.Type != 7 { // skip if not USERPROCESS
|
if u.Type != USER_PROCESS {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
user := UserStat{
|
user := UserStat{
|
||||||
|
@ -26,6 +26,9 @@ type LSB struct {
|
|||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from utmp.h
|
||||||
|
const USER_PROCESS = 7
|
||||||
|
|
||||||
func HostInfo() (*HostInfoStat, error) {
|
func HostInfo() (*HostInfoStat, error) {
|
||||||
ret := &HostInfoStat{
|
ret := &HostInfoStat{
|
||||||
OS: runtime.GOOS,
|
OS: runtime.GOOS,
|
||||||
@ -120,6 +123,9 @@ func Users() ([]UserStat, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if u.Type != USER_PROCESS {
|
||||||
|
continue
|
||||||
|
}
|
||||||
user := UserStat{
|
user := UserStat{
|
||||||
User: common.IntToString(u.User[:]),
|
User: common.IntToString(u.User[:]),
|
||||||
Terminal: common.IntToString(u.Line[:]),
|
Terminal: common.IntToString(u.Line[:]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user