system

package
v0.0.0-...-6d09ece Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	// Temperature, in °C.
	Temperature int8
	// Utilization of individual cores, in percent.
	CoreUtilizations map[string]float64
}

CPU is a reference to a processor.

Members `Temperature`, `Size` and `Used` may not be available, depending on the method that was used to create the instance of the object.

func GetCPU

func GetCPU() (CPU, error)

GetCPU returns a reference to the processor.

func (*CPU) FillTemperature

func (c *CPU) FillTemperature() error

FillTemperature reads the processor temperature in °C.

type Drive

type Drive struct {
	// Name of the drive, e.g. `sda`, `nvme0n1`.
	Name string
	// Path of the drive, e.g. `/dev/sda`, `/dev/nvme0n1`.
	Path string
	// Drive model, e.g. `WDC WDS100T2B0A-00SM50`.
	Model string
	// UUID
	UUID string
	// Partition table type, e.g. `gpt`.
	PartitionTableType string
	// Serial number.
	Serial string
	// Temperature, in °C.
	Temperature uint8
	// Total size, in bytes.
	Size uint64
	// Utilization, in bytes.
	Used uint64
	// Physical partitions, e.g. `/dev/sda`.
	PhysicalPartitions []Partition
	// LUKS partitions, e.g. `luks-3360132c-99e3-4017-896f-d8c0ff2b1fc0`.
	LUKSPartitions []Partition
	// LVM partitions, e.g. `luks-root`.
	LogicalPartitions []Partition
}

Drive is a reference to a physical drive.

Members `Temperature`, `Size` and `Used` may not be available, depending on the method that was used to create the instance of the object.

func GetDriveList

func GetDriveList() ([]Drive, error)

GetDriveList gets a list of physical drives using lsblk.

func (*Drive) FillSize

func (d *Drive) FillSize() error

FillSize reads usage information of drive partitions to obtain its size and utilization in bytes, using `df`.

The size and utilization of a drive is computed by adding up values of its partitions.

func (*Drive) FillTemperature

func (d *Drive) FillTemperature() error

FillTemperature reads S.M.A.R.T. of physical drive to obtain its temperature in °C, using `smartctl`.

Since Argon connects all drives using SATA over USB, `-d sat` needs to be passed in. This may cause some weirdness during development.

This may cause the drive to wake up.

func (*Drive) FillUtilization

func (d *Drive) FillUtilization() error

FillUtilization reads utilization of individual cores.

Due to the way the utilization is computed, this function requires one second delay to process.

type Partition

type Partition struct {
	Drive Drive
	// Filesystem type, e.g. `ext4`, `xfs`.
	Filesystem string
	// Label, e.g. `efi`.
	Label string
	// Mount point, e.g. `/boot/efi`.
	Mountpoint string
	// Name, e.g. `sda1`.
	Name string
	// Physical path, e.g. `/dev/sda1`.
	Path string
	// Total size, in bytes.
	Size uint64
	// Utilization, in bytes.
	Used uint64
	// UUID.
	UUID string
}

Partition is a reference to a partition on a drive.

Members `Size` and `Used` may not be available, depending on the method that was used to create the instance of the object.

Jump to

Keyboard shortcuts

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