2017-02-01 16:36:24 +00:00
|
|
|
// +build !darwin,!linux,!freebsd,!openbsd,!windows
|
|
|
|
|
|
|
|
package process
|
|
|
|
|
|
|
|
import (
|
2018-10-19 18:33:23 +00:00
|
|
|
"context"
|
2017-02-01 16:36:24 +00:00
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"github.com/shirou/gopsutil/cpu"
|
|
|
|
"github.com/shirou/gopsutil/internal/common"
|
|
|
|
"github.com/shirou/gopsutil/net"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MemoryMapsStat struct {
|
|
|
|
Path string `json:"path"`
|
|
|
|
Rss uint64 `json:"rss"`
|
|
|
|
Size uint64 `json:"size"`
|
|
|
|
Pss uint64 `json:"pss"`
|
|
|
|
SharedClean uint64 `json:"sharedClean"`
|
|
|
|
SharedDirty uint64 `json:"sharedDirty"`
|
|
|
|
PrivateClean uint64 `json:"privateClean"`
|
|
|
|
PrivateDirty uint64 `json:"privateDirty"`
|
|
|
|
Referenced uint64 `json:"referenced"`
|
|
|
|
Anonymous uint64 `json:"anonymous"`
|
|
|
|
Swap uint64 `json:"swap"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type MemoryInfoExStat struct {
|
|
|
|
}
|
|
|
|
|
2020-07-01 12:47:56 +00:00
|
|
|
func pidsWithContext(ctx context.Context) ([]int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return []int32{}, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
|
2018-10-19 18:33:23 +00:00
|
|
|
func Processes() ([]*Process, error) {
|
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
|
|
|
|
func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
|
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
|
2020-07-01 12:47:56 +00:00
|
|
|
func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
|
|
|
|
pids, err := PidsWithContext(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, i := range pids {
|
|
|
|
if i == pid {
|
|
|
|
return true, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false, err
|
2017-02-01 16:36:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) Ppid() (int32, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.PpidWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return 0, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Name() (string, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.NameWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) NameWithContext(ctx context.Context) (string, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return "", common.ErrNotImplementedError
|
|
|
|
}
|
2018-10-19 18:33:23 +00:00
|
|
|
func (p *Process) Tgid() (int32, error) {
|
|
|
|
return 0, common.ErrNotImplementedError
|
|
|
|
}
|
2017-02-01 16:36:24 +00:00
|
|
|
func (p *Process) Exe() (string, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.ExeWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return "", common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Cmdline() (string, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.CmdlineWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return "", common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) CmdlineSlice() ([]string, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.CmdlineSliceWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return []string{}, common.ErrNotImplementedError
|
|
|
|
}
|
2018-10-19 18:33:23 +00:00
|
|
|
|
2020-07-01 12:47:56 +00:00
|
|
|
func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return 0, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Cwd() (string, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.CwdWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return "", common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Parent() (*Process, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.ParentWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Status() (string, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.StatusWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) StatusWithContext(ctx context.Context) (string, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return "", common.ErrNotImplementedError
|
|
|
|
}
|
2020-07-01 12:47:56 +00:00
|
|
|
func (p *Process) Foreground() (bool, error) {
|
|
|
|
return p.ForegroundWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
|
|
|
|
return false, common.ErrNotImplementedError
|
|
|
|
}
|
2017-02-01 16:36:24 +00:00
|
|
|
func (p *Process) Uids() ([]int32, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.UidsWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return []int32{}, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Gids() ([]int32, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.GidsWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return []int32{}, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Terminal() (string, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.TerminalWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return "", common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Nice() (int32, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.NiceWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return 0, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) IOnice() (int32, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.IOniceWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return 0, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.RlimitWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
|
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error) {
|
|
|
|
return p.RlimitUsageWithContext(context.Background(), gatherUsed)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.IOCountersWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.NumCtxSwitchesWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) NumFDs() (int32, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.NumFDsWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return 0, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) NumThreads() (int32, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.NumThreadsWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return 0, common.ErrNotImplementedError
|
|
|
|
}
|
2018-10-19 18:33:23 +00:00
|
|
|
func (p *Process) Threads() (map[int32]*cpu.TimesStat, error) {
|
|
|
|
return p.ThreadsWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Times() (*cpu.TimesStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.TimesWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) CPUAffinity() ([]int32, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.CPUAffinityWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.MemoryInfoWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.MemoryInfoExWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
2020-07-01 12:47:56 +00:00
|
|
|
func (p *Process) PageFaults() (*PageFaultsStat, error) {
|
|
|
|
return p.PageFaultsWithContext(context.Background())
|
|
|
|
}
|
|
|
|
func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
|
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
2017-02-01 16:36:24 +00:00
|
|
|
func (p *Process) Children() ([]*Process, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.ChildrenWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.OpenFilesWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return []OpenFilesStat{}, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Connections() ([]net.ConnectionStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.ConnectionsWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return []net.ConnectionStat{}, common.ErrNotImplementedError
|
|
|
|
}
|
2020-07-01 12:47:56 +00:00
|
|
|
|
|
|
|
func (p *Process) ConnectionsMax(max int) ([]net.ConnectionStat, error) {
|
|
|
|
return p.ConnectionsMaxWithContext(context.Background(), max)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) {
|
|
|
|
return []net.ConnectionStat{}, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
|
2017-02-01 16:36:24 +00:00
|
|
|
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.NetIOCountersWithContext(context.Background(), pernic)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return []net.IOCountersStat{}, common.ErrNotImplementedError
|
|
|
|
}
|
2018-10-19 18:33:23 +00:00
|
|
|
|
2017-02-01 16:36:24 +00:00
|
|
|
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.MemoryMapsWithContext(context.Background(), grouped)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return nil, common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) SendSignal(sig syscall.Signal) error {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.SendSignalWithContext(context.Background(), sig)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) error {
|
2017-02-01 16:36:24 +00:00
|
|
|
return common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Suspend() error {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.SuspendWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) SuspendWithContext(ctx context.Context) error {
|
2017-02-01 16:36:24 +00:00
|
|
|
return common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Resume() error {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.ResumeWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) ResumeWithContext(ctx context.Context) error {
|
2017-02-01 16:36:24 +00:00
|
|
|
return common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Terminate() error {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.TerminateWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) TerminateWithContext(ctx context.Context) error {
|
2017-02-01 16:36:24 +00:00
|
|
|
return common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Kill() error {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.KillWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) KillWithContext(ctx context.Context) error {
|
2017-02-01 16:36:24 +00:00
|
|
|
return common.ErrNotImplementedError
|
|
|
|
}
|
|
|
|
func (p *Process) Username() (string, error) {
|
2018-10-19 18:33:23 +00:00
|
|
|
return p.UsernameWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
|
2017-02-01 16:36:24 +00:00
|
|
|
return "", common.ErrNotImplementedError
|
|
|
|
}
|