Add new measurement with results of pgrep lookup to procstat input (#4307)

This commit is contained in:
maxunt
2018-06-19 11:47:13 -07:00
committed by Daniel Nelson
parent 8b678b9041
commit 86e4cd0083
4 changed files with 53 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ import (
"os/exec"
"strconv"
"strings"
"syscall"
"time"
"unicode"
)
@@ -193,3 +194,15 @@ func RandomSleep(max time.Duration, shutdown chan struct{}) {
return
}
}
// Exit status takes the error from exec.Command
// and returns the exit status and true
// if error is not exit status, will return 0 and false
func ExitStatus(err error) (int, bool) {
if exiterr, ok := err.(*exec.ExitError); ok {
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
return status.ExitStatus(), true
}
}
return 0, false
}