df

package
v0.0.0-...-886287a Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package df wraps Unix 'df' command. Reference https://en.wikipedia.org/wiki/Df_(Unix).

Index

Constants

This section is empty.

Variables

View Source
var Headers = []string{
	"Filesystem",

	"Mounted",
	"on",

	"Type",
	"File",
	"Inodes",
	"IFree",
	"IUsed",
	"IUse%",
	"1K-blocks",
	"Avail",
	"Used",
	"Use%",
}

Headers is the headers in 'df' output.

View Source
var RowSchema = schema.RawData{
	IsYAML: false,
	Columns: []schema.Column{
		{Name: "file-system", Godoc: "file system ('source')", Kind: reflect.String},
		{Name: "device", Godoc: "device name", Kind: reflect.String},
		{Name: "mounted-on", Godoc: "'mounted on' ('target')", Kind: reflect.String},
		{Name: "file-system-type", Godoc: "file system type ('fstype')", Kind: reflect.String},
		{Name: "file", Godoc: "file name if specified on the command line ('file')", Kind: reflect.String},

		{Name: "inodes", Godoc: "total number of inodes ('itotal')", Kind: reflect.Int64},
		{Name: "ifree", Godoc: "number of available inodes ('iavail')", Kind: reflect.Int64},
		{Name: "iused", Godoc: "number of used inodes ('iused')", Kind: reflect.Int64},
		{Name: "iused-percent", Godoc: "percentage of iused divided by itotal ('ipcent')", Kind: reflect.String},

		{Name: "total-blocks", Godoc: "total number of 1K-blocks ('size')", Kind: reflect.Int64},
		{Name: "available-blocks", Godoc: "number of available 1K-blocks ('avail')", Kind: reflect.Int64},
		{Name: "used-blocks", Godoc: "number of used 1K-blocks ('used')", Kind: reflect.Int64},
		{Name: "used-blocks-percent", Godoc: "percentage of used-blocks divided by total-blocks ('pcent')", Kind: reflect.String},
	},
	ColumnsToParse: map[string]schema.RawDataType{
		"total-blocks":     schema.TypeBytes,
		"available-blocks": schema.TypeBytes,
		"used-blocks":      schema.TypeBytes,
	},
}

RowSchema represents 'df' command output row (See https://en.wikipedia.org/wiki/Df_(Unix) and https://www.gnu.org/software/coreutils/manual/html_node/df-invocation.html and 'df --all --sync --block-size=1024 --output=source,target,fstype,file,itotal,iavail,iused,ipcent,size,avail,used,pcent' and the output unit is kilobytes).

Functions

func GetDevice

func GetDevice(target string) (string, error)

GetDevice returns the device name where dir is mounted.

func Read

func Read(dfPath string, target string) (string, error)

Read reads Linux 'df' command output. Pass ” target to list all information.

func ReadDefault

func ReadDefault(target string) (string, error)

ReadDefault reads Linux 'df' command output. Pass ” target to list all information.

Types

type Row

type Row struct {
	// FileSystem is file system ('source').
	FileSystem string `column:"file_system"`
	// Device is device name.
	Device string `column:"device"`
	// MountedOn is 'mounted on' ('target').
	MountedOn string `column:"mounted_on"`
	// FileSystemType is file system type ('fstype').
	FileSystemType string `column:"file_system_type"`
	// File is file name if specified on the command line ('file').
	File string `column:"file"`
	// Inodes is total number of inodes ('itotal').
	Inodes int64 `column:"inodes"`
	// Ifree is number of available inodes ('iavail').
	Ifree int64 `column:"ifree"`
	// Iused is number of used inodes ('iused').
	Iused int64 `column:"iused"`
	// IusedPercent is percentage of iused divided by itotal ('ipcent').
	IusedPercent string `column:"iused_percent"`
	// TotalBlocks is total number of 1K-blocks ('size').
	TotalBlocks            int64  `column:"total_blocks"`
	TotalBlocksBytesN      int64  `column:"total_blocks_bytes_n"`
	TotalBlocksParsedBytes string `column:"total_blocks_parsed_bytes"`
	// AvailableBlocks is number of available 1K-blocks ('avail').
	AvailableBlocks            int64  `column:"available_blocks"`
	AvailableBlocksBytesN      int64  `column:"available_blocks_bytes_n"`
	AvailableBlocksParsedBytes string `column:"available_blocks_parsed_bytes"`
	// UsedBlocks is number of used 1K-blocks ('used').
	UsedBlocks            int64  `column:"used_blocks"`
	UsedBlocksBytesN      int64  `column:"used_blocks_bytes_n"`
	UsedBlocksParsedBytes string `column:"used_blocks_parsed_bytes"`
	// UsedBlocksPercent is percentage of used-blocks divided by total-blocks ('pcent').
	UsedBlocksPercent string `column:"used_blocks_percent"`
}

Row is 'df' command output row in Linux.

func Get

func Get(dfPath string, target string) ([]Row, error)

Get returns entries in 'df' command. Pass ” target to list all information.

func GetDefault

func GetDefault(target string) ([]Row, error)

GetDefault returns entries in 'df' command. Pass ” target to list all information.

func Parse

func Parse(s string) ([]Row, error)

Parse parses 'df' command output and returns the rows.

Jump to

Keyboard shortcuts

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