pkg.re/essentialkaos/ek@v12.36.0+incompatible/system/process/process_windows.go (about) 1 // +build windows 2 3 package process 4 5 // ////////////////////////////////////////////////////////////////////////////////// // 6 // // 7 // Copyright (c) 2021 ESSENTIAL KAOS // 8 // Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> // 9 // // 10 // ////////////////////////////////////////////////////////////////////////////////// // 11 12 import ( 13 "time" 14 ) 15 16 // ////////////////////////////////////////////////////////////////////////////////// // 17 18 const ( 19 STATE_RUNNING = "R" 20 STATE_SLEEPING = "S" 21 STATE_DISK_WAIT = "D" 22 STATE_ZOMBIE = "Z" 23 STATE_STOPPED = "T" 24 STATE_DEAD = "X" 25 STATE_WAKEKILL = "K" 26 STATE_WAKING = "W" 27 STATE_PARKED = "P" 28 ) 29 30 // ////////////////////////////////////////////////////////////////////////////////// // 31 32 // ProcSample contains value for usage calculation 33 type ProcSample uint 34 35 // ProcInfo contains partial info from /proc/[PID]/stat 36 type ProcInfo struct { 37 PID int `json:"pid"` // The process ID 38 Comm string `json:"comm"` // The filename of the executable, in parentheses 39 State string `json:"state"` // Process state 40 PPID int `json:"ppid"` // The PID of the parent of this process 41 Session int `json:"session"` // The session ID of the process 42 TTYNR int `json:"tty_nr"` // The controlling terminal of the process 43 TPGid int `json:"tpgid"` // The ID of the foreground process group of the controlling terminal of the process 44 UTime uint64 `json:"utime"` // Amount of time that this process has been scheduled in user mode, measured in clock ticks 45 STime uint64 `json:"stime"` // Amount of time that this process has been scheduled in kernel mode, measured in clock ticks 46 CUTime uint64 `json:"cutime"` // Amount of time that this process's waited-for children have been scheduled in user mode, measured in clock ticks 47 CSTime uint64 `json:"cstime"` // Amount of time that this process's waited-for children have been scheduled in kernel mode, measured in clock ticks 48 Priority int `json:"priority"` // Priority 49 Nice int `json:"nice"` // The nice value 50 NumThreads int `json:"num_threads"` // Number of threads in this process 51 } 52 53 // MemInfo contains process memory usage stats 54 type MemInfo struct { 55 VmPeak uint64 `json:"peak"` // Peak virtual memory size 56 VmSize uint64 `json:"size"` // Virtual memory size 57 VmLck uint64 `json:"lck"` // Locked memory size 58 VmPin uint64 `json:"pin"` // Pinned memory size (since Linux 3.2) 59 VmHWM uint64 `json:"hwm"` // Peak resident set size ("high water mark") 60 VmRSS uint64 `json:"rss"` // Resident set size 61 VmData uint64 `json:"data"` // Size of data 62 VmStk uint64 `json:"stk"` // Size of stack 63 VmExe uint64 `json:"exe"` // Size of text segments 64 VmLib uint64 `json:"lib"` // Shared library code size 65 VmPTE uint64 `json:"pte"` // Page table entries size (since Linux 2.6.10) 66 VmSwap uint64 `json:"swap"` // Swap size 67 } 68 69 // MountInfo contains information about mounts 70 // https://www.kernel.org/doc/Documentation/filesystems/proc.txt 71 type MountInfo struct { 72 MountID uint16 `json:"mount_id"` // unique identifier of the mount (may be reused after umount) 73 ParentID uint16 `json:"parent_id"` // ID of parent (or of self for the top of the mount tree) 74 StDevMajor uint16 `json:"stdev_major"` // major value of st_dev for files on filesystem 75 StDevMinor uint16 `json:"stdev_minor"` // minor value of st_dev for files on filesystem 76 Root string `json:"root"` // root of the mount within the filesystem 77 MountPoint string `json:"mount_point"` // mount point relative to the process's root 78 MountOptions []string `json:"mount_options"` // per mount options 79 OptionalFields []string `json:"optional_fields"` // zero or more fields of the form "tag[:value]" 80 FSType string `json:"fs_type"` // name of filesystem of the form "type[.subtype]" 81 MountSource string `json:"mount_source"` // filesystem specific information or "none" 82 SuperOptions []string `json:"super_options"` // per super block options 83 } 84 85 // ////////////////////////////////////////////////////////////////////////////////// // 86 87 // ToSample converts ProcInfo to ProcSample for CPU usage calculation 88 func (pi *ProcInfo) ToSample() ProcSample { 89 return 0 90 } 91 92 // ////////////////////////////////////////////////////////////////////////////////// // 93 94 // GetInfo returns process info from procfs 95 func GetInfo(pid int) (*ProcInfo, error) { 96 return nil, nil 97 } 98 99 // GetSample returns ProcSample for CPU usage calculation 100 func GetSample(pid int) (ProcSample, error) { 101 return 0, nil 102 } 103 104 // CalculateCPUUsage calculate CPU usage 105 func CalculateCPUUsage(s1, s2 ProcSample, duration time.Duration) float64 { 106 return 0.0 107 } 108 109 // GetMemInfo returns info about process memory usage 110 func GetMemInfo(pid int) (*MemInfo, error) { 111 return nil, nil 112 } 113 114 // GetMountInfo returns info about process mounts 115 func GetMountInfo(pid int) ([]*MountInfo, error) { 116 return nil, nil 117 } 118 119 // GetCPUPriority returns process CPU scheduling priority (PR, NI, error) 120 func GetCPUPriority(pid int) (int, int, error) { 121 return 0, 0, nil 122 } 123 124 // SetCPUPriority sets process CPU scheduling priority 125 func SetCPUPriority(pid, niceness int) error { 126 return nil 127 } 128 129 // GetIOPriority returns process IO scheduling priority (class, classdata, error) 130 func GetIOPriority(pid int) (int, int, error) { 131 return 0, 0, nil 132 } 133 134 // SetIOPriority sets process IO scheduling priority 135 func SetIOPriority(pid, class, classdata int) error { 136 return nil 137 }