A status-right line for tmux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

27 lines
465 B

//+build !windows
package main
import (
"fmt"
"github.com/shirou/gopsutil/v3/load"
"runtime"
)
func printLoad(format Format, precision int) {
l, err := load.Avg()
if err != nil {
panic(err) // fixme
}
cpus, err := cpu.Counts(true)
if err != nil {
// todo: log error
cpus = runtime.NumCPU()
}
if l.Load1 > float64(cpus) {
fmt.Print(format.Warning)
}
fmt.Printf("[%.[1]*[2]f %.[1]*[3]f %.[1]*[4]f]",
precision, l.Load1, l.Load5, l.Load15)
}