Add processes created to misc stats

This commit is contained in:
James Bebbington 2020-07-02 11:40:58 +10:00
parent 10a398abdd
commit 28b2246b5b
3 changed files with 5 additions and 1 deletions

View File

@ -21,6 +21,7 @@ func (l AvgStat) String() string {
type MiscStat struct { type MiscStat struct {
ProcsTotal int `json:"procsTotal"` ProcsTotal int `json:"procsTotal"`
ProcsCreated int `json:"procsCreated"`
ProcsRunning int `json:"procsRunning"` ProcsRunning int `json:"procsRunning"`
ProcsBlocked int `json:"procsBlocked"` ProcsBlocked int `json:"procsBlocked"`
Ctxt int `json:"ctxt"` Ctxt int `json:"ctxt"`

View File

@ -92,6 +92,8 @@ func MiscWithContext(ctx context.Context) (*MiscStat, error) {
continue continue
} }
switch fields[0] { switch fields[0] {
case "processes":
ret.ProcsCreated = int(v)
case "procs_running": case "procs_running":
ret.ProcsRunning = int(v) ret.ProcsRunning = int(v)
case "procs_blocked": case "procs_blocked":

View File

@ -47,11 +47,12 @@ func TestMisc(t *testing.T) {
func TestMiscStatString(t *testing.T) { func TestMiscStatString(t *testing.T) {
v := MiscStat{ v := MiscStat{
ProcsTotal: 4, ProcsTotal: 4,
ProcsCreated: 5,
ProcsRunning: 1, ProcsRunning: 1,
ProcsBlocked: 2, ProcsBlocked: 2,
Ctxt: 3, Ctxt: 3,
} }
e := `{"procsTotal":4,"procsRunning":1,"procsBlocked":2,"ctxt":3}` e := `{"procsTotal":4,"procsCreated":5,"procsRunning":1,"procsBlocked":2,"ctxt":3}`
if e != fmt.Sprintf("%v", v) { if e != fmt.Sprintf("%v", v) {
t.Errorf("TestMiscString string is invalid: %v", v) t.Errorf("TestMiscString string is invalid: %v", v)
} }