Skip to content

Wraps RAM and CPU resource information gathering. Cgroups and cgroups2 are supported. If none of them is active, fallback to procfs provides resource information.

License

Notifications You must be signed in to change notification settings

arivum/resource-ticker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 and package documentation

How to use

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)
		}
	}
}

About

Wraps RAM and CPU resource information gathering. Cgroups and cgroups2 are supported. If none of them is active, fallback to procfs provides resource information.

Topics

Resources

License

Stars

Watchers

Forks

Languages