...

Source file src/golang.conradwood.net/tests/authtest/load.go

Documentation: golang.conradwood.net/tests/authtest

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"golang.conradwood.net/go-easyops/linux"
     6  	"golang.conradwood.net/go-easyops/utils"
     7  	"time"
     8  )
     9  
    10  func LoadClient() {
    11  	la := linux.Loadavg{}
    12  xloop:
    13  	c, err := la.GetCPULoad(nil, nil)
    14  	if err != nil {
    15  		fmt.Printf("Fail: %s\n", err)
    16  	} else {
    17  		//	fmt.Printf("Sum=%d, IdleTime=%0.1f%%, Idle=%d,User=%d\n", c.Sum, c.IdleTime, c.Idle, c.User)
    18  		fmt.Printf("[%20s] Load: CPUs %2d, Total: %0.2f, PerCPU: %0.2f, IdleTime: %0.2f%%\n", utils.TimeString(time.Now()), c.CPUCount, c.Avg1, c.PerCPU, c.IdleTime)
    19  	}
    20  	if *loop {
    21  		time.Sleep(time.Duration(1000) * time.Millisecond)
    22  		goto xloop
    23  	}
    24  	fmt.Printf("\n")
    25  }
    26  

View as plain text