...

Source file src/github.com/shirou/gopsutil/load/load_solaris.go

Documentation: github.com/shirou/gopsutil/load

     1  // +build solaris
     2  
     3  package load
     4  
     5  import (
     6  	"context"
     7  	"os/exec"
     8  	"strings"
     9  
    10  	"github.com/shirou/gopsutil/internal/common"
    11  )
    12  
    13  func Avg() (*AvgStat, error) {
    14  	return AvgWithContext(context.Background())
    15  }
    16  
    17  func AvgWithContext(ctx context.Context) (*AvgStat, error) {
    18  	return nil, common.ErrNotImplementedError
    19  }
    20  
    21  func Misc() (*MiscStat, error) {
    22  	return MiscWithContext(context.Background())
    23  }
    24  
    25  func MiscWithContext(ctx context.Context) (*MiscStat, error) {
    26  	bin, err := exec.LookPath("ps")
    27  	if err != nil {
    28  		return nil, err
    29  	}
    30  	out, err := invoke.CommandWithContext(ctx, bin, "-efo", "s")
    31  	if err != nil {
    32  		return nil, err
    33  	}
    34  	lines := strings.Split(string(out), "\n")
    35  
    36  	ret := MiscStat{}
    37  	for _, l := range lines {
    38  		if l == "O" {
    39  			ret.ProcsRunning++
    40  		}
    41  	}
    42  
    43  	return &ret, nil
    44  }
    45  

View as plain text