Documentation
¶
Overview ¶
Package sysfs provides functions to retrieve system and kernel metrics from the pseudo-filesystem sys.
Index ¶
- Constants
- type ClassThermalZoneStats
- type ClockSource
- type FS
- func (fs FS) ClassThermalZoneStats() ([]ClassThermalZoneStats, error)
- func (fs FS) ClockSources() ([]ClockSource, error)
- func (fs FS) InfiniBandClass() (InfiniBandClass, error)
- func (fs FS) NetClass() (NetClass, error)
- func (fs FS) NetClassDevices() ([]string, error)
- func (fs FS) PowerSupplyClass() (PowerSupplyClass, error)
- func (fs FS) SystemCpufreq() ([]SystemCPUCpufreqStats, error)
- type InfiniBandClass
- type InfiniBandCounters
- type InfiniBandDevice
- type InfiniBandPort
- type NetClass
- type NetClassIface
- type PowerSupply
- type PowerSupplyClass
- type SystemCPUCpufreqStats
Constants ¶
const DefaultMountPoint = fs.DefaultSysMountPoint
DefaultMountPoint is the common mount point of the sys filesystem.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClassThermalZoneStats ¶
type ClassThermalZoneStats struct {
Name string // The name of the zone from the directory structure.
Type string // The type of thermal zone.
Temp uint64 // Temperature in millidegree Celsius.
Policy string // One of the various thermal governors used for a particular zone.
Mode *bool // Optional: One of the predefined values in [enabled, disabled].
Passive *uint64 // Optional: millidegrees Celsius. (0 for disabled, > 1000 for enabled+value)
}
ClassThermalZoneStats contains info from files in /sys/class/thermal/thermal_zone<zone> for a single <zone>. https://www.kernel.org/doc/Documentation/thermal/sysfs-api.txt
type ClockSource ¶
type ClockSource struct {
Name string
Available []string
Current string
}
ClockSource contains metrics related to the clock source
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS represents the pseudo-filesystem sys, which provides an interface to kernel data structures.
func NewDefaultFS ¶ added in v0.0.2
func NewDefaultFS() (FS, error)
NewDefaultFS returns a new FS mounted under the default mountPoint. It will error if the mount point can't be read.
func NewFS ¶
func NewFS(mountPoint string) (FS, error)
NewFS returns a new FS mounted under the given mountPoint. It will error if the mount point can't be read.
func (FS) ClassThermalZoneStats ¶ added in v0.0.2
func (fs FS) ClassThermalZoneStats() ([]ClassThermalZoneStats, error)
ClassThermalZoneStats returns Thermal Zone metrics for all zones.
func (FS) ClockSources ¶
func (fs FS) ClockSources() ([]ClockSource, error)
ClockSources returns clocksource information including current and available clocksources read from '/sys/devices/system/clocksource'
func (FS) InfiniBandClass ¶ added in v0.0.3
func (fs FS) InfiniBandClass() (InfiniBandClass, error)
InfiniBandClass returns info for all InfiniBand devices read from /sys/class/infiniband.
func (FS) NetClass ¶ added in v0.0.2
func (fs FS) NetClass() (NetClass, error)
NetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
func (FS) NetClassDevices ¶
func (fs FS) NetClassDevices() ([]string, error)
NetClassDevices scans /sys/class/net for devices and returns them as a list of names.
func (FS) PowerSupplyClass ¶ added in v0.0.2
func (fs FS) PowerSupplyClass() (PowerSupplyClass, error)
PowerSupplyClass returns info for all power supplies read from /sys/class/power_supply.
func (FS) SystemCpufreq ¶ added in v0.0.2
func (fs FS) SystemCpufreq() ([]SystemCPUCpufreqStats, error)
SystemCpufreq returns CPU frequency metrics for all CPUs.
type InfiniBandClass ¶ added in v0.0.3
type InfiniBandClass map[string]InfiniBandDevice
InfiniBandClass is a collection of every InfiniBand device in /sys/class/infiniband.
The map keys are the names of the InfiniBand devices.
type InfiniBandCounters ¶ added in v0.0.3
type InfiniBandCounters struct {
LegacyPortMulticastRcvPackets *uint64 // counters_ext/port_multicast_rcv_packets
LegacyPortMulticastXmitPackets *uint64 // counters_ext/port_multicast_xmit_packets
LegacyPortRcvData64 *uint64 // counters_ext/port_rcv_data_64
LegacyPortRcvPackets64 *uint64 // counters_ext/port_rcv_packets_64
LegacyPortUnicastRcvPackets *uint64 // counters_ext/port_unicast_rcv_packets
LegacyPortUnicastXmitPackets *uint64 // counters_ext/port_unicast_xmit_packets
LegacyPortXmitData64 *uint64 // counters_ext/port_xmit_data_64
LegacyPortXmitPackets64 *uint64 // counters_ext/port_xmit_packets_64
LinkDowned *uint64 // counters/link_downed
LinkErrorRecovery *uint64 // counters/link_error_recovery
MulticastRcvPackets *uint64 // counters/multicast_rcv_packets
MulticastXmitPackets *uint64 // counters/multicast_xmit_packets
PortRcvConstraintErrors *uint64 // counters/port_rcv_constraint_errors
PortRcvData *uint64 // counters/port_rcv_data
PortRcvDiscards *uint64 // counters/port_rcv_discards
PortRcvErrors *uint64 // counters/port_rcv_errors
PortRcvPackets *uint64 // counters/port_rcv_packets
PortXmitConstraintErrors *uint64 // counters/port_xmit_constraint_errors
PortXmitData *uint64 // counters/port_xmit_data
PortXmitDiscards *uint64 // counters/port_xmit_discards
PortXmitPackets *uint64 // counters/port_xmit_packets
PortXmitWait *uint64 // counters/port_xmit_wait
UnicastRcvPackets *uint64 // counters/unicast_rcv_packets
UnicastXmitPackets *uint64 // counters/unicast_xmit_packets
}
InfiniBandCounters contains counter values from files in /sys/class/infiniband/<Name>/ports/<Port>/counters or /sys/class/infiniband/<Name>/ports/<Port>/counters_ext for a single port of one InfiniBand device.
type InfiniBandDevice ¶ added in v0.0.3
type InfiniBandDevice struct {
Name string
BoardID string // /sys/class/infiniband/<Name>/board_id
FirmwareVersion string // /sys/class/infiniband/<Name>/fw_ver
HCAType string // /sys/class/infiniband/<Name>/hca_type
Ports map[uint]InfiniBandPort
}
InfiniBandDevice contains info from files in /sys/class/infiniband for a single InfiniBand device.
type InfiniBandPort ¶ added in v0.0.3
type InfiniBandPort struct {
Name string
Port uint
State string // String representation from /sys/class/infiniband/<Name>/ports/<Port>/state
StateID uint // ID from /sys/class/infiniband/<Name>/ports/<Port>/state
PhysState string // String representation from /sys/class/infiniband/<Name>/ports/<Port>/phys_state
PhysStateID uint // String representation from /sys/class/infiniband/<Name>/ports/<Port>/phys_state
Rate uint64 // in bytes/second from /sys/class/infiniband/<Name>/ports/<Port>/rate
Counters InfiniBandCounters
}
InfiniBandPort contains info from files in /sys/class/infiniband/<Name>/ports/<Port> for a single port of one InfiniBand device.
type NetClass ¶
type NetClass map[string]NetClassIface
NetClass is collection of info for every interface (iface) in /sys/class/net. The map keys are interface (iface) names.
type NetClassIface ¶
type NetClassIface struct {
Name string // Interface name
AddrAssignType *int64 `fileName:"addr_assign_type"` // /sys/class/net/<iface>/addr_assign_type
AddrLen *int64 `fileName:"addr_len"` // /sys/class/net/<iface>/addr_len
Address string `fileName:"address"` // /sys/class/net/<iface>/address
Broadcast string `fileName:"broadcast"` // /sys/class/net/<iface>/broadcast
Carrier *int64 `fileName:"carrier"` // /sys/class/net/<iface>/carrier
CarrierChanges *int64 `fileName:"carrier_changes"` // /sys/class/net/<iface>/carrier_changes
CarrierUpCount *int64 `fileName:"carrier_up_count"` // /sys/class/net/<iface>/carrier_up_count
CarrierDownCount *int64 `fileName:"carrier_down_count"` // /sys/class/net/<iface>/carrier_down_count
DevID *int64 `fileName:"dev_id"` // /sys/class/net/<iface>/dev_id
Dormant *int64 `fileName:"dormant"` // /sys/class/net/<iface>/dormant
Duplex string `fileName:"duplex"` // /sys/class/net/<iface>/duplex
Flags *int64 `fileName:"flags"` // /sys/class/net/<iface>/flags
IfAlias string `fileName:"ifalias"` // /sys/class/net/<iface>/ifalias
IfIndex *int64 `fileName:"ifindex"` // /sys/class/net/<iface>/ifindex
IfLink *int64 `fileName:"iflink"` // /sys/class/net/<iface>/iflink
LinkMode *int64 `fileName:"link_mode"` // /sys/class/net/<iface>/link_mode
MTU *int64 `fileName:"mtu"` // /sys/class/net/<iface>/mtu
NameAssignType *int64 `fileName:"name_assign_type"` // /sys/class/net/<iface>/name_assign_type
NetDevGroup *int64 `fileName:"netdev_group"` // /sys/class/net/<iface>/netdev_group
OperState string `fileName:"operstate"` // /sys/class/net/<iface>/operstate
PhysPortID string `fileName:"phys_port_id"` // /sys/class/net/<iface>/phys_port_id
PhysPortName string `fileName:"phys_port_name"` // /sys/class/net/<iface>/phys_port_name
PhysSwitchID string `fileName:"phys_switch_id"` // /sys/class/net/<iface>/phys_switch_id
Speed *int64 `fileName:"speed"` // /sys/class/net/<iface>/speed
TxQueueLen *int64 `fileName:"tx_queue_len"` // /sys/class/net/<iface>/tx_queue_len
Type *int64 `fileName:"type"` // /sys/class/net/<iface>/type
}
NetClassIface contains info from files in /sys/class/net/<iface> for single interface (iface).
type PowerSupply ¶
type PowerSupply struct {
Name string // Power Supply Name
Authentic *int64 // /sys/class/power_supply/<Name>/authentic
Calibrate *int64 // /sys/class/power_supply/<Name>/calibrate
Capacity *int64 // /sys/class/power_supply/<Name>/capacity
CapacityAlertMax *int64 // /sys/class/power_supply/<Name>/capacity_alert_max
CapacityAlertMin *int64 // /sys/class/power_supply/<Name>/capacity_alert_min
CapacityLevel string // /sys/class/power_supply/<Name>/capacity_level
ChargeAvg *int64 // /sys/class/power_supply/<Name>/charge_avg
ChargeControlLimit *int64 // /sys/class/power_supply/<Name>/charge_control_limit
ChargeControlLimitMax *int64 // /sys/class/power_supply/<Name>/charge_control_limit_max
ChargeCounter *int64 // /sys/class/power_supply/<Name>/charge_counter
ChargeEmpty *int64 // /sys/class/power_supply/<Name>/charge_empty
ChargeEmptyDesign *int64 // /sys/class/power_supply/<Name>/charge_empty_design
ChargeFull *int64 // /sys/class/power_supply/<Name>/charge_full
ChargeFullDesign *int64 // /sys/class/power_supply/<Name>/charge_full_design
ChargeNow *int64 // /sys/class/power_supply/<Name>/charge_now
ChargeTermCurrent *int64 // /sys/class/power_supply/<Name>/charge_term_current
ChargeType string // /sys/class/power_supply/<Name>/charge_type
ConstantChargeCurrent *int64 // /sys/class/power_supply/<Name>/constant_charge_current
ConstantChargeCurrentMax *int64 // /sys/class/power_supply/<Name>/constant_charge_current_max
ConstantChargeVoltage *int64 // /sys/class/power_supply/<Name>/constant_charge_voltage
ConstantChargeVoltageMax *int64 // /sys/class/power_supply/<Name>/constant_charge_voltage_max
CurrentAvg *int64 // /sys/class/power_supply/<Name>/current_avg
CurrentBoot *int64 // /sys/class/power_supply/<Name>/current_boot
CurrentMax *int64 // /sys/class/power_supply/<Name>/current_max
CurrentNow *int64 // /sys/class/power_supply/<Name>/current_now
CycleCount *int64 // /sys/class/power_supply/<Name>/cycle_count
EnergyAvg *int64 // /sys/class/power_supply/<Name>/energy_avg
EnergyEmpty *int64 // /sys/class/power_supply/<Name>/energy_empty
EnergyEmptyDesign *int64 // /sys/class/power_supply/<Name>/energy_empty_design
EnergyFull *int64 // /sys/class/power_supply/<Name>/energy_full
EnergyFullDesign *int64 // /sys/class/power_supply/<Name>/energy_full_design
EnergyNow *int64 // /sys/class/power_supply/<Name>/energy_now
Health string // /sys/class/power_supply/<Name>/health
InputCurrentLimit *int64 // /sys/class/power_supply/<Name>/input_current_limit
Manufacturer string // /sys/class/power_supply/<Name>/manufacturer
ModelName string // /sys/class/power_supply/<Name>/model_name
Online *int64 // /sys/class/power_supply/<Name>/online
PowerAvg *int64 // /sys/class/power_supply/<Name>/power_avg
PowerNow *int64 // /sys/class/power_supply/<Name>/power_now
PrechargeCurrent *int64 // /sys/class/power_supply/<Name>/precharge_current
Present *int64 // /sys/class/power_supply/<Name>/present
Scope string // /sys/class/power_supply/<Name>/scope
SerialNumber string // /sys/class/power_supply/<Name>/serial_number
Status string // /sys/class/power_supply/<Name>/status
Technology string // /sys/class/power_supply/<Name>/technology
Temp *int64 // /sys/class/power_supply/<Name>/temp
TempAlertMax *int64 // /sys/class/power_supply/<Name>/temp_alert_max
TempAlertMin *int64 // /sys/class/power_supply/<Name>/temp_alert_min
TempAmbient *int64 // /sys/class/power_supply/<Name>/temp_ambient
TempAmbientMax *int64 // /sys/class/power_supply/<Name>/temp_ambient_max
TempAmbientMin *int64 // /sys/class/power_supply/<Name>/temp_ambient_min
TempMax *int64 // /sys/class/power_supply/<Name>/temp_max
TempMin *int64 // /sys/class/power_supply/<Name>/temp_min
TimeToEmptyAvg *int64 // /sys/class/power_supply/<Name>/time_to_empty_avg
TimeToEmptyNow *int64 // /sys/class/power_supply/<Name>/time_to_empty_now
TimeToFullAvg *int64 // /sys/class/power_supply/<Name>/time_to_full_avg
TimeToFullNow *int64 // /sys/class/power_supply/<Name>/time_to_full_now
Type string // /sys/class/power_supply/<Name>/type
UsbType string // /sys/class/power_supply/<Name>/usb_type
VoltageAvg *int64 // /sys/class/power_supply/<Name>/voltage_avg
VoltageBoot *int64 // /sys/class/power_supply/<Name>/voltage_boot
VoltageMax *int64 // /sys/class/power_supply/<Name>/voltage_max
VoltageMaxDesign *int64 // /sys/class/power_supply/<Name>/voltage_max_design
VoltageMin *int64 // /sys/class/power_supply/<Name>/voltage_min
VoltageMinDesign *int64 // /sys/class/power_supply/<Name>/voltage_min_design
VoltageNow *int64 // /sys/class/power_supply/<Name>/voltage_now
VoltageOCV *int64 // /sys/class/power_supply/<Name>/voltage_ocv
}
PowerSupply contains info from files in /sys/class/power_supply for a single power supply.
type PowerSupplyClass ¶
type PowerSupplyClass map[string]PowerSupply
PowerSupplyClass is a collection of every power supply in /sys/class/power_supply.
The map keys are the names of the power supplies.
type SystemCPUCpufreqStats ¶
type SystemCPUCpufreqStats struct {
Name string
CpuinfoCurrentFrequency *uint64
CpuinfoMinimumFrequency *uint64
CpuinfoMaximumFrequency *uint64
CpuinfoTransitionLatency *uint64
ScalingCurrentFrequency *uint64
ScalingMinimumFrequency *uint64
ScalingMaximumFrequency *uint64
AvailableGovernors string
Driver string
Governor string
RelatedCpus string
SetSpeed string
}
SystemCPUCpufreqStats contains stats from devices/system/cpu/cpu[0-9]*/cpufreq/...