-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1074 from scop/feat/solaris-load-procsrunning
[load][solaris] support MiscStat.ProcsRunning
- Loading branch information
Showing
4 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// +build solaris | ||
|
||
package load | ||
|
||
import ( | ||
"context" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/shirou/gopsutil/internal/common" | ||
) | ||
|
||
func Avg() (*AvgStat, error) { | ||
return AvgWithContext(context.Background()) | ||
} | ||
|
||
func AvgWithContext(ctx context.Context) (*AvgStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func Misc() (*MiscStat, error) { | ||
return MiscWithContext(context.Background()) | ||
} | ||
|
||
func MiscWithContext(ctx context.Context) (*MiscStat, error) { | ||
bin, err := exec.LookPath("ps") | ||
if err != nil { | ||
return nil, err | ||
} | ||
out, err := invoke.CommandWithContext(ctx, bin, "-efo", "s") | ||
if err != nil { | ||
return nil, err | ||
} | ||
lines := strings.Split(string(out), "\n") | ||
|
||
ret := MiscStat{} | ||
for _, l := range lines { | ||
if l == "O" { | ||
ret.ProcsRunning++ | ||
} | ||
} | ||
|
||
return &ret, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// +build solaris | ||
|
||
package load | ||
|
||
import ( | ||
"context" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/shirou/gopsutil/v3/internal/common" | ||
) | ||
|
||
func Avg() (*AvgStat, error) { | ||
return AvgWithContext(context.Background()) | ||
} | ||
|
||
func AvgWithContext(ctx context.Context) (*AvgStat, error) { | ||
return nil, common.ErrNotImplementedError | ||
} | ||
|
||
func Misc() (*MiscStat, error) { | ||
return MiscWithContext(context.Background()) | ||
} | ||
|
||
func MiscWithContext(ctx context.Context) (*MiscStat, error) { | ||
bin, err := exec.LookPath("ps") | ||
if err != nil { | ||
return nil, err | ||
} | ||
out, err := invoke.CommandWithContext(ctx, bin, "-efo", "s") | ||
if err != nil { | ||
return nil, err | ||
} | ||
lines := strings.Split(string(out), "\n") | ||
|
||
ret := MiscStat{} | ||
for _, l := range lines { | ||
if l == "O" { | ||
ret.ProcsRunning++ | ||
} | ||
} | ||
|
||
return &ret, nil | ||
} |