hwmon

package
v0.11.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMetric = errors.New("no Metrics exist in this device")

ErrNoMetric specifies that no metrics were found for a given Sensor. This is meant to be a soft error if needed, as the slapdash nature of hwmon sysfs files means that we can see *_label files with no corresponding metrics, and so on

View Source
var FanSensor = SensorType{/* contains filtered or unexported fields */}

FanSensor is the prefix for fan sensors

View Source
var TempSensor = SensorType{/* contains filtered or unexported fields */}

TempSensor is the string prefix for a temp sensor

View Source
var VoltSensor = SensorType{/* contains filtered or unexported fields */}

VoltSensor is the prefix for voltage sensors

Functions

This section is empty.

Types

type Device

type Device struct {
	// Name is the specified hwmon label for the directory
	Name string
	// AbsPath is the absolute path to the monitoring directory, usually linked as /sys/class/hwmon/hwmon*
	AbsPath string
	//Sensors are the individual metrics connected to a device
	Sensors []Sensor
}

Device represents a single sensor chip, usually exposed as /sys/class/hwmon/hwmon*

func DetectHwmon

func DetectHwmon(hostfs resolve.Resolver) ([]Device, error)

DetectHwmon returns a list of hwmon sensors found on the system, if they exist

type MonData

type MonData map[string]SensorMetrics

MonData is a simple wrapper type for the map returned by ReportSensors

func ReportSensors

func ReportSensors(dev Device) (MonData, error)

ReportSensors returns the metrics from all the known sensors.

type Sensor

type Sensor struct {
	DevType SensorType
	// SensorNum is the numerical ID of the sensor, i.e temp7_*
	SensorNum int64
}

Sensor is used to track a single hwmon chip metric

func (Sensor) Fetch

func (s Sensor) Fetch(path string) (SensorMetrics, error)

Fetch fetches the metrics and data for the sensor.

type SensorMetrics

type SensorMetrics struct {
	//Generic Fields
	Label string `struct:"label,omitempty"`

	Critical opt.Uint `struct:"critical,omitempty"`
	Max      opt.Uint `struct:"max,omitempty"`
	Lowest   opt.Uint `struct:"lowest,omitempty"`
	Average  opt.Uint `struct:"average,omitempty"`

	// The input value of the metric. The key is overridden and set to the value of sensorType by Fold()
	Value opt.Uint `struct:"value,omitempty"`
	// contains filtered or unexported fields
}

SensorMetrics reports the actual metrics in a sensor This is meant to be generic for all possible sensor types.

func (*SensorMetrics) Fold

func (sm *SensorMetrics) Fold(v structform.ExtVisitor) error

Fold implements the Folder interface for structform This is entirely so we can carry around a relatively simple struct that transforms into the more heavily nested event that's the standard for beats events.

type SensorType

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

SensorType is for the string prefix of the sensor files

Jump to

Keyboard shortcuts

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