Skip to content

Commit

Permalink
[cpu]: remove unused field Stolen
Browse files Browse the repository at this point in the history
see #676
  • Loading branch information
shirou committed Apr 27, 2019
1 parent fa98459 commit cae8efc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type TimesStat struct {
Steal float64 `json:"steal"`
Guest float64 `json:"guest"`
GuestNice float64 `json:"guestNice"`
Stolen float64 `json:"stolen"`
}

type InfoStat struct {
Expand Down Expand Up @@ -80,7 +79,6 @@ func (c TimesStat) String() string {
`"steal":` + strconv.FormatFloat(c.Steal, 'f', 1, 64),
`"guest":` + strconv.FormatFloat(c.Guest, 'f', 1, 64),
`"guestNice":` + strconv.FormatFloat(c.GuestNice, 'f', 1, 64),
`"stolen":` + strconv.FormatFloat(c.Stolen, 'f', 1, 64),
}

return `{` + strings.Join(v, ",") + `}`
Expand All @@ -89,7 +87,7 @@ func (c TimesStat) String() string {
// Total returns the total number of seconds in a CPUTimesStat
func (c TimesStat) Total() float64 {
total := c.User + c.System + c.Nice + c.Iowait + c.Irq + c.Softirq + c.Steal +
c.Guest + c.GuestNice + c.Idle + c.Stolen
c.Guest + c.GuestNice + c.Idle
return total
}

Expand All @@ -100,7 +98,7 @@ func (c InfoStat) String() string {

func getAllBusy(t TimesStat) (float64, float64) {
busy := t.User + t.System + t.Nice + t.Iowait + t.Irq +
t.Softirq + t.Steal + t.Guest + t.GuestNice + t.Stolen
t.Softirq + t.Steal + t.Guest + t.GuestNice
return busy + t.Idle, busy
}

Expand Down
2 changes: 1 addition & 1 deletion cpu/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestCPUTimeStat_String(t *testing.T) {
System: 200.1,
Idle: 300.1,
}
e := `{"cpu":"cpu0","user":100.1,"system":200.1,"idle":300.1,"nice":0.0,"iowait":0.0,"irq":0.0,"softirq":0.0,"steal":0.0,"guest":0.0,"guestNice":0.0,"stolen":0.0}`
e := `{"cpu":"cpu0","user":100.1,"system":200.1,"idle":300.1,"nice":0.0,"iowait":0.0,"irq":0.0,"softirq":0.0,"steal":0.0,"guest":0.0,"guestNice":0.0}`
if e != fmt.Sprintf("%v", v) {
t.Errorf("CPUTimesStat string is invalid: %v", v)
}
Expand Down

0 comments on commit cae8efc

Please sign in to comment.