mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-28 13:48:49 +08:00
Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
62a52f910b | ||
![]() |
8e62971eb0 | ||
![]() |
aa9796d3d7 | ||
![]() |
6be0508aeb | ||
![]() |
137fd2acac | ||
![]() |
aa47e0fde0 | ||
![]() |
de435c3739 | ||
![]() |
9ae3f38658 | ||
![]() |
a19cedeb30 | ||
![]() |
c9da2cc0aa | ||
![]() |
44c71b62c0 | ||
![]() |
30457973b5 | ||
![]() |
7422a58e32 | ||
![]() |
c30c83bf4a | ||
![]() |
9fc4f64913 | ||
![]() |
68512056e8 | ||
![]() |
ec973203e9 | ||
![]() |
c37a5eba8c | ||
![]() |
9732546382 | ||
![]() |
10d9c04c2e | ||
![]() |
4cb0abd1d2 | ||
![]() |
3773f6fe43 | ||
![]() |
45e3591650 | ||
![]() |
3c43ac0060 | ||
![]() |
023f0cf765 | ||
![]() |
b048ca575d | ||
![]() |
3f241a0b08 |
4
.github/workflows/build_test.yml
vendored
4
.github/workflows/build_test.yml
vendored
@ -26,13 +26,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
- id: cache-paths
|
- id: cache-paths
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=cache::$(go env GOCACHE)"
|
echo "::set-output name=cache::$(go env GOCACHE)"
|
||||||
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
|
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
|
||||||
- name: Cache go modules
|
- name: Cache go modules
|
||||||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
${{ steps.cache-paths.outputs.cache }}
|
${{ steps.cache-paths.outputs.cache }}
|
||||||
|
4
.github/workflows/lint.yml
vendored
4
.github/workflows/lint.yml
vendored
@ -21,9 +21,9 @@ jobs:
|
|||||||
go-version: 1.17
|
go-version: 1.17
|
||||||
cache: false
|
cache: false
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
- name: Setup golangci-lint
|
- name: Setup golangci-lint
|
||||||
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
|
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
|
||||||
with:
|
with:
|
||||||
args: --verbose
|
args: --verbose
|
||||||
version: latest
|
version: latest
|
||||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -10,6 +10,6 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
- name: Release
|
- name: Release
|
||||||
run: make release
|
run: make release
|
||||||
|
4
.github/workflows/sbom_generator.yml
vendored
4
.github/workflows/sbom_generator.yml
vendored
@ -13,13 +13,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- uses: advanced-security/sbom-generator-action@375dee8e6144d9fd0ec1f5667b4f6fb4faacefed # v0.0.1
|
- uses: advanced-security/sbom-generator-action@375dee8e6144d9fd0ec1f5667b4f6fb4faacefed # v0.0.1
|
||||||
id: sbom
|
id: sbom
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||||
with:
|
with:
|
||||||
path: ${{steps.sbom.outputs.fileName }}
|
path: ${{steps.sbom.outputs.fileName }}
|
||||||
name: "SBOM"
|
name: "SBOM"
|
||||||
|
2
.github/workflows/shellcheck.yml
vendored
2
.github/workflows/shellcheck.yml
vendored
@ -8,6 +8,6 @@ jobs:
|
|||||||
name: Shellcheck
|
name: Shellcheck
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
- name: Run ShellCheck
|
- name: Run ShellCheck
|
||||||
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0
|
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0
|
||||||
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -27,13 +27,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
- id: go-env
|
- id: go-env
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=cache::$(go env GOCACHE)"
|
echo "::set-output name=cache::$(go env GOCACHE)"
|
||||||
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
|
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
|
||||||
- name: Cache go modules
|
- name: Cache go modules
|
||||||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
${{ steps.go-env.outputs.cache }}
|
${{ steps.go-env.outputs.cache }}
|
||||||
|
10
cpu/cpu_netbsd_arm.go
Normal file
10
cpu/cpu_netbsd_arm.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
type cpuTimes struct {
|
||||||
|
User uint32
|
||||||
|
Nice uint32
|
||||||
|
Sys uint32
|
||||||
|
Intr uint32
|
||||||
|
Idle uint32
|
||||||
|
}
|
46
disk/disk_netbsd_arm.go
Normal file
46
disk/disk_netbsd_arm.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
//go:build netbsd && arm
|
||||||
|
// +build netbsd,arm
|
||||||
|
|
||||||
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
|
// cgo -godefs disk/types_netbsd.go
|
||||||
|
|
||||||
|
package disk
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeOfStatvfs = 0xcc8
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Statvfs struct {
|
||||||
|
Flag uint32
|
||||||
|
Bsize uint32
|
||||||
|
Frsize uint32
|
||||||
|
Iosize uint32
|
||||||
|
Blocks uint64
|
||||||
|
Bfree uint64
|
||||||
|
Bavail uint64
|
||||||
|
Bresvd uint64
|
||||||
|
Files uint64
|
||||||
|
Ffree uint64
|
||||||
|
Favail uint64
|
||||||
|
Fresvd uint64
|
||||||
|
Syncreads uint64
|
||||||
|
Syncwrites uint64
|
||||||
|
Asyncreads uint64
|
||||||
|
Asyncwrites uint64
|
||||||
|
Fsidx _Ctype_struct___0
|
||||||
|
Fsid uint32
|
||||||
|
Namemax uint32
|
||||||
|
Owner uint32
|
||||||
|
Pad_cgo_0 [4]byte
|
||||||
|
Spare [4]uint64
|
||||||
|
Fstypename [32]uint8
|
||||||
|
Mntonname [1024]uint8
|
||||||
|
Mntfromname [1024]uint8
|
||||||
|
Mntfromlabel [1024]uint8
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type _Ctype_struct___0 struct {
|
||||||
|
FsidVal [2]int32
|
||||||
|
}
|
4
go.mod
4
go.mod
@ -3,14 +3,14 @@ module github.com/shirou/gopsutil/v4
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ebitengine/purego v0.8.0
|
github.com/ebitengine/purego v0.8.1
|
||||||
github.com/google/go-cmp v0.6.0
|
github.com/google/go-cmp v0.6.0
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
github.com/tklauser/go-sysconf v0.3.12
|
github.com/tklauser/go-sysconf v0.3.12
|
||||||
github.com/yusufpapurcu/wmi v1.2.4
|
github.com/yusufpapurcu/wmi v1.2.4
|
||||||
golang.org/x/sys v0.25.0
|
golang.org/x/sys v0.26.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
8
go.sum
8
go.sum
@ -1,7 +1,7 @@
|
|||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
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/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE=
|
github.com/ebitengine/purego v0.8.1 h1:sdRKd6plj7KYW33EH5As6YKfe8m9zbN9JMrOjNVF/BE=
|
||||||
github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
github.com/ebitengine/purego v0.8.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
@ -25,8 +25,8 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.8.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.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
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=
|
||||||
|
@ -315,6 +315,8 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
|
|||||||
family = "solus"
|
family = "solus"
|
||||||
case "neokylin":
|
case "neokylin":
|
||||||
family = "neokylin"
|
family = "neokylin"
|
||||||
|
case "anolis":
|
||||||
|
family = "anolis"
|
||||||
}
|
}
|
||||||
|
|
||||||
return platform, family, version, nil
|
return platform, family, version, nil
|
||||||
|
@ -11,7 +11,10 @@ import (
|
|||||||
|
|
||||||
// ExVirtualMemory represents Windows specific information
|
// ExVirtualMemory represents Windows specific information
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-memorystatusex
|
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-memorystatusex
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/api/psapi/ns-psapi-performance_information
|
||||||
type ExVirtualMemory struct {
|
type ExVirtualMemory struct {
|
||||||
|
CommitLimit uint64 `json:"commitLimit"`
|
||||||
|
CommitTotal uint64 `json:"commitTotal"`
|
||||||
VirtualTotal uint64 `json:"virtualTotal"`
|
VirtualTotal uint64 `json:"virtualTotal"`
|
||||||
VirtualAvail uint64 `json:"virtualAvail"`
|
VirtualAvail uint64 `json:"virtualAvail"`
|
||||||
}
|
}
|
||||||
@ -30,7 +33,16 @@ func (e *ExWindows) VirtualMemory() (*ExVirtualMemory, error) {
|
|||||||
return nil, windows.GetLastError()
|
return nil, windows.GetLastError()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var perfInfo performanceInformation
|
||||||
|
perfInfo.cb = uint32(unsafe.Sizeof(perfInfo))
|
||||||
|
perf, _, _ := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&perfInfo)), uintptr(perfInfo.cb))
|
||||||
|
if perf == 0 {
|
||||||
|
return nil, windows.GetLastError()
|
||||||
|
}
|
||||||
|
|
||||||
ret := &ExVirtualMemory{
|
ret := &ExVirtualMemory{
|
||||||
|
CommitLimit: perfInfo.commitLimit * perfInfo.pageSize,
|
||||||
|
CommitTotal: perfInfo.commitTotal * perfInfo.pageSize,
|
||||||
VirtualTotal: memInfo.ullTotalVirtual,
|
VirtualTotal: memInfo.ullTotalVirtual,
|
||||||
VirtualAvail: memInfo.ullAvailVirtual,
|
VirtualAvail: memInfo.ullAvailVirtual,
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,8 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer common.PdhCloseQuery.Call(uintptr(counter.Query))
|
||||||
|
|
||||||
usedPercent, err := counter.GetValue()
|
usedPercent, err := counter.GetValue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -96,6 +96,10 @@ func (ta *temperatureArm) getProductNames() []string {
|
|||||||
ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors))
|
ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors))
|
||||||
matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system))
|
matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system))
|
||||||
|
|
||||||
|
if matchingsrvs == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
count := ta.cfArrayGetCount(uintptr(matchingsrvs))
|
count := ta.cfArrayGetCount(uintptr(matchingsrvs))
|
||||||
|
|
||||||
var i int32
|
var i int32
|
||||||
@ -130,6 +134,10 @@ func (ta *temperatureArm) getThermalValues() []float64 {
|
|||||||
ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors))
|
ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors))
|
||||||
matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system))
|
matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system))
|
||||||
|
|
||||||
|
if matchingsrvs == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
count := ta.cfArrayGetCount(uintptr(matchingsrvs))
|
count := ta.cfArrayGetCount(uintptr(matchingsrvs))
|
||||||
|
|
||||||
var values []float64
|
var values []float64
|
||||||
|
Loading…
x
Reference in New Issue
Block a user