提交 c5e37d9f 编写于 作者: S shirou

Merge pull request #11 from def/master

Disk stat changes  (rebased)
......@@ -31,6 +31,7 @@ type DiskIOCountersStat struct {
ReadTime uint64 `json:"readTime"`
WriteTime uint64 `json:"writeTime"`
Name string `json:"name"`
IoTime uint64 `json:"ioTime"`
}
func (d DiskUsageStat) String() string {
......
......@@ -71,6 +71,7 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
}
d := DiskPartitionStat{
Device: byteToString(stat.FMntfromname[:]),
Mountpoint: byteToString(stat.FMntonname[:]),
Fstype: byteToString(stat.FFstypename[:]),
Opts: opts,
......
......@@ -25,6 +25,7 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
for _, line := range lines {
fields := strings.Fields(line)
d := DiskPartitionStat{
Device: fields[0],
Mountpoint: fields[1],
Fstype: fields[2],
Opts: fields[3],
......@@ -53,6 +54,7 @@ func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
writes := mustParseUint64(fields[7])
wbytes := mustParseUint64(fields[9])
wtime := mustParseUint64(fields[10])
iotime := mustParseUint64(fields[13])
d := DiskIOCountersStat{
ReadBytes: rbytes * SectorSize,
WriteBytes: wbytes * SectorSize,
......@@ -60,6 +62,7 @@ func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
WriteCount: writes,
ReadTime: rtime,
WriteTime: wtime,
IoTime: iotime,
}
if d == empty {
continue
......
......@@ -85,7 +85,7 @@ func TestDiskIOCountersStat_String(t *testing.T) {
ReadBytes: 300,
WriteBytes: 400,
}
e := `{"readCount":100,"writeCount":200,"readBytes":300,"writeBytes":400,"readTime":0,"writeTime":0,"name":"sd01"}`
e := `{"readCount":100,"writeCount":200,"readBytes":300,"writeBytes":400,"readTime":0,"writeTime":0,"name":"sd01","ioTime":0}`
if e != fmt.Sprintf("%v", v) {
t.Errorf("DiskUsageStat string is invalid: %v", v)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册