mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-20 00:50:06 +08:00
chore: remove depend of gopsutil
This commit is contained in:
parent
0c25831726
commit
0992ee8adf
8
component/memory/memory.go
Normal file
8
component/memory/memory.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Package memory return MemoryInfoStat
|
||||||
|
// modify from https://github.com/shirou/gopsutil/tree/v4.25.1/process
|
||||||
|
package memory
|
||||||
|
|
||||||
|
type MemoryInfoStat struct {
|
||||||
|
RSS uint64 `json:"rss"` // bytes
|
||||||
|
VMS uint64 `json:"vms"` // bytes
|
||||||
|
}
|
||||||
116
component/memory/memory_darwin.go
Normal file
116
component/memory/memory_darwin.go
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/ebitengine/purego"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PROC_PIDTASKINFO = 4
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProcTaskInfo struct {
|
||||||
|
Virtual_size uint64
|
||||||
|
Resident_size uint64
|
||||||
|
Total_user uint64
|
||||||
|
Total_system uint64
|
||||||
|
Threads_user uint64
|
||||||
|
Threads_system uint64
|
||||||
|
Policy int32
|
||||||
|
Faults int32
|
||||||
|
Pageins int32
|
||||||
|
Cow_faults int32
|
||||||
|
Messages_sent int32
|
||||||
|
Messages_received int32
|
||||||
|
Syscalls_mach int32
|
||||||
|
Syscalls_unix int32
|
||||||
|
Csw int32
|
||||||
|
Threadnum int32
|
||||||
|
Numrunning int32
|
||||||
|
Priority int32
|
||||||
|
}
|
||||||
|
|
||||||
|
// Library represents a dynamic library loaded by purego.
|
||||||
|
type Library struct {
|
||||||
|
addr uintptr
|
||||||
|
path string
|
||||||
|
close func()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLibrary(path string) (*Library, error) {
|
||||||
|
lib, err := purego.Dlopen(path, purego.RTLD_LAZY|purego.RTLD_GLOBAL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
closeFunc := func() {
|
||||||
|
purego.Dlclose(lib)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Library{
|
||||||
|
addr: lib,
|
||||||
|
path: path,
|
||||||
|
close: closeFunc,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lib *Library) Dlsym(symbol string) (uintptr, error) {
|
||||||
|
return purego.Dlsym(lib.addr, symbol)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetFunc[T any](lib *Library, symbol string) T {
|
||||||
|
var fptr T
|
||||||
|
purego.RegisterLibFunc(&fptr, lib.addr, symbol)
|
||||||
|
return fptr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lib *Library) Close() {
|
||||||
|
lib.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// library paths
|
||||||
|
const (
|
||||||
|
System = "/usr/lib/libSystem.B.dylib"
|
||||||
|
)
|
||||||
|
|
||||||
|
// System functions and symbols.
|
||||||
|
type (
|
||||||
|
ProcPidInfoFunc func(pid, flavor int32, arg uint64, buffer uintptr, bufferSize int32) int32
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ProcPidInfoSym = "proc_pidinfo"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
procPidInfo ProcPidInfoFunc
|
||||||
|
)
|
||||||
|
|
||||||
|
func registerFuncs() (*Library, error) {
|
||||||
|
lib, err := NewLibrary(System)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
procPidInfo = GetFunc[ProcPidInfoFunc](lib, ProcPidInfoSym)
|
||||||
|
|
||||||
|
return lib, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMemoryInfo(pid int32) (*MemoryInfoStat, error) {
|
||||||
|
lib, err := registerFuncs()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer lib.Close()
|
||||||
|
|
||||||
|
var ti ProcTaskInfo
|
||||||
|
procPidInfo(pid, PROC_PIDTASKINFO, 0, uintptr(unsafe.Pointer(&ti)), int32(unsafe.Sizeof(ti)))
|
||||||
|
|
||||||
|
ret := &MemoryInfoStat{
|
||||||
|
RSS: uint64(ti.Resident_size),
|
||||||
|
VMS: uint64(ti.Virtual_size),
|
||||||
|
}
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
11
component/memory/memory_falllback.go
Normal file
11
component/memory/memory_falllback.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//go:build !darwin && !linux && !freebsd && !openbsd && !windows
|
||||||
|
|
||||||
|
package memory
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
var ErrNotImplementedError = errors.New("not implemented yet")
|
||||||
|
|
||||||
|
func GetMemoryInfo(pid int32) (*MemoryInfoStat, error) {
|
||||||
|
return nil, ErrNotImplementedError
|
||||||
|
}
|
||||||
97
component/memory/memory_freebsd.go
Normal file
97
component/memory/memory_freebsd.go
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CTLKern = 1
|
||||||
|
KernProc = 14
|
||||||
|
KernProcPID = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func CallSyscall(mib []int32) ([]byte, uint64, error) {
|
||||||
|
mibptr := unsafe.Pointer(&mib[0])
|
||||||
|
miblen := uint64(len(mib))
|
||||||
|
|
||||||
|
// get required buffer size
|
||||||
|
length := uint64(0)
|
||||||
|
_, _, err := unix.Syscall6(
|
||||||
|
unix.SYS___SYSCTL,
|
||||||
|
uintptr(mibptr),
|
||||||
|
uintptr(miblen),
|
||||||
|
0,
|
||||||
|
uintptr(unsafe.Pointer(&length)),
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
if err != 0 {
|
||||||
|
var b []byte
|
||||||
|
return b, length, err
|
||||||
|
}
|
||||||
|
if length == 0 {
|
||||||
|
var b []byte
|
||||||
|
return b, length, err
|
||||||
|
}
|
||||||
|
// get proc info itself
|
||||||
|
buf := make([]byte, length)
|
||||||
|
_, _, err = unix.Syscall6(
|
||||||
|
unix.SYS___SYSCTL,
|
||||||
|
uintptr(mibptr),
|
||||||
|
uintptr(miblen),
|
||||||
|
uintptr(unsafe.Pointer(&buf[0])),
|
||||||
|
uintptr(unsafe.Pointer(&length)),
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
if err != 0 {
|
||||||
|
return buf, length, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf, length, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseKinfoProc(buf []byte) (KinfoProc, error) {
|
||||||
|
var k KinfoProc
|
||||||
|
br := bytes.NewReader(buf)
|
||||||
|
err := binary.Read(br, binary.LittleEndian, &k)
|
||||||
|
return k, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func getKProc(pid int32) (*KinfoProc, error) {
|
||||||
|
mib := []int32{CTLKern, KernProc, KernProcPID, pid}
|
||||||
|
|
||||||
|
buf, length, err := CallSyscall(mib)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if length != sizeOfKinfoProc {
|
||||||
|
return nil, errors.New("unexpected size of KinfoProc")
|
||||||
|
}
|
||||||
|
|
||||||
|
k, err := parseKinfoProc(buf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &k, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMemoryInfo(pid int32) (*MemoryInfoStat, error) {
|
||||||
|
k, err := getKProc(pid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
v, err := unix.Sysctl("vm.stats.vm.v_page_size")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pageSize := binary.LittleEndian.Uint16([]byte(v))
|
||||||
|
|
||||||
|
return &MemoryInfoStat{
|
||||||
|
RSS: uint64(k.Rssize) * uint64(pageSize),
|
||||||
|
VMS: uint64(k.Size),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
119
component/memory/memory_freebsd_386.go
Normal file
119
component/memory/memory_freebsd_386.go
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x300
|
||||||
|
|
||||||
|
type Timeval struct {
|
||||||
|
Sec int32
|
||||||
|
Usec int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Rusage struct {
|
||||||
|
Utime Timeval
|
||||||
|
Stime Timeval
|
||||||
|
Maxrss int32
|
||||||
|
Ixrss int32
|
||||||
|
Idrss int32
|
||||||
|
Isrss int32
|
||||||
|
Minflt int32
|
||||||
|
Majflt int32
|
||||||
|
Nswap int32
|
||||||
|
Inblock int32
|
||||||
|
Oublock int32
|
||||||
|
Msgsnd int32
|
||||||
|
Msgrcv int32
|
||||||
|
Nsignals int32
|
||||||
|
Nvcsw int32
|
||||||
|
Nivcsw int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Structsize int32
|
||||||
|
Layout int32
|
||||||
|
Args int32 /* pargs */
|
||||||
|
Paddr int32 /* proc */
|
||||||
|
Addr int32 /* user */
|
||||||
|
Tracep int32 /* vnode */
|
||||||
|
Textvp int32 /* vnode */
|
||||||
|
Fd int32 /* filedesc */
|
||||||
|
Vmspace int32 /* vmspace */
|
||||||
|
Wchan int32
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Sid int32
|
||||||
|
Tsid int32
|
||||||
|
Jobc int16
|
||||||
|
Spare_short1 int16
|
||||||
|
Tdev uint32
|
||||||
|
Siglist [16]byte /* sigset */
|
||||||
|
Sigmask [16]byte /* sigset */
|
||||||
|
Sigignore [16]byte /* sigset */
|
||||||
|
Sigcatch [16]byte /* sigset */
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Svuid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Ngroups int16
|
||||||
|
Spare_short2 int16
|
||||||
|
Groups [16]uint32
|
||||||
|
Size uint32
|
||||||
|
Rssize int32
|
||||||
|
Swrss int32
|
||||||
|
Tsize int32
|
||||||
|
Dsize int32
|
||||||
|
Ssize int32
|
||||||
|
Xstat uint16
|
||||||
|
Acflag uint16
|
||||||
|
Pctcpu uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Slptime uint32
|
||||||
|
Swtime uint32
|
||||||
|
Cow uint32
|
||||||
|
Runtime uint64
|
||||||
|
Start Timeval
|
||||||
|
Childtime Timeval
|
||||||
|
Flag int32
|
||||||
|
Kiflag int32
|
||||||
|
Traceflag int32
|
||||||
|
Stat int8
|
||||||
|
Nice int8
|
||||||
|
Lock int8
|
||||||
|
Rqindex int8
|
||||||
|
Oncpu uint8
|
||||||
|
Lastcpu uint8
|
||||||
|
Tdname [17]int8
|
||||||
|
Wmesg [9]int8
|
||||||
|
Login [18]int8
|
||||||
|
Lockname [9]int8
|
||||||
|
Comm [20]int8
|
||||||
|
Emul [17]int8
|
||||||
|
Loginclass [18]int8
|
||||||
|
Sparestrings [50]int8
|
||||||
|
Spareints [7]int32
|
||||||
|
Flag2 int32
|
||||||
|
Fibnum int32
|
||||||
|
Cr_flags uint32
|
||||||
|
Jid int32
|
||||||
|
Numthreads int32
|
||||||
|
Tid int32
|
||||||
|
Pri Priority
|
||||||
|
Rusage Rusage
|
||||||
|
Rusage_ch Rusage
|
||||||
|
Pcb int32 /* pcb */
|
||||||
|
Kstack int32
|
||||||
|
Udata int32
|
||||||
|
Tdaddr int32 /* thread */
|
||||||
|
Spareptrs [6]int32
|
||||||
|
Sparelongs [12]int32
|
||||||
|
Sflag int32
|
||||||
|
Tdflags int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Priority struct {
|
||||||
|
Class uint8
|
||||||
|
Level uint8
|
||||||
|
Native uint8
|
||||||
|
User uint8
|
||||||
|
}
|
||||||
125
component/memory/memory_freebsd_amd64.go
Normal file
125
component/memory/memory_freebsd_amd64.go
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x440
|
||||||
|
|
||||||
|
type Timeval struct {
|
||||||
|
Sec int64
|
||||||
|
Usec int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Rusage struct {
|
||||||
|
Utime Timeval
|
||||||
|
Stime Timeval
|
||||||
|
Maxrss int64
|
||||||
|
Ixrss int64
|
||||||
|
Idrss int64
|
||||||
|
Isrss int64
|
||||||
|
Minflt int64
|
||||||
|
Majflt int64
|
||||||
|
Nswap int64
|
||||||
|
Inblock int64
|
||||||
|
Oublock int64
|
||||||
|
Msgsnd int64
|
||||||
|
Msgrcv int64
|
||||||
|
Nsignals int64
|
||||||
|
Nvcsw int64
|
||||||
|
Nivcsw int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Structsize int32
|
||||||
|
Layout int32
|
||||||
|
Args int64 /* pargs */
|
||||||
|
Paddr int64 /* proc */
|
||||||
|
Addr int64 /* user */
|
||||||
|
Tracep int64 /* vnode */
|
||||||
|
Textvp int64 /* vnode */
|
||||||
|
Fd int64 /* filedesc */
|
||||||
|
Vmspace int64 /* vmspace */
|
||||||
|
Wchan int64
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Sid int32
|
||||||
|
Tsid int32
|
||||||
|
Jobc int16
|
||||||
|
Spare_short1 int16
|
||||||
|
Tdev_freebsd11 uint32
|
||||||
|
Siglist [16]byte /* sigset */
|
||||||
|
Sigmask [16]byte /* sigset */
|
||||||
|
Sigignore [16]byte /* sigset */
|
||||||
|
Sigcatch [16]byte /* sigset */
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Svuid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Ngroups int16
|
||||||
|
Spare_short2 int16
|
||||||
|
Groups [16]uint32
|
||||||
|
Size uint64
|
||||||
|
Rssize int64
|
||||||
|
Swrss int64
|
||||||
|
Tsize int64
|
||||||
|
Dsize int64
|
||||||
|
Ssize int64
|
||||||
|
Xstat uint16
|
||||||
|
Acflag uint16
|
||||||
|
Pctcpu uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Slptime uint32
|
||||||
|
Swtime uint32
|
||||||
|
Cow uint32
|
||||||
|
Runtime uint64
|
||||||
|
Start Timeval
|
||||||
|
Childtime Timeval
|
||||||
|
Flag int64
|
||||||
|
Kiflag int64
|
||||||
|
Traceflag int32
|
||||||
|
Stat int8
|
||||||
|
Nice int8
|
||||||
|
Lock int8
|
||||||
|
Rqindex int8
|
||||||
|
Oncpu_old uint8
|
||||||
|
Lastcpu_old uint8
|
||||||
|
Tdname [17]int8
|
||||||
|
Wmesg [9]int8
|
||||||
|
Login [18]int8
|
||||||
|
Lockname [9]int8
|
||||||
|
Comm [20]int8
|
||||||
|
Emul [17]int8
|
||||||
|
Loginclass [18]int8
|
||||||
|
Moretdname [4]int8
|
||||||
|
Sparestrings [46]int8
|
||||||
|
Spareints [2]int32
|
||||||
|
Tdev uint64
|
||||||
|
Oncpu int32
|
||||||
|
Lastcpu int32
|
||||||
|
Tracer int32
|
||||||
|
Flag2 int32
|
||||||
|
Fibnum int32
|
||||||
|
Cr_flags uint32
|
||||||
|
Jid int32
|
||||||
|
Numthreads int32
|
||||||
|
Tid int32
|
||||||
|
Pri Priority
|
||||||
|
Rusage Rusage
|
||||||
|
Rusage_ch Rusage
|
||||||
|
Pcb int64 /* pcb */
|
||||||
|
Kstack int64
|
||||||
|
Udata int64
|
||||||
|
Tdaddr int64 /* thread */
|
||||||
|
Pd int64 /* pwddesc, not accurate */
|
||||||
|
Spareptrs [5]int64
|
||||||
|
Sparelongs [12]int64
|
||||||
|
Sflag int64
|
||||||
|
Tdflags int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Priority struct {
|
||||||
|
Class uint8
|
||||||
|
Level uint8
|
||||||
|
Native uint8
|
||||||
|
User uint8
|
||||||
|
}
|
||||||
119
component/memory/memory_freebsd_arm.go
Normal file
119
component/memory/memory_freebsd_arm.go
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x440
|
||||||
|
|
||||||
|
type Timeval struct {
|
||||||
|
Sec int64
|
||||||
|
Usec int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Rusage struct {
|
||||||
|
Utime Timeval
|
||||||
|
Stime Timeval
|
||||||
|
Maxrss int32
|
||||||
|
Ixrss int32
|
||||||
|
Idrss int32
|
||||||
|
Isrss int32
|
||||||
|
Minflt int32
|
||||||
|
Majflt int32
|
||||||
|
Nswap int32
|
||||||
|
Inblock int32
|
||||||
|
Oublock int32
|
||||||
|
Msgsnd int32
|
||||||
|
Msgrcv int32
|
||||||
|
Nsignals int32
|
||||||
|
Nvcsw int32
|
||||||
|
Nivcsw int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Structsize int32
|
||||||
|
Layout int32
|
||||||
|
Args int32 /* pargs */
|
||||||
|
Paddr int32 /* proc */
|
||||||
|
Addr int32 /* user */
|
||||||
|
Tracep int32 /* vnode */
|
||||||
|
Textvp int32 /* vnode */
|
||||||
|
Fd int32 /* filedesc */
|
||||||
|
Vmspace int32 /* vmspace */
|
||||||
|
Wchan int32
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Sid int32
|
||||||
|
Tsid int32
|
||||||
|
Jobc int16
|
||||||
|
Spare_short1 int16
|
||||||
|
Tdev uint32
|
||||||
|
Siglist [16]byte /* sigset */
|
||||||
|
Sigmask [16]byte /* sigset */
|
||||||
|
Sigignore [16]byte /* sigset */
|
||||||
|
Sigcatch [16]byte /* sigset */
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Svuid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Ngroups int16
|
||||||
|
Spare_short2 int16
|
||||||
|
Groups [16]uint32
|
||||||
|
Size uint32
|
||||||
|
Rssize int32
|
||||||
|
Swrss int32
|
||||||
|
Tsize int32
|
||||||
|
Dsize int32
|
||||||
|
Ssize int32
|
||||||
|
Xstat uint16
|
||||||
|
Acflag uint16
|
||||||
|
Pctcpu uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Slptime uint32
|
||||||
|
Swtime uint32
|
||||||
|
Cow uint32
|
||||||
|
Runtime uint64
|
||||||
|
Start Timeval
|
||||||
|
Childtime Timeval
|
||||||
|
Flag int32
|
||||||
|
Kiflag int32
|
||||||
|
Traceflag int32
|
||||||
|
Stat int8
|
||||||
|
Nice int8
|
||||||
|
Lock int8
|
||||||
|
Rqindex int8
|
||||||
|
Oncpu uint8
|
||||||
|
Lastcpu uint8
|
||||||
|
Tdname [17]int8
|
||||||
|
Wmesg [9]int8
|
||||||
|
Login [18]int8
|
||||||
|
Lockname [9]int8
|
||||||
|
Comm [20]int8
|
||||||
|
Emul [17]int8
|
||||||
|
Loginclass [18]int8
|
||||||
|
Sparestrings [50]int8
|
||||||
|
Spareints [4]int32
|
||||||
|
Flag2 int32
|
||||||
|
Fibnum int32
|
||||||
|
Cr_flags uint32
|
||||||
|
Jid int32
|
||||||
|
Numthreads int32
|
||||||
|
Tid int32
|
||||||
|
Pri Priority
|
||||||
|
Rusage Rusage
|
||||||
|
Rusage_ch Rusage
|
||||||
|
Pcb int32 /* pcb */
|
||||||
|
Kstack int32
|
||||||
|
Udata int32
|
||||||
|
Tdaddr int32 /* thread */
|
||||||
|
Spareptrs [6]int64
|
||||||
|
Sparelongs [12]int64
|
||||||
|
Sflag int64
|
||||||
|
Tdflags int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Priority struct {
|
||||||
|
Class uint8
|
||||||
|
Level uint8
|
||||||
|
Native uint8
|
||||||
|
User uint8
|
||||||
|
}
|
||||||
125
component/memory/memory_freebsd_arm64.go
Normal file
125
component/memory/memory_freebsd_arm64.go
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x440
|
||||||
|
|
||||||
|
type Timeval struct {
|
||||||
|
Sec int64
|
||||||
|
Usec int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Rusage struct {
|
||||||
|
Utime Timeval
|
||||||
|
Stime Timeval
|
||||||
|
Maxrss int64
|
||||||
|
Ixrss int64
|
||||||
|
Idrss int64
|
||||||
|
Isrss int64
|
||||||
|
Minflt int64
|
||||||
|
Majflt int64
|
||||||
|
Nswap int64
|
||||||
|
Inblock int64
|
||||||
|
Oublock int64
|
||||||
|
Msgsnd int64
|
||||||
|
Msgrcv int64
|
||||||
|
Nsignals int64
|
||||||
|
Nvcsw int64
|
||||||
|
Nivcsw int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Structsize int32
|
||||||
|
Layout int32
|
||||||
|
Args int64 /* pargs */
|
||||||
|
Paddr int64 /* proc */
|
||||||
|
Addr int64 /* user */
|
||||||
|
Tracep int64 /* vnode */
|
||||||
|
Textvp int64 /* vnode */
|
||||||
|
Fd int64 /* filedesc */
|
||||||
|
Vmspace int64 /* vmspace */
|
||||||
|
Wchan int64
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Sid int32
|
||||||
|
Tsid int32
|
||||||
|
Jobc int16
|
||||||
|
Spare_short1 int16
|
||||||
|
Tdev_freebsd11 uint32
|
||||||
|
Siglist [16]byte /* sigset */
|
||||||
|
Sigmask [16]byte /* sigset */
|
||||||
|
Sigignore [16]byte /* sigset */
|
||||||
|
Sigcatch [16]byte /* sigset */
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Svuid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Ngroups int16
|
||||||
|
Spare_short2 int16
|
||||||
|
Groups [16]uint32
|
||||||
|
Size uint64
|
||||||
|
Rssize int64
|
||||||
|
Swrss int64
|
||||||
|
Tsize int64
|
||||||
|
Dsize int64
|
||||||
|
Ssize int64
|
||||||
|
Xstat uint16
|
||||||
|
Acflag uint16
|
||||||
|
Pctcpu uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Slptime uint32
|
||||||
|
Swtime uint32
|
||||||
|
Cow uint32
|
||||||
|
Runtime uint64
|
||||||
|
Start Timeval
|
||||||
|
Childtime Timeval
|
||||||
|
Flag int64
|
||||||
|
Kiflag int64
|
||||||
|
Traceflag int32
|
||||||
|
Stat uint8
|
||||||
|
Nice int8
|
||||||
|
Lock uint8
|
||||||
|
Rqindex uint8
|
||||||
|
Oncpu_old uint8
|
||||||
|
Lastcpu_old uint8
|
||||||
|
Tdname [17]uint8
|
||||||
|
Wmesg [9]uint8
|
||||||
|
Login [18]uint8
|
||||||
|
Lockname [9]uint8
|
||||||
|
Comm [20]int8 // changed from uint8 by hand
|
||||||
|
Emul [17]uint8
|
||||||
|
Loginclass [18]uint8
|
||||||
|
Moretdname [4]uint8
|
||||||
|
Sparestrings [46]uint8
|
||||||
|
Spareints [2]int32
|
||||||
|
Tdev uint64
|
||||||
|
Oncpu int32
|
||||||
|
Lastcpu int32
|
||||||
|
Tracer int32
|
||||||
|
Flag2 int32
|
||||||
|
Fibnum int32
|
||||||
|
Cr_flags uint32
|
||||||
|
Jid int32
|
||||||
|
Numthreads int32
|
||||||
|
Tid int32
|
||||||
|
Pri Priority
|
||||||
|
Rusage Rusage
|
||||||
|
Rusage_ch Rusage
|
||||||
|
Pcb int64 /* pcb */
|
||||||
|
Kstack int64
|
||||||
|
Udata int64
|
||||||
|
Tdaddr int64 /* thread */
|
||||||
|
Pd int64 /* pwddesc, not accurate */
|
||||||
|
Spareptrs [5]int64
|
||||||
|
Sparelongs [12]int64
|
||||||
|
Sflag int64
|
||||||
|
Tdflags int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Priority struct {
|
||||||
|
Class uint8
|
||||||
|
Level uint8
|
||||||
|
Native uint8
|
||||||
|
User uint8
|
||||||
|
}
|
||||||
37
component/memory/memory_linux.go
Normal file
37
component/memory/memory_linux.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var pageSize = uint64(os.Getpagesize())
|
||||||
|
|
||||||
|
func GetMemoryInfo(pid int32) (*MemoryInfoStat, error) {
|
||||||
|
proc := os.Getenv("HOST_PROC")
|
||||||
|
if proc == "" {
|
||||||
|
proc = "/proc"
|
||||||
|
}
|
||||||
|
memPath := filepath.Join(proc, strconv.Itoa(int(pid)), "statm")
|
||||||
|
contents, err := os.ReadFile(memPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
fields := strings.Split(string(contents), " ")
|
||||||
|
|
||||||
|
vms, err := strconv.ParseUint(fields[0], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
rss, err := strconv.ParseUint(fields[1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
memInfo := &MemoryInfoStat{
|
||||||
|
RSS: rss * pageSize,
|
||||||
|
VMS: vms * pageSize,
|
||||||
|
}
|
||||||
|
return memInfo, nil
|
||||||
|
}
|
||||||
95
component/memory/memory_openbsd.go
Normal file
95
component/memory/memory_openbsd.go
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CTLKern = 1
|
||||||
|
KernProc = 14
|
||||||
|
KernProcPID = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func callKernProcSyscall(op int32, arg int32) ([]byte, uint64, error) {
|
||||||
|
mib := []int32{CTLKern, KernProc, op, arg, sizeOfKinfoProc, 0}
|
||||||
|
mibptr := unsafe.Pointer(&mib[0])
|
||||||
|
miblen := uint64(len(mib))
|
||||||
|
length := uint64(0)
|
||||||
|
_, _, err := unix.Syscall6(
|
||||||
|
unix.SYS___SYSCTL,
|
||||||
|
uintptr(mibptr),
|
||||||
|
uintptr(miblen),
|
||||||
|
0,
|
||||||
|
uintptr(unsafe.Pointer(&length)),
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
if err != 0 {
|
||||||
|
return nil, length, err
|
||||||
|
}
|
||||||
|
|
||||||
|
count := int32(length / uint64(sizeOfKinfoProc))
|
||||||
|
mib = []int32{CTLKern, KernProc, op, arg, sizeOfKinfoProc, count}
|
||||||
|
mibptr = unsafe.Pointer(&mib[0])
|
||||||
|
miblen = uint64(len(mib))
|
||||||
|
// get proc info itself
|
||||||
|
buf := make([]byte, length)
|
||||||
|
_, _, err = unix.Syscall6(
|
||||||
|
unix.SYS___SYSCTL,
|
||||||
|
uintptr(mibptr),
|
||||||
|
uintptr(miblen),
|
||||||
|
uintptr(unsafe.Pointer(&buf[0])),
|
||||||
|
uintptr(unsafe.Pointer(&length)),
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
if err != 0 {
|
||||||
|
return buf, length, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf, length, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseKinfoProc(buf []byte) (KinfoProc, error) {
|
||||||
|
var k KinfoProc
|
||||||
|
br := bytes.NewReader(buf)
|
||||||
|
err := binary.Read(br, binary.LittleEndian, &k)
|
||||||
|
return k, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func getKProc(pid int32) (*KinfoProc, error) {
|
||||||
|
buf, length, err := callKernProcSyscall(KernProcPID, pid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if length != sizeOfKinfoProc {
|
||||||
|
return nil, errors.New("unexpected size of KinfoProc")
|
||||||
|
}
|
||||||
|
|
||||||
|
k, err := parseKinfoProc(buf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &k, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMemoryInfo(pid int32) (*MemoryInfoStat, error) {
|
||||||
|
k, err := getKProc(pid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
uvmexp, err := unix.SysctlUvmexp("vm.uvmexp")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pageSize := uint64(uvmexp.Pagesize)
|
||||||
|
|
||||||
|
return &MemoryInfoStat{
|
||||||
|
RSS: uint64(k.Vm_rssize) * pageSize,
|
||||||
|
VMS: uint64(k.Vm_tsize) + uint64(k.Vm_dsize) +
|
||||||
|
uint64(k.Vm_ssize),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
99
component/memory/memory_openbsd_386.go
Normal file
99
component/memory/memory_openbsd_386.go
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x264
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Forw uint64
|
||||||
|
Back uint64
|
||||||
|
Paddr uint64
|
||||||
|
Addr uint64
|
||||||
|
Fd uint64
|
||||||
|
Stats uint64
|
||||||
|
Limit uint64
|
||||||
|
Vmspace uint64
|
||||||
|
Sigacts uint64
|
||||||
|
Sess uint64
|
||||||
|
Tsess uint64
|
||||||
|
Ru uint64
|
||||||
|
Eflag int32
|
||||||
|
Exitsig int32
|
||||||
|
Flag int32
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Sid int32
|
||||||
|
X_pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Gid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Groups [16]uint32
|
||||||
|
Ngroups int16
|
||||||
|
Jobc int16
|
||||||
|
Tdev uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Rtime_sec uint32
|
||||||
|
Rtime_usec uint32
|
||||||
|
Cpticks int32
|
||||||
|
Pctcpu uint32
|
||||||
|
Swtime uint32
|
||||||
|
Slptime uint32
|
||||||
|
Schedflags int32
|
||||||
|
Uticks uint64
|
||||||
|
Sticks uint64
|
||||||
|
Iticks uint64
|
||||||
|
Tracep uint64
|
||||||
|
Traceflag int32
|
||||||
|
Holdcnt int32
|
||||||
|
Siglist int32
|
||||||
|
Sigmask uint32
|
||||||
|
Sigignore uint32
|
||||||
|
Sigcatch uint32
|
||||||
|
Stat int8
|
||||||
|
Priority uint8
|
||||||
|
Usrpri uint8
|
||||||
|
Nice uint8
|
||||||
|
Xstat uint16
|
||||||
|
Acflag uint16
|
||||||
|
Comm [24]int8
|
||||||
|
Wmesg [8]int8
|
||||||
|
Wchan uint64
|
||||||
|
Login [32]int8
|
||||||
|
Vm_rssize int32
|
||||||
|
Vm_tsize int32
|
||||||
|
Vm_dsize int32
|
||||||
|
Vm_ssize int32
|
||||||
|
Uvalid int64
|
||||||
|
Ustart_sec uint64
|
||||||
|
Ustart_usec uint32
|
||||||
|
Uutime_sec uint32
|
||||||
|
Uutime_usec uint32
|
||||||
|
Ustime_sec uint32
|
||||||
|
Ustime_usec uint32
|
||||||
|
Uru_maxrss uint64
|
||||||
|
Uru_ixrss uint64
|
||||||
|
Uru_idrss uint64
|
||||||
|
Uru_isrss uint64
|
||||||
|
Uru_minflt uint64
|
||||||
|
Uru_majflt uint64
|
||||||
|
Uru_nswap uint64
|
||||||
|
Uru_inblock uint64
|
||||||
|
Uru_oublock uint64
|
||||||
|
Uru_msgsnd uint64
|
||||||
|
Uru_msgrcv uint64
|
||||||
|
Uru_nsignals uint64
|
||||||
|
Uru_nvcsw uint64
|
||||||
|
Uru_nivcsw uint64
|
||||||
|
Uctime_sec uint32
|
||||||
|
Uctime_usec uint32
|
||||||
|
Psflags int32
|
||||||
|
Spare int32
|
||||||
|
Svuid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Emul [8]int8
|
||||||
|
Rlim_rss_cur uint64
|
||||||
|
Cpuid uint64
|
||||||
|
Vm_map_size uint64
|
||||||
|
Tid int32
|
||||||
|
Rtableid uint32
|
||||||
|
}
|
||||||
100
component/memory/memory_openbsd_amd64.go
Normal file
100
component/memory/memory_openbsd_amd64.go
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x268
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Forw uint64
|
||||||
|
Back uint64
|
||||||
|
Paddr uint64
|
||||||
|
Addr uint64
|
||||||
|
Fd uint64
|
||||||
|
Stats uint64
|
||||||
|
Limit uint64
|
||||||
|
Vmspace uint64
|
||||||
|
Sigacts uint64
|
||||||
|
Sess uint64
|
||||||
|
Tsess uint64
|
||||||
|
Ru uint64
|
||||||
|
Eflag int32
|
||||||
|
Exitsig int32
|
||||||
|
Flag int32
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Sid int32
|
||||||
|
X_pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Gid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Groups [16]uint32
|
||||||
|
Ngroups int16
|
||||||
|
Jobc int16
|
||||||
|
Tdev uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Rtime_sec uint32
|
||||||
|
Rtime_usec uint32
|
||||||
|
Cpticks int32
|
||||||
|
Pctcpu uint32
|
||||||
|
Swtime uint32
|
||||||
|
Slptime uint32
|
||||||
|
Schedflags int32
|
||||||
|
Uticks uint64
|
||||||
|
Sticks uint64
|
||||||
|
Iticks uint64
|
||||||
|
Tracep uint64
|
||||||
|
Traceflag int32
|
||||||
|
Holdcnt int32
|
||||||
|
Siglist int32
|
||||||
|
Sigmask uint32
|
||||||
|
Sigignore uint32
|
||||||
|
Sigcatch uint32
|
||||||
|
Stat int8
|
||||||
|
Priority uint8
|
||||||
|
Usrpri uint8
|
||||||
|
Nice uint8
|
||||||
|
Xstat uint16
|
||||||
|
Acflag uint16
|
||||||
|
Comm [24]int8
|
||||||
|
Wmesg [8]int8
|
||||||
|
Wchan uint64
|
||||||
|
Login [32]int8
|
||||||
|
Vm_rssize int32
|
||||||
|
Vm_tsize int32
|
||||||
|
Vm_dsize int32
|
||||||
|
Vm_ssize int32
|
||||||
|
Uvalid int64
|
||||||
|
Ustart_sec uint64
|
||||||
|
Ustart_usec uint32
|
||||||
|
Uutime_sec uint32
|
||||||
|
Uutime_usec uint32
|
||||||
|
Ustime_sec uint32
|
||||||
|
Ustime_usec uint32
|
||||||
|
Pad_cgo_0 [4]byte
|
||||||
|
Uru_maxrss uint64
|
||||||
|
Uru_ixrss uint64
|
||||||
|
Uru_idrss uint64
|
||||||
|
Uru_isrss uint64
|
||||||
|
Uru_minflt uint64
|
||||||
|
Uru_majflt uint64
|
||||||
|
Uru_nswap uint64
|
||||||
|
Uru_inblock uint64
|
||||||
|
Uru_oublock uint64
|
||||||
|
Uru_msgsnd uint64
|
||||||
|
Uru_msgrcv uint64
|
||||||
|
Uru_nsignals uint64
|
||||||
|
Uru_nvcsw uint64
|
||||||
|
Uru_nivcsw uint64
|
||||||
|
Uctime_sec uint32
|
||||||
|
Uctime_usec uint32
|
||||||
|
Psflags int32
|
||||||
|
Spare int32
|
||||||
|
Svuid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Emul [8]int8
|
||||||
|
Rlim_rss_cur uint64
|
||||||
|
Cpuid uint64
|
||||||
|
Vm_map_size uint64
|
||||||
|
Tid int32
|
||||||
|
Rtableid uint32
|
||||||
|
}
|
||||||
99
component/memory/memory_openbsd_arm.go
Normal file
99
component/memory/memory_openbsd_arm.go
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x264
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Forw uint64
|
||||||
|
Back uint64
|
||||||
|
Paddr uint64
|
||||||
|
Addr uint64
|
||||||
|
Fd uint64
|
||||||
|
Stats uint64
|
||||||
|
Limit uint64
|
||||||
|
Vmspace uint64
|
||||||
|
Sigacts uint64
|
||||||
|
Sess uint64
|
||||||
|
Tsess uint64
|
||||||
|
Ru uint64
|
||||||
|
Eflag int32
|
||||||
|
Exitsig int32
|
||||||
|
Flag int32
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Sid int32
|
||||||
|
X_pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Gid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Groups [16]uint32
|
||||||
|
Ngroups int16
|
||||||
|
Jobc int16
|
||||||
|
Tdev uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Rtime_sec uint32
|
||||||
|
Rtime_usec uint32
|
||||||
|
Cpticks int32
|
||||||
|
Pctcpu uint32
|
||||||
|
Swtime uint32
|
||||||
|
Slptime uint32
|
||||||
|
Schedflags int32
|
||||||
|
Uticks uint64
|
||||||
|
Sticks uint64
|
||||||
|
Iticks uint64
|
||||||
|
Tracep uint64
|
||||||
|
Traceflag int32
|
||||||
|
Holdcnt int32
|
||||||
|
Siglist int32
|
||||||
|
Sigmask uint32
|
||||||
|
Sigignore uint32
|
||||||
|
Sigcatch uint32
|
||||||
|
Stat int8
|
||||||
|
Priority uint8
|
||||||
|
Usrpri uint8
|
||||||
|
Nice uint8
|
||||||
|
Xstat uint16
|
||||||
|
Acflag uint16
|
||||||
|
Comm [24]int8
|
||||||
|
Wmesg [8]int8
|
||||||
|
Wchan uint64
|
||||||
|
Login [32]int8
|
||||||
|
Vm_rssize int32
|
||||||
|
Vm_tsize int32
|
||||||
|
Vm_dsize int32
|
||||||
|
Vm_ssize int32
|
||||||
|
Uvalid int64
|
||||||
|
Ustart_sec uint64
|
||||||
|
Ustart_usec uint32
|
||||||
|
Uutime_sec uint32
|
||||||
|
Uutime_usec uint32
|
||||||
|
Ustime_sec uint32
|
||||||
|
Ustime_usec uint32
|
||||||
|
Uru_maxrss uint64
|
||||||
|
Uru_ixrss uint64
|
||||||
|
Uru_idrss uint64
|
||||||
|
Uru_isrss uint64
|
||||||
|
Uru_minflt uint64
|
||||||
|
Uru_majflt uint64
|
||||||
|
Uru_nswap uint64
|
||||||
|
Uru_inblock uint64
|
||||||
|
Uru_oublock uint64
|
||||||
|
Uru_msgsnd uint64
|
||||||
|
Uru_msgrcv uint64
|
||||||
|
Uru_nsignals uint64
|
||||||
|
Uru_nvcsw uint64
|
||||||
|
Uru_nivcsw uint64
|
||||||
|
Uctime_sec uint32
|
||||||
|
Uctime_usec uint32
|
||||||
|
Psflags int32
|
||||||
|
Spare int32
|
||||||
|
Svuid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Emul [8]int8
|
||||||
|
Rlim_rss_cur uint64
|
||||||
|
Cpuid uint64
|
||||||
|
Vm_map_size uint64
|
||||||
|
Tid int32
|
||||||
|
Rtableid uint32
|
||||||
|
}
|
||||||
100
component/memory/memory_openbsd_arm64.go
Normal file
100
component/memory/memory_openbsd_arm64.go
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x270
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Forw uint64
|
||||||
|
Back uint64
|
||||||
|
Paddr uint64
|
||||||
|
Addr uint64
|
||||||
|
Fd uint64
|
||||||
|
Stats uint64
|
||||||
|
Limit uint64
|
||||||
|
Vmspace uint64
|
||||||
|
Sigacts uint64
|
||||||
|
Sess uint64
|
||||||
|
Tsess uint64
|
||||||
|
Ru uint64
|
||||||
|
Eflag int32
|
||||||
|
Exitsig int32
|
||||||
|
Flag int32
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Sid int32
|
||||||
|
X_pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Gid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Groups [16]uint32
|
||||||
|
Ngroups int16
|
||||||
|
Jobc int16
|
||||||
|
Tdev uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Rtime_sec uint32
|
||||||
|
Rtime_usec uint32
|
||||||
|
Cpticks int32
|
||||||
|
Pctcpu uint32
|
||||||
|
Swtime uint32
|
||||||
|
Slptime uint32
|
||||||
|
Schedflags int32
|
||||||
|
Uticks uint64
|
||||||
|
Sticks uint64
|
||||||
|
Iticks uint64
|
||||||
|
Tracep uint64
|
||||||
|
Traceflag int32
|
||||||
|
Holdcnt int32
|
||||||
|
Siglist int32
|
||||||
|
Sigmask uint32
|
||||||
|
Sigignore uint32
|
||||||
|
Sigcatch uint32
|
||||||
|
Stat int8
|
||||||
|
Priority uint8
|
||||||
|
Usrpri uint8
|
||||||
|
Nice uint8
|
||||||
|
Xstat uint16
|
||||||
|
Acflag uint16
|
||||||
|
Comm [24]int8
|
||||||
|
Wmesg [8]uint8
|
||||||
|
Wchan uint64
|
||||||
|
Login [32]uint8
|
||||||
|
Vm_rssize int32
|
||||||
|
Vm_tsize int32
|
||||||
|
Vm_dsize int32
|
||||||
|
Vm_ssize int32
|
||||||
|
Uvalid int64
|
||||||
|
Ustart_sec uint64
|
||||||
|
Ustart_usec uint32
|
||||||
|
Uutime_sec uint32
|
||||||
|
Uutime_usec uint32
|
||||||
|
Ustime_sec uint32
|
||||||
|
Ustime_usec uint32
|
||||||
|
Uru_maxrss uint64
|
||||||
|
Uru_ixrss uint64
|
||||||
|
Uru_idrss uint64
|
||||||
|
Uru_isrss uint64
|
||||||
|
Uru_minflt uint64
|
||||||
|
Uru_majflt uint64
|
||||||
|
Uru_nswap uint64
|
||||||
|
Uru_inblock uint64
|
||||||
|
Uru_oublock uint64
|
||||||
|
Uru_msgsnd uint64
|
||||||
|
Uru_msgrcv uint64
|
||||||
|
Uru_nsignals uint64
|
||||||
|
Uru_nvcsw uint64
|
||||||
|
Uru_nivcsw uint64
|
||||||
|
Uctime_sec uint32
|
||||||
|
Uctime_usec uint32
|
||||||
|
Psflags uint32
|
||||||
|
Spare int32
|
||||||
|
Svuid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Emul [8]uint8
|
||||||
|
Rlim_rss_cur uint64
|
||||||
|
Cpuid uint64
|
||||||
|
Vm_map_size uint64
|
||||||
|
Tid int32
|
||||||
|
Rtableid uint32
|
||||||
|
Pledge uint64
|
||||||
|
}
|
||||||
101
component/memory/memory_openbsd_riscv64.go
Normal file
101
component/memory/memory_openbsd_riscv64.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
const sizeOfKinfoProc = 0x288
|
||||||
|
|
||||||
|
type KinfoProc struct {
|
||||||
|
Forw uint64
|
||||||
|
Back uint64
|
||||||
|
Paddr uint64
|
||||||
|
Addr uint64
|
||||||
|
Fd uint64
|
||||||
|
Stats uint64
|
||||||
|
Limit uint64
|
||||||
|
Vmspace uint64
|
||||||
|
Sigacts uint64
|
||||||
|
Sess uint64
|
||||||
|
Tsess uint64
|
||||||
|
Ru uint64
|
||||||
|
Eflag int32
|
||||||
|
Exitsig int32
|
||||||
|
Flag int32
|
||||||
|
Pid int32
|
||||||
|
Ppid int32
|
||||||
|
Sid int32
|
||||||
|
X_pgid int32
|
||||||
|
Tpgid int32
|
||||||
|
Uid uint32
|
||||||
|
Ruid uint32
|
||||||
|
Gid uint32
|
||||||
|
Rgid uint32
|
||||||
|
Groups [16]uint32
|
||||||
|
Ngroups int16
|
||||||
|
Jobc int16
|
||||||
|
Tdev uint32
|
||||||
|
Estcpu uint32
|
||||||
|
Rtime_sec uint32
|
||||||
|
Rtime_usec uint32
|
||||||
|
Cpticks int32
|
||||||
|
Pctcpu uint32
|
||||||
|
Swtime uint32
|
||||||
|
Slptime uint32
|
||||||
|
Schedflags int32
|
||||||
|
Uticks uint64
|
||||||
|
Sticks uint64
|
||||||
|
Iticks uint64
|
||||||
|
Tracep uint64
|
||||||
|
Traceflag int32
|
||||||
|
Holdcnt int32
|
||||||
|
Siglist int32
|
||||||
|
Sigmask uint32
|
||||||
|
Sigignore uint32
|
||||||
|
Sigcatch uint32
|
||||||
|
Stat int8
|
||||||
|
Priority uint8
|
||||||
|
Usrpri uint8
|
||||||
|
Nice uint8
|
||||||
|
Xstat uint16
|
||||||
|
Spare uint16
|
||||||
|
Comm [24]int8
|
||||||
|
Wmesg [8]uint8
|
||||||
|
Wchan uint64
|
||||||
|
Login [32]uint8
|
||||||
|
Vm_rssize int32
|
||||||
|
Vm_tsize int32
|
||||||
|
Vm_dsize int32
|
||||||
|
Vm_ssize int32
|
||||||
|
Uvalid int64
|
||||||
|
Ustart_sec uint64
|
||||||
|
Ustart_usec uint32
|
||||||
|
Uutime_sec uint32
|
||||||
|
Uutime_usec uint32
|
||||||
|
Ustime_sec uint32
|
||||||
|
Ustime_usec uint32
|
||||||
|
Uru_maxrss uint64
|
||||||
|
Uru_ixrss uint64
|
||||||
|
Uru_idrss uint64
|
||||||
|
Uru_isrss uint64
|
||||||
|
Uru_minflt uint64
|
||||||
|
Uru_majflt uint64
|
||||||
|
Uru_nswap uint64
|
||||||
|
Uru_inblock uint64
|
||||||
|
Uru_oublock uint64
|
||||||
|
Uru_msgsnd uint64
|
||||||
|
Uru_msgrcv uint64
|
||||||
|
Uru_nsignals uint64
|
||||||
|
Uru_nvcsw uint64
|
||||||
|
Uru_nivcsw uint64
|
||||||
|
Uctime_sec uint32
|
||||||
|
Uctime_usec uint32
|
||||||
|
Psflags uint32
|
||||||
|
Acflag uint32
|
||||||
|
Svuid uint32
|
||||||
|
Svgid uint32
|
||||||
|
Emul [8]uint8
|
||||||
|
Rlim_rss_cur uint64
|
||||||
|
Cpuid uint64
|
||||||
|
Vm_map_size uint64
|
||||||
|
Tid int32
|
||||||
|
Rtableid uint32
|
||||||
|
Pledge uint64
|
||||||
|
Name [24]uint8
|
||||||
|
}
|
||||||
66
component/memory/memory_windows.go
Normal file
66
component/memory/memory_windows.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package memory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
modpsapi = windows.NewLazySystemDLL("psapi.dll")
|
||||||
|
procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo")
|
||||||
|
)
|
||||||
|
|
||||||
|
const processQueryInformation = windows.PROCESS_QUERY_LIMITED_INFORMATION
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func getProcessMemoryInfo(h windows.Handle, mem *PROCESS_MEMORY_COUNTERS) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(h), uintptr(unsafe.Pointer(mem)), uintptr(unsafe.Sizeof(*mem)))
|
||||||
|
if r1 == 0 {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = error(e1)
|
||||||
|
} else {
|
||||||
|
err = syscall.EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMemoryInfo(pid int32) (PROCESS_MEMORY_COUNTERS, error) {
|
||||||
|
var mem PROCESS_MEMORY_COUNTERS
|
||||||
|
c, err := windows.OpenProcess(processQueryInformation, false, uint32(pid))
|
||||||
|
if err != nil {
|
||||||
|
return mem, err
|
||||||
|
}
|
||||||
|
defer windows.CloseHandle(c)
|
||||||
|
if err := getProcessMemoryInfo(c, &mem); err != nil {
|
||||||
|
return mem, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return mem, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMemoryInfo(pid int32) (*MemoryInfoStat, error) {
|
||||||
|
mem, err := getMemoryInfo(pid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ret := &MemoryInfoStat{
|
||||||
|
RSS: uint64(mem.WorkingSetSize),
|
||||||
|
VMS: uint64(mem.PagefileUsage),
|
||||||
|
}
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
8
go.mod
8
go.mod
@ -6,6 +6,7 @@ require (
|
|||||||
github.com/bahlo/generic-list-go v0.2.0
|
github.com/bahlo/generic-list-go v0.2.0
|
||||||
github.com/coreos/go-iptables v0.8.0
|
github.com/coreos/go-iptables v0.8.0
|
||||||
github.com/dlclark/regexp2 v1.11.5
|
github.com/dlclark/regexp2 v1.11.5
|
||||||
|
github.com/ebitengine/purego v0.9.0
|
||||||
github.com/enfein/mieru/v3 v3.20.0
|
github.com/enfein/mieru/v3 v3.20.0
|
||||||
github.com/go-chi/chi/v5 v5.2.3
|
github.com/go-chi/chi/v5 v5.2.3
|
||||||
github.com/go-chi/render v1.0.3
|
github.com/go-chi/render v1.0.3
|
||||||
@ -46,7 +47,6 @@ require (
|
|||||||
github.com/sagernet/cors v1.2.1
|
github.com/sagernet/cors v1.2.1
|
||||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a
|
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a
|
||||||
github.com/samber/lo v1.51.0
|
github.com/samber/lo v1.51.0
|
||||||
github.com/shirou/gopsutil/v4 v4.25.1 // lastest version compatible with golang1.20
|
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1
|
github.com/vmihailenco/msgpack/v5 v5.4.1
|
||||||
@ -70,7 +70,6 @@ require (
|
|||||||
github.com/andybalholm/brotli v1.0.6 // indirect
|
github.com/andybalholm/brotli v1.0.6 // indirect
|
||||||
github.com/buger/jsonparser v1.1.1 // indirect
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/ebitengine/purego v0.8.4 // indirect
|
|
||||||
github.com/ericlagergren/aegis v0.0.0-20250325060835-cd0defd64358 // indirect
|
github.com/ericlagergren/aegis v0.0.0-20250325060835-cd0defd64358 // indirect
|
||||||
github.com/ericlagergren/polyval v0.0.0-20220411101811-e25bc10ba391 // indirect
|
github.com/ericlagergren/polyval v0.0.0-20220411101811-e25bc10ba391 // indirect
|
||||||
github.com/ericlagergren/siv v0.0.0-20220507050439-0b757b3aa5f1 // indirect
|
github.com/ericlagergren/siv v0.0.0-20220507050439-0b757b3aa5f1 // indirect
|
||||||
@ -88,7 +87,6 @@ require (
|
|||||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||||
github.com/klauspost/reedsolomon v1.12.3 // indirect
|
github.com/klauspost/reedsolomon v1.12.3 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
github.com/mdlayher/socket v0.4.1 // indirect
|
github.com/mdlayher/socket v0.4.1 // indirect
|
||||||
github.com/metacubex/ascon v0.1.0 // indirect
|
github.com/metacubex/ascon v0.1.0 // indirect
|
||||||
@ -99,17 +97,13 @@ require (
|
|||||||
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
|
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
|
||||||
github.com/pierrec/lz4/v4 v4.1.14 // indirect
|
github.com/pierrec/lz4/v4 v4.1.14 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
|
||||||
github.com/quic-go/qpack v0.4.0 // indirect
|
github.com/quic-go/qpack v0.4.0 // indirect
|
||||||
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b // indirect
|
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b // indirect
|
||||||
github.com/sina-ghaderi/rabaead v0.0.0-20220730151906-ab6e06b96e8c // indirect
|
github.com/sina-ghaderi/rabaead v0.0.0-20220730151906-ab6e06b96e8c // indirect
|
||||||
github.com/sina-ghaderi/rabbitio v0.0.0-20220730151941-9ce26f4f872e // indirect
|
github.com/sina-ghaderi/rabbitio v0.0.0-20220730151941-9ce26f4f872e // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
|
||||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
|
||||||
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 // indirect
|
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 // indirect
|
||||||
github.com/vishvananda/netns v0.0.4 // indirect
|
github.com/vishvananda/netns v0.0.4 // indirect
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
|
||||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
|
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
|
||||||
go.uber.org/mock v0.4.0 // indirect
|
go.uber.org/mock v0.4.0 // indirect
|
||||||
golang.org/x/mod v0.20.0 // indirect
|
golang.org/x/mod v0.20.0 // indirect
|
||||||
|
|||||||
23
go.sum
23
go.sum
@ -23,8 +23,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
|
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
|
||||||
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||||
github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw=
|
github.com/ebitengine/purego v0.9.0 h1:mh0zpKBIXDceC63hpvPuGLiJ8ZAa3DfrFTudmfi8A4k=
|
||||||
github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
github.com/ebitengine/purego v0.9.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||||
github.com/enfein/mieru/v3 v3.20.0 h1:1ob7pCIVSH5FYFAfYvim8isLW1vBOS4cFOUF9exJS38=
|
github.com/enfein/mieru/v3 v3.20.0 h1:1ob7pCIVSH5FYFAfYvim8isLW1vBOS4cFOUF9exJS38=
|
||||||
github.com/enfein/mieru/v3 v3.20.0/go.mod h1:zJBUCsi5rxyvHM8fjFf+GLaEl4OEjjBXr1s5F6Qd3hM=
|
github.com/enfein/mieru/v3 v3.20.0/go.mod h1:zJBUCsi5rxyvHM8fjFf+GLaEl4OEjjBXr1s5F6Qd3hM=
|
||||||
github.com/ericlagergren/aegis v0.0.0-20250325060835-cd0defd64358 h1:kXYqH/sL8dS/FdoFjr12ePjnLPorPo2FsnrHNuXSDyo=
|
github.com/ericlagergren/aegis v0.0.0-20250325060835-cd0defd64358 h1:kXYqH/sL8dS/FdoFjr12ePjnLPorPo2FsnrHNuXSDyo=
|
||||||
@ -45,7 +45,6 @@ github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hH
|
|||||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
|
||||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
||||||
@ -64,7 +63,6 @@ github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
|
|||||||
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
|
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
|
||||||
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
|
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
|
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
|
||||||
@ -86,8 +84,6 @@ github.com/klauspost/reedsolomon v1.12.3/go.mod h1:3K5rXwABAvzGeR01r6pWZieUALXO/
|
|||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||||
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
|
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
|
||||||
@ -172,8 +168,6 @@ github.com/pierrec/lz4/v4 v4.1.14/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFu
|
|||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
|
||||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
||||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
||||||
@ -183,8 +177,6 @@ github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZN
|
|||||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
|
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
|
||||||
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
||||||
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||||
github.com/shirou/gopsutil/v4 v4.25.1 h1:QSWkTc+fu9LTAWfkZwZ6j8MSUk4A2LV7rbH0ZqmLjXs=
|
|
||||||
github.com/shirou/gopsutil/v4 v4.25.1/go.mod h1:RoUCUpndaJFtT+2zsZzzmhvbfGoDCJ7nFXKJf8GqJbI=
|
|
||||||
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b h1:rXHg9GrUEtWZhEkrykicdND3VPjlVbYiLdX9J7gimS8=
|
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b h1:rXHg9GrUEtWZhEkrykicdND3VPjlVbYiLdX9J7gimS8=
|
||||||
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b/go.mod h1:X7qrxNQViEaAN9LNZOPl9PfvQtp3V3c7LTo0dvGi0fM=
|
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b/go.mod h1:X7qrxNQViEaAN9LNZOPl9PfvQtp3V3c7LTo0dvGi0fM=
|
||||||
github.com/sina-ghaderi/rabaead v0.0.0-20220730151906-ab6e06b96e8c h1:DjKMC30y6yjG3IxDaeAj3PCoRr+IsO+bzyT+Se2m2Hk=
|
github.com/sina-ghaderi/rabaead v0.0.0-20220730151906-ab6e06b96e8c h1:DjKMC30y6yjG3IxDaeAj3PCoRr+IsO+bzyT+Se2m2Hk=
|
||||||
@ -206,10 +198,6 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
|
|||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
|
||||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
|
||||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
|
||||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
|
||||||
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 h1:tHNk7XK9GkmKUR6Gh8gVBKXc2MVSZ4G/NnWLtzw4gNA=
|
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 h1:tHNk7XK9GkmKUR6Gh8gVBKXc2MVSZ4G/NnWLtzw4gNA=
|
||||||
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923/go.mod h1:eLL9Nub3yfAho7qB0MzZizFhTU2QkLeoVsWdHtDW264=
|
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923/go.mod h1:eLL9Nub3yfAho7qB0MzZizFhTU2QkLeoVsWdHtDW264=
|
||||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
||||||
@ -224,8 +212,6 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV
|
|||||||
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||||
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM=
|
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM=
|
||||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
|
||||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
|
||||||
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7 h1:UNrDfkQqiEYzdMlNsVvBYOAJWZjdktqFE9tQh5BT2+4=
|
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7 h1:UNrDfkQqiEYzdMlNsVvBYOAJWZjdktqFE9tQh5BT2+4=
|
||||||
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7/go.mod h1:E+rxHvJG9H6PUdzq9NRG6csuLN3XUx98BfGOVWNYnXs=
|
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7/go.mod h1:E+rxHvJG9H6PUdzq9NRG6csuLN3XUx98BfGOVWNYnXs=
|
||||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec h1:FpfFs4EhNehiVfzQttTuxanPIT43FtkkCFypIod8LHo=
|
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec h1:FpfFs4EhNehiVfzQttTuxanPIT43FtkkCFypIod8LHo=
|
||||||
@ -257,17 +243,13 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
@ -281,7 +263,6 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK
|
|||||||
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
|
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
|
||||||
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
|
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/metacubex/mihomo/common/atomic"
|
"github.com/metacubex/mihomo/common/atomic"
|
||||||
"github.com/metacubex/mihomo/common/xsync"
|
"github.com/metacubex/mihomo/common/xsync"
|
||||||
|
"github.com/metacubex/mihomo/component/memory"
|
||||||
"github.com/shirou/gopsutil/v4/process"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var DefaultManager *Manager
|
var DefaultManager *Manager
|
||||||
@ -20,7 +19,7 @@ func init() {
|
|||||||
downloadBlip: atomic.NewInt64(0),
|
downloadBlip: atomic.NewInt64(0),
|
||||||
uploadTotal: atomic.NewInt64(0),
|
uploadTotal: atomic.NewInt64(0),
|
||||||
downloadTotal: atomic.NewInt64(0),
|
downloadTotal: atomic.NewInt64(0),
|
||||||
process: &process.Process{Pid: int32(os.Getpid())},
|
pid: int32(os.Getpid()),
|
||||||
}
|
}
|
||||||
|
|
||||||
go DefaultManager.handle()
|
go DefaultManager.handle()
|
||||||
@ -34,7 +33,7 @@ type Manager struct {
|
|||||||
downloadBlip atomic.Int64
|
downloadBlip atomic.Int64
|
||||||
uploadTotal atomic.Int64
|
uploadTotal atomic.Int64
|
||||||
downloadTotal atomic.Int64
|
downloadTotal atomic.Int64
|
||||||
process *process.Process
|
pid int32
|
||||||
memory uint64
|
memory uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +92,7 @@ func (m *Manager) Snapshot() *Snapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) updateMemory() {
|
func (m *Manager) updateMemory() {
|
||||||
stat, err := m.process.MemoryInfo()
|
stat, err := memory.GetMemoryInfo(m.pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user