Skip to content

Instantly share code, notes, and snippets.

@shirou
Last active December 16, 2018 23:06
Show Gist options
  • Save shirou/004b2a859ed5f33ca659e431b7378d17 to your computer and use it in GitHub Desktop.
Save shirou/004b2a859ed5f33ca659e431b7378d17 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/shirou/gopsutil/disk"
)
func main() {
parts, err := disk.Partitions(true)
if err != nil {
panic(err)
}
for _, part := range parts {
u, errUsage := disk.Usage(part.Mountpoint)
if errUsage != nil {
fmt.Println(errUsage)
continue
}
counters, errIO := disk.IOCounters(part.Mountpoint)
if errIO != nil {
fmt.Println(errIO)
}
fmt.Println(u, counters)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment