https://github.com/arivum/resource-ticker
Wraps RAM and CPU resource information gathering. Cgroups and cgroups2 are supported. If none of them is active, fallback to procfs provides resource information.
https://github.com/arivum/resource-ticker
cgroups cgroups-v2 golang library monitoring procfs
Last synced: 19 days ago
JSON representation
Wraps RAM and CPU resource information gathering. Cgroups and cgroups2 are supported. If none of them is active, fallback to procfs provides resource information.
- Host: GitHub
- URL: https://github.com/arivum/resource-ticker
- Owner: arivum
- License: mit
- Created: 2021-10-11T18:52:38.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-13T02:04:48.000Z (almost 3 years ago)
- Last Synced: 2024-12-22T17:02:46.794Z (about 1 year ago)
- Topics: cgroups, cgroups-v2, golang, library, monitoring, procfs
- Language: Go
- Homepage: https://gopkg.in/arivum/resource-ticker.v0
- Size: 35.2 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ResourceTicker
This module wraps RAM and CPU resource information gathering.
Cgroups and cgroups2 are supported. If none of them is active, fallback to procfs provides resource information.
See [general documenation](https://pkg.go.dev/github.com/arivum/resource-ticker) and [package documentation](https://pkg.go.dev/github.com/arivum/resource-ticker/pkg/resources)
## How to use
```go
package main
import (
"log"
"github.com/arivum/resource-ticker/pkg/resources"
)
func main() {
if ticker, err := resources.NewResourceTicker(resources.WithCPUFloatingAvg(1)); err != nil {
log.Fatal(err)
}
resourceChan, errChan := ticker.Run()
for {
select {
case r := <-resourceChan:
log.Printf("$+v\n", r.RAM)
log.Printf("$+v\n", r.CPU)
case err := <-errChan:
log.Println(err)
}
}
}
```