disk

package
v0.0.0-...-9ba49b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Local = local{}

Local is a standard implementation of the Disk interface that uses gosigar and unix.Stat to obtain statistics for the local machine.

Functions

func FormatBytes

func FormatBytes(kb uint64) string

Types

type CheckUsageType

type CheckUsageType func(streams step.OutStreams, d Disk, diskFreeRatio float64, paths ...string) (FileSystemDiskUsage, error)

type Disk

type Disk interface {
	Filesystems() (sigar.FileSystemList, error)
	Usage(string) (sigar.FileSystemUsage, error)
	Stat(string) (*unix.Stat_t, error)
}

type FileSystemDiskUsage

type FileSystemDiskUsage []*idl.CheckDiskSpaceReply_DiskUsage

func CheckUsage

func CheckUsage(streams step.OutStreams, d Disk, diskFreeRatio float64, paths ...string) (FileSystemDiskUsage, error)

CheckUsage uses the given Disk to look up filesystem usage for each path, and compares the available space to the required disk ratio. Any filesystems that don't have enough space will be given an entry in the returned SpaceFailures map. Note that this is one entry per filesystem, not one entry per path.

This function ignores space that has been reserved for the superuser (i.e. the difference between "free" and "avail" in statfs(2)). It does not consider that space to be free for use, nor does it count that space against the total disk size. For example, a disk with 25% avail space and 75% free space -- as defined by statfs(2) -- would be considered 50% available by CheckUsage.

func (FileSystemDiskUsage) Len

func (f FileSystemDiskUsage) Len() int

func (FileSystemDiskUsage) Less

func (f FileSystemDiskUsage) Less(i, j int) bool

func (FileSystemDiskUsage) Swap

func (f FileSystemDiskUsage) Swap(i, j int)

type FilesystemHost

type FilesystemHost struct {
	Filesystem string
	Host       string
}

type SpaceUsageErr

type SpaceUsageErr struct {
	// contains filtered or unexported fields
}

func NewSpaceUsageErrorFromUsage

func NewSpaceUsageErrorFromUsage(usage *idl.CheckDiskSpaceReply_DiskUsage) *SpaceUsageErr

func (SpaceUsageErr) Error

func (d SpaceUsageErr) Error() string

func (SpaceUsageErr) Table

func (d SpaceUsageErr) Table() [][]string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL