-func iostat(devs ...string) {
- stats := make([]string, len(devs)*4)
- for i := 0; i < len(devs); i++ {
- stats[i*4+1] = "/"
- stats[i*4+3] = " "
+func iostat() {
+ var stats []string
+ for cols := range bg("iostat", "-d", "-w", "1", "-x") {
+ if cols[0] == "device" {
+ IOs = strings.Join(stats, " ")
+ stats = nil
+ continue
+ }
+ if len(cols) < 4 || (cols[1] == "0" && cols[2] == "0") {
+ continue
+ }
+ stats = append(stats, fmt.Sprintf("%s:%s/%s", cols[0], cols[1], cols[2]))