package process

Import Path
	github.com/shirou/gopsutil/v3/process (on go.dev)

Dependency Relation
	imports 23 packages, and imported by one package


Package-Level Type Names (total 11)
/* sort by: | */
ReadBytes uint64 ReadCount uint64 WriteBytes uint64 WriteCount uint64 ( IOCountersStat) String() string IOCountersStat : expvar.Var IOCountersStat : fmt.Stringer func (*Process).IOCounters() (*IOCountersStat, error) func (*Process).IOCountersWithContext(ctx context.Context) (*IOCountersStat, error)
MemoryInfoExStat is different between OSes // bytes // bytes // bytes // bytes // bytes // bytes // bytes ( MemoryInfoExStat) String() string MemoryInfoExStat : expvar.Var MemoryInfoExStat : fmt.Stringer func (*Process).MemoryInfoEx() (*MemoryInfoExStat, error) func (*Process).MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error)
// bytes // bytes // bytes // bytes // bytes // bytes // bytes ( MemoryInfoStat) String() string MemoryInfoStat : expvar.Var MemoryInfoStat : fmt.Stringer func (*Process).MemoryInfo() (*MemoryInfoStat, error) func (*Process).MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error)
Anonymous uint64 Path string PrivateClean uint64 PrivateDirty uint64 Pss uint64 Referenced uint64 Rss uint64 SharedClean uint64 SharedDirty uint64 Size uint64 Swap uint64 String returns JSON value of the process. MemoryMapsStat : expvar.Var MemoryMapsStat : fmt.Stringer func (*Process).MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) func (*Process).MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error)
Involuntary int64 Voluntary int64 ( NumCtxSwitchesStat) String() string NumCtxSwitchesStat : expvar.Var NumCtxSwitchesStat : fmt.Stringer func (*Process).NumCtxSwitches() (*NumCtxSwitchesStat, error) func (*Process).NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error)
Fd uint64 Path string ( OpenFilesStat) String() string OpenFilesStat : expvar.Var OpenFilesStat : fmt.Stringer func (*Process).OpenFiles() ([]OpenFilesStat, error) func (*Process).OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error)
ChildMajorFaults uint64 ChildMinorFaults uint64 MajorFaults uint64 MinorFaults uint64 func (*Process).PageFaults() (*PageFaultsStat, error) func (*Process).PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error)
Pid int32 Background returns true if the process is in background, false otherwise. (*Process) BackgroundWithContext(ctx context.Context) (bool, error) CPUAffinity returns CPU affinity of the process. (*Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) CPUPercent returns how many percent of the CPU time this process uses (*Process) CPUPercentWithContext(ctx context.Context) (float64, error) Children returns the children of the process represented as a slice of pointers to Process type. (*Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) Cmdline returns the command line arguments of the process as a string with each argument separated by 0x20 ascii character. CmdlineSlice returns the command line arguments of the process as a slice with each element being an argument. (*Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) (*Process) CmdlineWithContext(ctx context.Context) (string, error) Connections returns a slice of net.ConnectionStat used by the process. This returns all kind of the connection. This means TCP, UDP or UNIX. ConnectionsMax returns a slice of net.ConnectionStat used by the process at most `max`. (*Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) (*Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) CreateTime returns created time of the process in milliseconds since the epoch, in UTC. (*Process) CreateTimeWithContext(ctx context.Context) (int64, error) Cwd returns current working directory of the process. (*Process) CwdWithContext(ctx context.Context) (string, error) Environ returns the environment variables of the process. (*Process) EnvironWithContext(ctx context.Context) ([]string, error) Exe returns executable path of the process. (*Process) ExeWithContext(ctx context.Context) (string, error) Foreground returns true if the process is in foreground, false otherwise. (*Process) ForegroundWithContext(ctx context.Context) (bool, error) Gids returns group ids of the process as a slice of the int (*Process) GidsWithContext(ctx context.Context) ([]int32, error) Groups returns all group IDs(include supplementary groups) of the process as a slice of the int (*Process) GroupsWithContext(ctx context.Context) ([]int32, error) IOCounters returns IO Counters. (*Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) IOnice returns process I/O nice value (priority). (*Process) IOniceWithContext(ctx context.Context) (int32, error) IsRunning returns whether the process is still running or not. (*Process) IsRunningWithContext(ctx context.Context) (bool, error) Kill sends SIGKILL to the process. (*Process) KillWithContext(ctx context.Context) error MemoryInfo returns generic process memory information, such as RSS and VMS. MemoryInfoEx returns platform-specific process memory information. (*Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) (*Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) MemoryMaps get memory maps from /proc/(pid)/smaps (*Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) MemoryPercent returns how many percent of the total RAM this process uses (*Process) MemoryPercentWithContext(ctx context.Context) (float32, error) Name returns name of the process. (*Process) NameWithContext(ctx context.Context) (string, error) Nice returns a nice value (priority). (*Process) NiceWithContext(ctx context.Context) (int32, error) NumCtxSwitches returns the number of the context switches of the process. (*Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) NumFDs returns the number of File Descriptors used by the process. (*Process) NumFDsWithContext(ctx context.Context) (int32, error) NumThreads returns the number of threads used by the process. (*Process) NumThreadsWithContext(ctx context.Context) (int32, error) OpenFiles returns a slice of OpenFilesStat opend by the process. OpenFilesStat includes a file path and file descriptor. (*Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) PageFaults returns the process's page fault counters. (*Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) Parent returns parent Process of the process. ParentWithContext returns parent Process of the process. If interval is 0, return difference from last call(non-blocking). If interval > 0, wait interval sec and return difference between start and end. (*Process) PercentWithContext(ctx context.Context, interval time.Duration) (float64, error) Ppid returns Parent Process ID of the process. (*Process) PpidWithContext(ctx context.Context) (int32, error) Resume sends SIGCONT to the process. (*Process) ResumeWithContext(ctx context.Context) error Rlimit returns Resource Limits. RlimitUsage returns Resource Limits. If gatherUsed is true, the currently used value will be gathered and added to the resulting RlimitStat. (*Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) (*Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) SendSignal sends a unix.Signal to the process. (*Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) error Status returns the process status. Return value could be one of these. R: Running S: Sleep T: Stop I: Idle Z: Zombie W: Wait L: Lock The character is same within all supported platforms. (*Process) StatusWithContext(ctx context.Context) ([]string, error) ( Process) String() string Suspend sends SIGSTOP to the process. (*Process) SuspendWithContext(ctx context.Context) error Terminal returns a terminal which is associated with the process. (*Process) TerminalWithContext(ctx context.Context) (string, error) Terminate sends SIGTERM to the process. (*Process) TerminateWithContext(ctx context.Context) error Tgid returns thread group id of the process. (*Process) TgidWithContext(ctx context.Context) (int32, error) (*Process) Threads() (map[int32]*cpu.TimesStat, error) (*Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) Times returns CPU times of the process. (*Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) Uids returns user ids of the process as a slice of the int (*Process) UidsWithContext(ctx context.Context) ([]int32, error) Username returns a username of the process. (*Process) UsernameWithContext(ctx context.Context) (string, error) Process : expvar.Var Process : fmt.Stringer func NewProcess(pid int32) (*Process, error) func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) func Processes() ([]*Process, error) func ProcessesWithContext(ctx context.Context) ([]*Process, error) func (*Process).Children() ([]*Process, error) func (*Process).ChildrenWithContext(ctx context.Context) ([]*Process, error) func (*Process).Parent() (*Process, error) func (*Process).ParentWithContext(ctx context.Context) (*Process, error)
Hard uint64 Resource int32 Soft uint64 Used uint64 ( RlimitStat) String() string RlimitStat : expvar.Var RlimitStat : fmt.Stringer func (*Process).Rlimit() ([]RlimitStat, error) func (*Process).RlimitUsage(gatherUsed bool) ([]RlimitStat, error) func (*Process).RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) func (*Process).RlimitWithContext(ctx context.Context) ([]RlimitStat, error)
type Signal = syscall.Signal (basic type)
Package-Level Functions (total 9)
EnableBootTimeCache change cache behavior of BootTime. If true, cache BootTime value. Default is false.
NewProcess creates a new Process instance, it only stores the pid and checks that the process exists. Other method on Process can be used to get more information about the process. An error will be returned if the process does not exist.
func PidExists(pid int32) (bool, error)
Pids returns a slice of process ID list which are running now.
Processes returns a slice of pointers to Process structs for all currently running processes.
Package-Level Variables (total 3)
Package-Level Constants (total 29)
Blocked marks a task waiting on a short, uninterruptible operation (usually I/O)
Process status
Idle marks a task sleeping for more than about 20 seconds
Lock marks a task waiting to acquire a lock
Process status
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Running marks a task a running or runnable (on the run queue)
Sleep marks task waiting for short, interruptible operation
Stop marks a stopped process
Process status
Process status
Wait marks an idle interrupt thread (or paging in pre 2.6.xx Linux)
Zombie marks a defunct process, terminated but not reaped by its parent