package process
import "github.com/shirou/gopsutil/process"
Index ¶
- Constants
- Variables
- func PidExists(pid int32) (bool, error)
- func PidExistsWithContext(ctx context.Context, pid int32) (bool, error)
- func Pids() ([]int32, error)
- func PidsWithContext(ctx context.Context) ([]int32, error)
- type IOCountersStat
- type MemoryInfoExStat
- type MemoryInfoStat
- type MemoryMapsStat
- type NumCtxSwitchesStat
- type OpenFilesStat
- type PROCESS_MEMORY_COUNTERS
- type PageFaultsStat
- type Process
- func NewProcess(pid int32) (*Process, error)
- func Processes() ([]*Process, error)
- func ProcessesWithContext(ctx context.Context) ([]*Process, error)
- func (p *Process) Background() (bool, error)
- func (p *Process) BackgroundWithContext(ctx context.Context) (bool, error)
- func (p *Process) CPUAffinity() ([]int32, error)
- func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error)
- func (p *Process) CPUPercent() (float64, error)
- func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error)
- func (p *Process) Children() ([]*Process, error)
- func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error)
- func (p *Process) Cmdline() (string, error)
- func (p *Process) CmdlineSlice() ([]string, error)
- func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error)
- func (p *Process) CmdlineWithContext(ctx context.Context) (string, error)
- func (p *Process) Connections() ([]net.ConnectionStat, error)
- func (p *Process) ConnectionsMax(max int) ([]net.ConnectionStat, error)
- func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error)
- func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error)
- func (p *Process) CreateTime() (int64, error)
- func (p *Process) CreateTimeWithContext(ctx context.Context) (int64, error)
- func (p *Process) Cwd() (string, error)
- func (p *Process) CwdWithContext(ctx context.Context) (string, error)
- func (p *Process) Exe() (string, error)
- func (p *Process) ExeWithContext(ctx context.Context) (string, error)
- func (p *Process) Foreground() (bool, error)
- func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error)
- func (p *Process) Gids() ([]int32, error)
- func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error)
- func (p *Process) IOCounters() (*IOCountersStat, error)
- func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error)
- func (p *Process) IOnice() (int32, error)
- func (p *Process) IOniceWithContext(ctx context.Context) (int32, error)
- func (p *Process) IsRunning() (bool, error)
- func (p *Process) IsRunningWithContext(ctx context.Context) (bool, error)
- func (p *Process) Kill() error
- func (p *Process) KillWithContext(ctx context.Context) error
- func (p *Process) MemoryInfo() (*MemoryInfoStat, error)
- func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error)
- func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error)
- func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error)
- func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error)
- func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error)
- func (p *Process) MemoryPercent() (float32, error)
- func (p *Process) MemoryPercentWithContext(ctx context.Context) (float32, error)
- func (p *Process) Name() (string, error)
- func (p *Process) NameWithContext(ctx context.Context) (string, error)
- func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error)
- func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error)
- func (p *Process) Nice() (int32, error)
- func (p *Process) NiceWithContext(ctx context.Context) (int32, error)
- func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error)
- func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error)
- func (p *Process) NumFDs() (int32, error)
- func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error)
- func (p *Process) NumThreads() (int32, error)
- func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error)
- func (p *Process) OpenFiles() ([]OpenFilesStat, error)
- func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error)
- func (p *Process) PageFaults() (*PageFaultsStat, error)
- func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error)
- func (p *Process) Parent() (*Process, error)
- func (p *Process) ParentWithContext(ctx context.Context) (*Process, error)
- func (p *Process) Percent(interval time.Duration) (float64, error)
- func (p *Process) PercentWithContext(ctx context.Context, interval time.Duration) (float64, error)
- func (p *Process) Ppid() (int32, error)
- func (p *Process) PpidWithContext(ctx context.Context) (int32, error)
- func (p *Process) Resume() error
- func (p *Process) ResumeWithContext(ctx context.Context) error
- func (p *Process) Rlimit() ([]RlimitStat, error)
- func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error)
- func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error)
- func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error)
- func (p *Process) SendSignal(sig windows.Signal) error
- func (p *Process) SendSignalWithContext(ctx context.Context, sig windows.Signal) error
- func (p *Process) Status() (string, error)
- func (p *Process) StatusWithContext(ctx context.Context) (string, error)
- func (p Process) String() string
- func (p *Process) Suspend() error
- func (p *Process) SuspendWithContext(ctx context.Context) error
- func (p *Process) Terminal() (string, error)
- func (p *Process) TerminalWithContext(ctx context.Context) (string, error)
- func (p *Process) Terminate() error
- func (p *Process) TerminateWithContext(ctx context.Context) error
- func (p *Process) Tgid() (int32, error)
- func (p *Process) Threads() (map[int32]*cpu.TimesStat, error)
- func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error)
- func (p *Process) Times() (*cpu.TimesStat, error)
- func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
- func (p *Process) Uids() ([]int32, error)
- func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error)
- func (p *Process) Username() (string, error)
- func (p *Process) UsernameWithContext(ctx context.Context) (string, error)
- type RlimitStat
- type SYSTEM_TIMES
- type SignalInfoStat
- type SystemProcessInformation
- type Win32_Process
Constants ¶
const ( RLIMIT_CPU int32 = 0 RLIMIT_FSIZE int32 = 1 RLIMIT_DATA int32 = 2 RLIMIT_STACK int32 = 3 RLIMIT_CORE int32 = 4 RLIMIT_RSS int32 = 5 RLIMIT_NPROC int32 = 6 RLIMIT_NOFILE int32 = 7 RLIMIT_MEMLOCK int32 = 8 RLIMIT_AS int32 = 9 RLIMIT_LOCKS int32 = 10 RLIMIT_SIGPENDING int32 = 11 RLIMIT_MSGQUEUE int32 = 12 RLIMIT_NICE int32 = 13 RLIMIT_RTPRIO int32 = 14 RLIMIT_RTTIME int32 = 15 )
Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h from libc6-dev package in Ubuntu 16.10
Variables ¶
var ( ErrorNoChildren = errors.New("process does not have children") ErrorProcessNotRunning = errors.New("process does not exist") )
Functions ¶
func PidExists ¶
func PidExistsWithContext ¶
func Pids ¶
Pids returns a slice of process ID list which are running now.
func PidsWithContext ¶
Types ¶
type IOCountersStat ¶
type IOCountersStat struct { ReadCount uint64 `json:"readCount"` WriteCount uint64 `json:"writeCount"` ReadBytes uint64 `json:"readBytes"` WriteBytes uint64 `json:"writeBytes"` }
func (IOCountersStat) String ¶
func (i IOCountersStat) String() string
type MemoryInfoExStat ¶
type MemoryInfoExStat struct { }
Memory_info_ex is different between OSes
type MemoryInfoStat ¶
type MemoryInfoStat struct { RSS uint64 `json:"rss"` // bytes VMS uint64 `json:"vms"` // bytes HWM uint64 `json:"hwm"` // bytes Data uint64 `json:"data"` // bytes Stack uint64 `json:"stack"` // bytes Locked uint64 `json:"locked"` // bytes Swap uint64 `json:"swap"` // bytes }
func (MemoryInfoStat) String ¶
func (m MemoryInfoStat) String() string
type MemoryMapsStat ¶
type MemoryMapsStat struct { }
type NumCtxSwitchesStat ¶
type NumCtxSwitchesStat struct { Voluntary int64 `json:"voluntary"` Involuntary int64 `json:"involuntary"` }
func (NumCtxSwitchesStat) String ¶
func (p NumCtxSwitchesStat) String() string
type OpenFilesStat ¶
func (OpenFilesStat) String ¶
func (o OpenFilesStat) String() string
type PROCESS_MEMORY_COUNTERS ¶
type PROCESS_MEMORY_COUNTERS struct { CB uint32 PageFaultCount uint32 PeakWorkingSetSize uint64 WorkingSetSize uint64 QuotaPeakPagedPoolUsage uint64 QuotaPagedPoolUsage uint64 QuotaPeakNonPagedPoolUsage uint64 QuotaNonPagedPoolUsage uint64 PagefileUsage uint64 PeakPagefileUsage uint64 }
type PageFaultsStat ¶
type PageFaultsStat struct { MinorFaults uint64 `json:"minorFaults"` MajorFaults uint64 `json:"majorFaults"` ChildMinorFaults uint64 `json:"childMinorFaults"` ChildMajorFaults uint64 `json:"childMajorFaults"` }
type Process ¶
type Process struct { Pid int32 `json:"pid"` // contains filtered or unexported fields }
func NewProcess ¶
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 Processes ¶
Get processes
func ProcessesWithContext ¶
func (*Process) Background ¶
Background returns true if the process is in background, false otherwise.
func (*Process) BackgroundWithContext ¶
func (*Process) CPUAffinity ¶
func (*Process) CPUAffinityWithContext ¶
func (*Process) CPUPercent ¶
CPU_Percent returns how many percent of the CPU time this process uses
func (*Process) CPUPercentWithContext ¶
func (*Process) Children ¶
func (*Process) ChildrenWithContext ¶
func (*Process) Cmdline ¶
func (*Process) CmdlineSlice ¶
CmdlineSlice returns the command line arguments of the process as a slice with each element being an argument. This merely returns the CommandLine informations passed to the process split on the 0x20 ASCII character.
func (*Process) CmdlineSliceWithContext ¶
func (*Process) CmdlineWithContext ¶
func (*Process) Connections ¶
func (p *Process) Connections() ([]net.ConnectionStat, error)
func (*Process) ConnectionsMax ¶
func (p *Process) ConnectionsMax(max int) ([]net.ConnectionStat, error)
func (*Process) ConnectionsMaxWithContext ¶
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error)
func (*Process) ConnectionsWithContext ¶
func (*Process) CreateTime ¶
CreateTime returns created time of the process in milliseconds since the epoch, in UTC.
func (*Process) CreateTimeWithContext ¶
func (*Process) Cwd ¶
func (*Process) CwdWithContext ¶
func (*Process) Exe ¶
func (*Process) ExeWithContext ¶
func (*Process) Foreground ¶
func (*Process) ForegroundWithContext ¶
func (*Process) Gids ¶
func (*Process) GidsWithContext ¶
func (*Process) IOCounters ¶
func (p *Process) IOCounters() (*IOCountersStat, error)
func (*Process) IOCountersWithContext ¶
func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error)
func (*Process) IOnice ¶
func (*Process) IOniceWithContext ¶
func (*Process) IsRunning ¶
IsRunning returns whether the process is still running or not.
func (*Process) IsRunningWithContext ¶
func (*Process) Kill ¶
func (*Process) KillWithContext ¶
func (*Process) MemoryInfo ¶
func (p *Process) MemoryInfo() (*MemoryInfoStat, error)
func (*Process) MemoryInfoEx ¶
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error)
func (*Process) MemoryInfoExWithContext ¶
func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error)
func (*Process) MemoryInfoWithContext ¶
func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error)
func (*Process) MemoryMaps ¶
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error)
func (*Process) MemoryMapsWithContext ¶
func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error)
func (*Process) MemoryPercent ¶
MemoryPercent returns how many percent of the total RAM this process uses
func (*Process) MemoryPercentWithContext ¶
func (*Process) Name ¶
func (*Process) NameWithContext ¶
func (*Process) NetIOCounters ¶
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error)
func (*Process) NetIOCountersWithContext ¶
func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error)
func (*Process) Nice ¶
Nice returns priority in Windows
func (*Process) NiceWithContext ¶
func (*Process) NumCtxSwitches ¶
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error)
func (*Process) NumCtxSwitchesWithContext ¶
func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error)
func (*Process) NumFDs ¶
func (*Process) NumFDsWithContext ¶
func (*Process) NumThreads ¶
func (*Process) NumThreadsWithContext ¶
func (*Process) OpenFiles ¶
func (p *Process) OpenFiles() ([]OpenFilesStat, error)
func (*Process) OpenFilesWithContext ¶
func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error)
func (*Process) PageFaults ¶
func (p *Process) PageFaults() (*PageFaultsStat, error)
func (*Process) PageFaultsWithContext ¶
func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error)
func (*Process) Parent ¶
func (*Process) ParentWithContext ¶
func (*Process) Percent ¶
If interval is 0, return difference from last call(non-blocking). If interval > 0, wait interval sec and return diffrence between start and end.
func (*Process) PercentWithContext ¶
func (*Process) Ppid ¶
func (*Process) PpidWithContext ¶
func (*Process) Resume ¶
func (*Process) ResumeWithContext ¶
func (*Process) Rlimit ¶
func (p *Process) Rlimit() ([]RlimitStat, error)
func (*Process) RlimitUsage ¶
func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error)
func (*Process) RlimitUsageWithContext ¶
func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error)
func (*Process) RlimitWithContext ¶
func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error)
func (*Process) SendSignal ¶
func (*Process) SendSignalWithContext ¶
func (*Process) Status ¶
func (*Process) StatusWithContext ¶
func (Process) String ¶
func (*Process) Suspend ¶
func (*Process) SuspendWithContext ¶
func (*Process) Terminal ¶
func (*Process) TerminalWithContext ¶
func (*Process) Terminate ¶
func (*Process) TerminateWithContext ¶
func (*Process) Tgid ¶
func (*Process) Threads ¶
func (*Process) ThreadsWithContext ¶
func (*Process) Times ¶
func (*Process) TimesWithContext ¶
func (*Process) Uids ¶
func (*Process) UidsWithContext ¶
func (*Process) Username ¶
func (*Process) UsernameWithContext ¶
type RlimitStat ¶
type RlimitStat struct { Resource int32 `json:"resource"` Soft int32 `json:"soft"` //TODO too small. needs to be uint64 Hard int32 `json:"hard"` //TODO too small. needs to be uint64 Used uint64 `json:"used"` }
func (RlimitStat) String ¶
func (r RlimitStat) String() string
type SYSTEM_TIMES ¶
type SYSTEM_TIMES struct { CreateTime syscall.Filetime ExitTime syscall.Filetime KernelTime syscall.Filetime UserTime syscall.Filetime }
type SignalInfoStat ¶
type SignalInfoStat struct { PendingProcess uint64 `json:"pending_process"` PendingThread uint64 `json:"pending_thread"` Blocked uint64 `json:"blocked"` Ignored uint64 `json:"ignored"` Caught uint64 `json:"caught"` }
type SystemProcessInformation ¶
type SystemProcessInformation struct { NextEntryOffset uint64 NumberOfThreads uint64 Reserved1 [48]byte Reserved2 [3]byte UniqueProcessID uintptr Reserved3 uintptr HandleCount uint64 Reserved4 [4]byte Reserved5 [11]byte PeakPagefileUsage uint64 PrivatePageCount uint64 Reserved6 [6]uint64 }
type Win32_Process ¶
type Win32_Process struct { Name string ExecutablePath *string CommandLine *string Priority uint32 CreationDate *time.Time ProcessID uint32 ThreadCount uint32 Status *string ReadOperationCount uint64 ReadTransferCount uint64 WriteOperationCount uint64 WriteTransferCount uint64 CSCreationClassName string CSName string Caption *string CreationClassName string Description *string ExecutionState *uint16 HandleCount uint32 KernelModeTime uint64 MaximumWorkingSetSize *uint32 MinimumWorkingSetSize *uint32 OSCreationClassName string OSName string OtherOperationCount uint64 OtherTransferCount uint64 PageFaults uint32 PageFileUsage uint32 ParentProcessID uint32 PeakPageFileUsage uint32 PeakVirtualSize uint64 PeakWorkingSetSize uint32 PrivatePageCount uint64 TerminationDate *time.Time UserModeTime uint64 WorkingSetSize uint64 }
func GetWin32Proc ¶
func GetWin32Proc(pid int32) ([]Win32_Process, error)
func GetWin32ProcWithContext ¶
func GetWin32ProcWithContext(ctx context.Context, pid int32) ([]Win32_Process, error)
Source Files ¶
process.go process_windows.go process_windows_amd64.go
- Version
- v2.20.2+incompatible
- Published
- Mar 1, 2020
- Platform
- windows/amd64
- Imports
- 17 packages
- Last checked
- 7 hours ago –
Tools for package owners.