提交 c5e37d9f 编写于 作者: S shirou

Merge pull request #11 from def/master

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