Example #1
0
func GetFileSystemList75() []string {
	result := []string{}
	volumes := []sigar.FileSystem{}

	if runtime.GOOS == "windows" {
		volumes = getWindowsDrives()
	} else {
		fslist := sigar.FileSystemList{}
		fslist.Get()
		volumes = fslist.List
	}

	for _, volume := range volumes {
		dirName := volume.DirName
		usage := sigar.FileSystemUsage{}
		usage.Get(dirName)

		if usage.UsePercent() >= 75 {
			result = append(result, fmt.Sprintf("%s (%s)",
				dirName,
				sigar.FormatPercent(usage.UsePercent())))
		}
	}
	return result
}
Example #2
0
func main() {
	fslist := gosigar.FileSystemList{}
	fslist.Get()

	fmt.Fprintf(os.Stdout, output_format,
		"Filesystem", "Size", "Used", "Avail", "Use%", "Mounted on")

	for _, fs := range fslist.List {
		dir_name := fs.DirName

		usage := gosigar.FileSystemUsage{}

		usage.Get(dir_name)

		fmt.Fprintf(os.Stdout, output_format,
			fs.DevName,
			gosigar.FormatSize(usage.Total),
			gosigar.FormatSize(usage.Used),
			gosigar.FormatSize(usage.Avail),
			gosigar.FormatPercent(usage.UsePercent()),
			dir_name)
	}
}