Skip to content

Commit

Permalink
begin work of supporting current resource usage
Browse files Browse the repository at this point in the history
This patch begins the process of supporting current resource usage
information in `ghw`. The first resource we support is memory on Linux
systems.

Users can use the `ghw.WithCollectUsage(true)` function to instruct
`ghw` to gather usage information for the module in question.
Alternately, users can use the `GHW_COLLECT_USAGE=1` environs variable.
The following shows the effect of the variable:

```
jaypipes@lappie:~/src/github.com/jaypipes/ghw$ go run cmd/ghwc/main.go memory
memory (16GB physical, 16GB usable)
jaypipes@lappie:~/src/github.com/jaypipes/ghw$ GHW_COLLECT_USAGE=1 go run cmd/ghwc/main.go memory
memory (16GB physical, 16GB usable, 9GB used)
```

Issue #357

Signed-off-by: Jay Pipes <[email protected]>
  • Loading branch information
jaypipes committed Dec 30, 2023
1 parent 835f6a2 commit 2a67b25
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 159 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/fmtcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ jobs:
disable-sudo: true
allowed-endpoints: >
github.com:443
api.github.com:443
raw.githubusercontent.com:443
objects.githubusercontent.com:443
- name: checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: setup go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.19
go-version: 1.21
- name: check fmt
run: 'bash -c "diff -u <(echo -n) <(gofmt -d .)"'
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: setup go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.19
go-version: 1.21
- name: lint
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.19', '1.20']
go: [ '1.20', '1.21']
steps:
- name: harden runner
uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1
Expand All @@ -26,6 +26,9 @@ jobs:
disable-sudo: true
allowed-endpoints: >
github.com:443
api.github.com:443
raw.githubusercontent.com:443
objects.githubusercontent.com:443
- name: checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: setup go
Expand All @@ -51,6 +54,9 @@ jobs:
disable-sudo: true
allowed-endpoints: >
github.com:443
api.github.com:443
raw.githubusercontent.com:443
objects.githubusercontent.com:443
- name: checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: setup go
Expand All @@ -67,7 +73,7 @@ jobs:
runs-on: windows-2022
strategy:
matrix:
go: [ '1.19' ]
go: [ '1.20', '1.21' ]
steps:
- name: harden runner
uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1
Expand All @@ -76,6 +82,9 @@ jobs:
disable-sudo: true
allowed-endpoints: >
github.com:443
api.github.com:443
raw.githubusercontent.com:443
objects.githubusercontent.com:443
- name: checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: setup go
Expand All @@ -98,7 +107,7 @@ jobs:
runs-on: windows-2019
strategy:
matrix:
go: [ '1.18' ]
go: [ '1.18', '1.19' ]
steps:
- name: harden runner
uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1
Expand All @@ -107,6 +116,9 @@ jobs:
disable-sudo: true
allowed-endpoints: >
github.com:443
api.github.com:443
raw.githubusercontent.com:443
objects.githubusercontent.com:443
- name: checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: setup go
Expand Down Expand Up @@ -145,6 +157,9 @@ jobs:
disable-sudo: true
allowed-endpoints: >
github.com:443
api.github.com:443
raw.githubusercontent.com:443
objects.githubusercontent.com:443
- name: checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: setup go
Expand Down
Loading

0 comments on commit 2a67b25

Please sign in to comment.