Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support querying current resource usage #357

Open
jaypipes opened this issue Dec 30, 2023 · 1 comment
Open

Support querying current resource usage #357

jaypipes opened this issue Dec 30, 2023 · 1 comment
Assignees

Comments

@jaypipes
Copy link
Owner

ghw was originally designed as a system capabilities library, allowing developers to query for system functionality, NUMA topology and hardware capabilities. We deliberately did not query for resource usage, instead calling out in the documentation that there were other systems that were designed for monitoring.

However, as the years have gone by, I've noticed that many systems that import ghw (and a few that call the ghwc example CLI tool) also import other libraries or shell out to many other tools (depending on the host system) to additionally collect resource usage information. And, I think it would be used for these consumer tools to be able to use ghw for both discovering capabilities as well as collecting current resource usage amounts. That way, these consumer tools don't need to shell out to other tools and can use a single library for collecting resource capability and usage information.

@jaypipes jaypipes self-assigned this Dec 30, 2023
jaypipes added a commit that referenced this issue Dec 30, 2023
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]>
jaypipes added a commit that referenced this issue Dec 30, 2023
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]>
jaypipes added a commit that referenced this issue Dec 30, 2023
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]>
jaypipes added a commit that referenced this issue Dec 30, 2023
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]>
jaypipes added a commit that referenced this issue Dec 30, 2023
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]>
@ffromani
Copy link
Collaborator

I'm in favor of this enhancement. I wonder if we can implement the new functionality as add-on libraries on top of existing ghw packages, leaving the latter mostly unchanged. Perhaps is just more practical to bake in the new functionalities in the existing codebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants