1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-24 13:48:56 +08:00

Compare commits

...

27 Commits

Author SHA1 Message Date
shirou
62a52f910b
Merge pull request #1745 from wangyu-geek/add_anolis_family_in_host_linux
add anolis family with anolis platform in host/host_linux.go
2024-11-16 22:29:20 +09:00
wangyu
8e62971eb0 add anolis family with anolis platform 2024-11-15 19:28:24 +08:00
Lomanic
aa9796d3d7
Merge pull request #1723 from shirou/dependabot/go_modules/golang.org/x/sys-0.26.0
chore(deps): bump golang.org/x/sys from 0.25.0 to 0.26.0
2024-10-28 23:40:06 +01:00
Lomanic
6be0508aeb
Merge pull request #1739 from shirou/dependabot/github_actions/actions/checkout-4.2.2
chore(deps): bump actions/checkout from 4.2.1 to 4.2.2
2024-10-24 11:46:35 +02:00
dependabot[bot]
137fd2acac
chore(deps): bump actions/checkout from 4.2.1 to 4.2.2
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.1 to 4.2.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](eef61447b9...11bd71901b)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-24 01:26:12 +00:00
shirou
aa47e0fde0
Merge pull request #1720 from n4nn31355/feat/win_mem_commit_total
feat(mem): Add windows commit stats
2024-10-23 21:09:47 +09:00
shirou
de435c3739
Merge pull request #1737 from shirou/dependabot/go_modules/github.com/ebitengine/purego-0.8.1
chore(deps): bump github.com/ebitengine/purego from 0.8.0 to 0.8.1
2024-10-22 11:00:38 +09:00
dependabot[bot]
9ae3f38658
chore(deps): bump github.com/ebitengine/purego from 0.8.0 to 0.8.1
Bumps [github.com/ebitengine/purego](https://github.com/ebitengine/purego) from 0.8.0 to 0.8.1.
- [Release notes](https://github.com/ebitengine/purego/releases)
- [Commits](https://github.com/ebitengine/purego/compare/v0.8.0...v0.8.1)

---
updated-dependencies:
- dependency-name: github.com/ebitengine/purego
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-22 01:29:59 +00:00
shirou
a19cedeb30
Merge pull request #1727 from uubulb/fix_sensors_darwin_arm64
sensors: avoid passing nil pointer to CFArrayGetCount
2024-10-13 22:05:28 +09:00
shirou
c9da2cc0aa
Merge pull request #1731 from Lomanic/issue1645
[cpu][disk][netbsd] Generate arm-specific definitions
2024-10-12 21:37:56 +09:00
shirou
44c71b62c0
Merge pull request #1722 from uubulb/fix_windows_mem
fix(mem): possible memory leak on Windows
2024-10-11 15:45:29 +09:00
shirou
30457973b5
Merge pull request #1735 from shirou/dependabot/github_actions/actions/upload-artifact-4.4.3
chore(deps): bump actions/upload-artifact from 4.4.0 to 4.4.3
2024-10-10 10:12:24 +09:00
shirou
7422a58e32
Merge pull request #1733 from shirou/dependabot/github_actions/actions/cache-4.1.1
chore(deps): bump actions/cache from 4.0.2 to 4.1.1
2024-10-10 10:12:11 +09:00
dependabot[bot]
c30c83bf4a
chore(deps): bump actions/upload-artifact from 4.4.0 to 4.4.3
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.4.0 to 4.4.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](50769540e7...b4b15b8c7c)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-10 01:05:56 +00:00
dependabot[bot]
9fc4f64913
chore(deps): bump actions/cache from 4.0.2 to 4.1.1
Bumps [actions/cache](https://github.com/actions/cache) from 4.0.2 to 4.1.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](0c45773b62...3624ceb22c)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-09 01:04:20 +00:00
Lomanic
68512056e8
Merge pull request #1729 from shirou/dependabot/github_actions/actions/checkout-4.2.1
chore(deps): bump actions/checkout from 4.2.0 to 4.2.1
2024-10-09 00:55:07 +02:00
Lomanic
ec973203e9 [disk][netbsd] Generate cpu_netbsd_arm.go via mktypes.sh 2024-10-09 00:20:53 +02:00
Lomanic
c37a5eba8c [cpu][netbsd] Fix "undefined: cpuTimes" error at compile time on arm
Fixes #1645
2024-10-09 00:20:24 +02:00
dependabot[bot]
9732546382
chore(deps): bump actions/checkout from 4.2.0 to 4.2.1
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](d632683dd7...eef61447b9)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-08 01:50:59 +00:00
uubulb
10d9c04c2e sensors: avoid passing nil pointer to CFArrayGetCount 2024-10-08 00:53:42 +08:00
dependabot[bot]
4cb0abd1d2
chore(deps): bump golang.org/x/sys from 0.25.0 to 0.26.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.25.0 to 0.26.0.
- [Commits](https://github.com/golang/sys/compare/v0.25.0...v0.26.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-07 01:19:22 +00:00
uubulb
3773f6fe43 fix(mem): possible memory leak on Windows 2024-10-05 15:29:36 +08:00
shirou
45e3591650
Merge pull request #1714 from shirou/dependabot/github_actions/actions/checkout-4.2.0
chore(deps): bump actions/checkout from 4.1.7 to 4.2.0
2024-10-04 10:21:31 +09:00
dependabot[bot]
3c43ac0060
chore(deps): bump actions/checkout from 4.1.7 to 4.2.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](692973e3d9...d632683dd7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-04 01:12:46 +00:00
shirou
023f0cf765
Merge pull request #1721 from shirou/dependabot/github_actions/golangci/golangci-lint-action-6.1.1
chore(deps): bump golangci/golangci-lint-action from 6.1.0 to 6.1.1
2024-10-04 10:12:07 +09:00
dependabot[bot]
b048ca575d
chore(deps): bump golangci/golangci-lint-action from 6.1.0 to 6.1.1
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.1.0 to 6.1.1.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](aaa42aa062...971e284b60)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-04 01:04:29 +00:00
Vyacheslav Artemiev
3f241a0b08 feat(mem): Add windows commit stats
Closes Expose MemCommit info for Windows #1719
2024-10-04 01:57:36 +04:00
14 changed files with 96 additions and 16 deletions

View File

@ -26,13 +26,13 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: cache-paths
run: |
echo "::set-output name=cache::$(go env GOCACHE)"
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
- name: Cache go modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
with:
path: |
${{ steps.cache-paths.outputs.cache }}

View File

@ -21,9 +21,9 @@ jobs:
go-version: 1.17
cache: false
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
args: --verbose
version: latest

View File

@ -10,6 +10,6 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Release
run: make release

View File

@ -13,13 +13,13 @@ jobs:
runs-on: ubuntu-latest
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
id: sbom
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
path: ${{steps.sbom.outputs.fileName }}
name: "SBOM"

View File

@ -8,6 +8,6 @@ jobs:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0

View File

@ -27,13 +27,13 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: go-env
run: |
echo "::set-output name=cache::$(go env GOCACHE)"
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
- name: Cache go modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
with:
path: |
${{ steps.go-env.outputs.cache }}

10
cpu/cpu_netbsd_arm.go Normal file
View 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
View 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
View File

@ -3,14 +3,14 @@ module github.com/shirou/gopsutil/v4
go 1.18
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/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c
github.com/stretchr/testify v1.9.0
github.com/tklauser/go-sysconf v0.3.12
github.com/yusufpapurcu/wmi v1.2.4
golang.org/x/sys v0.25.0
golang.org/x/sys v0.26.0
)
require (

8
go.sum
View File

@ -1,7 +1,7 @@
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/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE=
github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/ebitengine/purego v0.8.1 h1:sdRKd6plj7KYW33EH5As6YKfe8m9zbN9JMrOjNVF/BE=
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/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
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.8.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.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
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=
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=

View File

@ -315,6 +315,8 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
family = "solus"
case "neokylin":
family = "neokylin"
case "anolis":
family = "anolis"
}
return platform, family, version, nil

View File

@ -11,7 +11,10 @@ import (
// 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/psapi/ns-psapi-performance_information
type ExVirtualMemory struct {
CommitLimit uint64 `json:"commitLimit"`
CommitTotal uint64 `json:"commitTotal"`
VirtualTotal uint64 `json:"virtualTotal"`
VirtualAvail uint64 `json:"virtualAvail"`
}
@ -30,7 +33,16 @@ func (e *ExWindows) VirtualMemory() (*ExVirtualMemory, error) {
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{
CommitLimit: perfInfo.commitLimit * perfInfo.pageSize,
CommitTotal: perfInfo.commitTotal * perfInfo.pageSize,
VirtualTotal: memInfo.ullTotalVirtual,
VirtualAvail: memInfo.ullAvailVirtual,
}

View File

@ -82,6 +82,8 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
if err != nil {
return nil, err
}
defer common.PdhCloseQuery.Call(uintptr(counter.Query))
usedPercent, err := counter.GetValue()
if err != nil {
return nil, err

View File

@ -96,6 +96,10 @@ func (ta *temperatureArm) getProductNames() []string {
ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors))
matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system))
if matchingsrvs == nil {
return nil
}
count := ta.cfArrayGetCount(uintptr(matchingsrvs))
var i int32
@ -130,6 +134,10 @@ func (ta *temperatureArm) getThermalValues() []float64 {
ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors))
matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system))
if matchingsrvs == nil {
return nil
}
count := ta.cfArrayGetCount(uintptr(matchingsrvs))
var values []float64