Merge pull request #263 from digitalis-io/master

added weightedIO field to disk IOCountersStat (last field of /etc/mtab)
This commit is contained in:
shirou 2016-09-22 21:59:23 +09:00 committed by GitHub
commit af2b5127ea
3 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,7 @@ type IOCountersStat struct {
WriteTime uint64 `json:"writeTime"`
IopsInProgress uint64 `json:"iopsInProgress"`
IoTime uint64 `json:"ioTime"`
WeightedIO uint64 `json:"weightedIO"`
Name string `json:"name"`
SerialNumber string `json:"serialNumber"`
}

View File

@ -328,6 +328,10 @@ func IOCounters() (map[string]IOCountersStat, error) {
if err != nil {
return ret, err
}
weightedIO, err := strconv.ParseUint((fields[13]), 10, 64)
if err != nil {
return ret, err
}
d := IOCountersStat{
ReadBytes: rbytes * SectorSize,
WriteBytes: wbytes * SectorSize,
@ -339,6 +343,7 @@ func IOCounters() (map[string]IOCountersStat, error) {
WriteTime: wtime,
IopsInProgress: iopsInProgress,
IoTime: iotime,
WeightedIO: weightedIO,
}
if d == empty {
continue

View File

@ -93,7 +93,7 @@ func TestDiskIOCountersStat_String(t *testing.T) {
WriteBytes: 400,
SerialNumber: "SERIAL",
}
e := `{"readCount":100,"mergedReadCount":0,"writeCount":200,"mergedWriteCount":0,"readBytes":300,"writeBytes":400,"readTime":0,"writeTime":0,"iopsInProgress":0,"ioTime":0,"name":"sd01","serialNumber":"SERIAL"}`
e := `{"readCount":100,"mergedReadCount":0,"writeCount":200,"mergedWriteCount":0,"readBytes":300,"writeBytes":400,"readTime":0,"writeTime":0,"iopsInProgress":0,"ioTime":0,"weightedIO":0,"name":"sd01","serialNumber":"SERIAL"}`
if e != fmt.Sprintf("%v", v) {
t.Errorf("DiskUsageStat string is invalid: %v", v)
}