disk

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package disk tracks the disk usage of all the mount points specified in the configuration.

Index

Constants

View Source
const (
	StateNameDiskExtPartition = "disk_ext_partition"

	StateKeyDiskPartitionDevice     = "device"
	StateKeyDiskPartitionMountPoint = "mount_point"
	StateKeyDiskPartitionFstype     = "fstype"

	StateNameDiskUsage = "disk_usage"

	StateKeyDiskUsageMountPoint        = "mount_point"
	StateKeyDiskUsageFstype            = "fstype"
	StateKeyDiskUsageTotalBytes        = "total_bytes"
	StateKeyDiskUsageTotalHumanized    = "total_humanized"
	StateKeyDiskUsageFreeBytes         = "free_bytes"
	StateKeyDiskUsageFreeHumanized     = "free_humanized"
	StateKeyDiskUsageUsedBytes         = "used_bytes"
	StateKeyDiskUsageUsedHumanized     = "used_humanized"
	StateKeyDiskUsageUsedPercent       = "used_percent"
	StateKeyDiskUsageInodesTotal       = "inodes_total"
	StateKeyDiskUsageInodesUsed        = "inodes_used"
	StateKeyDiskUsageInodesFree        = "inodes_free"
	StateKeyDiskUsageInodesUsedPercent = "inodes_used_percent"
)
View Source
const Name = "disk"

Variables

This section is empty.

Functions

func CreateGet

func CreateGet(cfg Config) query.GetFunc

func New

Types

type Config

type Config struct {
	Query       query_config.Config `json:"query"`
	MountPoints []string            `json:"mount_points"`
}

func DefaultConfig

func DefaultConfig() Config

func ParseConfig

func ParseConfig(b any, db *sql.DB) (*Config, error)

func (Config) Validate

func (cfg Config) Validate() error

type Output

type Output struct {
	ExtPartitions []Partition `json:"ext_partitions"`
	Usages        []Usage     `json:"usages"`
}

func ParseOutputJSON

func ParseOutputJSON(data []byte) (*Output, error)

func ParseStatesToOutput

func ParseStatesToOutput(states ...components.State) (*Output, error)

func (*Output) JSON

func (o *Output) JSON() ([]byte, error)

func (*Output) States

func (o *Output) States() ([]components.State, error)

type Partition

type Partition struct {
	Device     string `json:"device"`
	MountPoint string `json:"mount_point"`
	Fstype     string `json:"fstype"`
}

func ParseStateDiskPartition

func ParseStateDiskPartition(m map[string]string) (Partition, error)

func (Partition) Map

func (p Partition) Map() map[string]string

type Usage

type Usage struct {
	MountPoint string `json:"path"`
	Fstype     string `json:"fstype"`

	TotalBytes     uint64 `json:"total_bytes"`
	TotalHumanized string `json:"total_humanized"`

	FreeBytes     uint64 `json:"free_bytes"`
	FreeHumanized string `json:"free_humanized"`

	UsedBytes     uint64 `json:"used_bytes"`
	UsedHumanized string `json:"used_humanized"`

	UsedPercent      string  `json:"used_percent"`
	UsedPercentFloat float64 `json:"-"`

	InodesTotal       uint64 `json:"inodes_total"`
	InodesUsed        uint64 `json:"inodes_used"`
	InodesFree        uint64 `json:"inodes_free"`
	InodesUsedPercent string `json:"inodes_used_percent"`

	InodesUsedPercentFloat float64 `json:"-"`
}

func ParseStateDiskUsage

func ParseStateDiskUsage(m map[string]string) (Usage, error)

func (Usage) GetUsedPercent

func (u Usage) GetUsedPercent() (float64, error)

func (Usage) Map

func (u Usage) Map() map[string]string

Directories

Path Synopsis
Package metrics implements the disk metrics collection and reporting.
Package metrics implements the disk metrics collection and reporting.

Jump to

Keyboard shortcuts

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