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