resourceutil

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

README

Package resourceutil provides easy access to system resources.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAvailableMem

func GetAvailableMem() (int, error)

GetAvailableMem retrieves available memory in kilobytes from /proc/meminfo.

func GetBatterySOC

func GetBatterySOC(batteryName string) (int, error)

GetBatterySOC retrieves the State of Charge (SOC) of the battery as a percentage.

func GetBatterySOH

func GetBatterySOH(batteryName string) (int, error)

GetBatterySOH retrieves the State of Health (SOH) of the battery as a percentage.

SOH is calculated as the ratio of the battery's current maximum energy capacity as a percentage of its original design capacity.

func GetCPULoad

func GetCPULoad() (float64, error)

GetCPULoad calculates the current CPU load percentage by reading data from the /proc/stat file.

func GetMemUsage

func GetMemUsage() (float64, error)

GetMemUsage calculates the current memory usage in percent.

func GetTotalMem

func GetTotalMem() (int, error)

GetTotalMem retrieves total memory in kilobytes from /proc/meminfo.

Types

type StorageUsage

type StorageUsage struct {
	TotalGB     float64
	FreeGB      float64
	UsedGB      float64
	UsedPercent float64
}

StorageUsage represents disk storage metrics. Fields:

  • TotalGB (float64): The total storage capacity in gigabytes.
  • FreeGB (float64): The available storage in gigabytes for non-root users.
  • UsedGB (float64): The amount of used storage in gigabytes.
  • UsedPercent (float64): The percentage of storage in use.

func GetDiskUsage

func GetDiskUsage(path string) (StorageUsage, error)

GetDiskUsage retrieves disk usage statistics for a given file system path.

Jump to

Keyboard shortcuts

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