Documentation
¶
Overview ¶
Package sysfs provides functions to retrieve system and kernel metrics from the pseudo-filesystem sys.
Index ¶
- Constants
- type CPU
- type CPUThermalThrottle
- type CPUTopology
- type ClassCoolingDeviceStats
- type ClassThermalZoneStats
- type ClockSource
- type FS
- func (fs FS) CPUVulnerabilities() ([]Vulnerability, error)
- func (fs FS) CPUs() ([]CPU, error)
- func (fs FS) ClassCoolingDeviceStats() ([]ClassCoolingDeviceStats, error)
- func (fs FS) ClassThermalZoneStats() ([]ClassThermalZoneStats, error)
- func (fs FS) ClockSources() ([]ClockSource, error)
- func (fs FS) FibreChannelClass() (FibreChannelClass, 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)
- func (fs FS) VMStatNUMA() (map[int]VMStat, error)
- type FibreChannelClass
- type FibreChannelCounters
- type FibreChannelHost
- type InfiniBandClass
- type InfiniBandCounters
- type InfiniBandDevice
- type InfiniBandPort
- type NetClass
- type NetClassIface
- type PowerSupply
- type PowerSupplyClass
- type RaplZone
- type SystemCPUCpufreqStats
- type VMStat
- type Vulnerability
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 CPU ¶ added in v0.0.5
type CPU string
CPU represents a path to a CPU located in /sys/devices/system/cpu/cpu[0-9]*
func (CPU) ThermalThrottle ¶ added in v0.0.5
func (c CPU) ThermalThrottle() (*CPUThermalThrottle, error)
ThermalThrottle gets the cpu throttle count information for a single CPU from /sys/devices/system/cpu/cpuN/thermal_throttle
func (CPU) Topology ¶ added in v0.0.5
func (c CPU) Topology() (*CPUTopology, error)
Topology gets the topology information for a single CPU from /sys/devices/system/cpu/cpuN/topology
type CPUThermalThrottle ¶ added in v0.0.5
CPUThermalThrottle contains data from /sys/devices/system/cpu/cpu[0-9]*/thermal_throttle
type CPUTopology ¶ added in v0.0.5
type CPUTopology struct { CoreID string CoreSiblingsList string PhysicalPackageID string ThreadSiblingsList string }
CPUTopology contains data located in /sys/devices/system/cpu/cpu[0-9]*/topology
type ClassCoolingDeviceStats ¶ added in v0.0.4
type ClassCoolingDeviceStats struct { Name string // The name of the cooling device. Type string // Type of the cooling device(processor/fan/...) MaxState int64 // Maximum cooling state of the cooling device CurState int64 // Current cooling state of the cooling device }
ClassCoolingDeviceStats contains info from files in /sys/class/thermal/cooling_device[0-9]* for a single device. https://www.kernel.org/doc/Documentation/thermal/sysfs-api.txt
type ClassThermalZoneStats ¶
type ClassThermalZoneStats struct { Name string // The name of the zone from the directory structure. Type string // The type of thermal zone. Temp int64 // 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 ¶
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
NewDefaultFS returns a new FS mounted under the default mountPoint. It will error if the mount point can't be read.
func NewFS ¶
NewFS returns a new FS mounted under the given mountPoint. It will error if the mount point can't be read.
func (FS) CPUVulnerabilities ¶ added in v0.0.4
func (fs FS) CPUVulnerabilities() ([]Vulnerability, error)
CPUVulnerabilities retrieves a map of vulnerability names to their mitigations.
func (FS) ClassCoolingDeviceStats ¶ added in v0.0.4
func (fs FS) ClassCoolingDeviceStats() ([]ClassCoolingDeviceStats, error)
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) FibreChannelClass ¶ added in v0.1.0
func (fs FS) FibreChannelClass() (FibreChannelClass, error)
FibreChannelClass parses everything in /sys/class/fc_host.
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
NetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
func (FS) NetClassDevices ¶
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 FibreChannelClass ¶ added in v0.1.0
type FibreChannelClass map[string]FibreChannelHost
type FibreChannelCounters ¶ added in v0.1.0
type FibreChannelCounters struct { DumpedFrames uint64 // /sys/class/fc_host/<Name>/statistics/dumped_frames ErrorFrames uint64 // /sys/class/fc_host/<Name>/statistics/error_frames InvalidCRCCount uint64 // /sys/class/fc_host/<Name>/statistics/invalid_crc_count RXFrames uint64 // /sys/class/fc_host/<Name>/statistics/rx_frames RXWords uint64 // /sys/class/fc_host/<Name>/statistics/rx_words TXFrames uint64 // /sys/class/fc_host/<Name>/statistics/tx_frames TXWords uint64 // /sys/class/fc_host/<Name>/statistics/tx_words SecondsSinceLastReset uint64 // /sys/class/fc_host/<Name>/statistics/seconds_since_last_reset InvalidTXWordCount uint64 // /sys/class/fc_host/<Name>/statistics/invalid_tx_word_count LinkFailureCount uint64 // /sys/class/fc_host/<Name>/statistics/link_failure_count LossOfSyncCount uint64 // /sys/class/fc_host/<Name>/statistics/loss_of_sync_count LossOfSignalCount uint64 // /sys/class/fc_host/<Name>/statistics/loss_of_signal_count NosCount uint64 // /sys/class/fc_host/<Name>/statistics/nos_count FCPPacketAborts uint64 // / sys/class/fc_host/<Name>/statistics/fcp_packet_aborts }
type FibreChannelHost ¶ added in v0.1.0
type FibreChannelHost struct { Name string // /sys/class/fc_host/<Name> Speed string // /sys/class/fc_host/<Name>/speed PortState string // /sys/class/fc_host/<Name>/port_state PortType string // /sys/class/fc_host/<Name>/port_type SymbolicName string // /sys/class/fc_host/<Name>/symbolic_name NodeName string // /sys/class/fc_host/<Name>/node_name PortID string // /sys/class/fc_host/<Name>/port_id PortName string // /sys/class/fc_host/<Name>/port_name FabricName string // /sys/class/fc_host/<Name>/fabric_name DevLossTMO string // /sys/class/fc_host/<Name>/dev_loss_tmo SupportedClasses string // /sys/class/fc_host/<Name>/supported_classes SupportedSpeeds string // /sys/class/fc_host/<Name>/supported_speeds Counters FibreChannelCounters // /sys/class/fc_host/<Name>/statistics/* }
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 PortRcvRemotePhysicalErrors *uint64 // counters/port_rcv_remote_physical_errors PortRcvSwitchRelayErrors *uint64 // counters/port_rcv_switch_relay_errors 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 SymbolError *uint64 // counters/symbol_error UnicastRcvPackets *uint64 // counters/unicast_rcv_packets UnicastXmitPackets *uint64 // counters/unicast_xmit_packets VL15Dropped *uint64 // counters/VL15_dropped }
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 // /sys/class/net/<iface>/addr_assign_type AddrLen *int64 // /sys/class/net/<iface>/addr_len Address string // /sys/class/net/<iface>/address Broadcast string // /sys/class/net/<iface>/broadcast Carrier *int64 // /sys/class/net/<iface>/carrier CarrierChanges *int64 // /sys/class/net/<iface>/carrier_changes CarrierUpCount *int64 // /sys/class/net/<iface>/carrier_up_count CarrierDownCount *int64 // /sys/class/net/<iface>/carrier_down_count DevID *int64 // /sys/class/net/<iface>/dev_id Dormant *int64 // /sys/class/net/<iface>/dormant Duplex string // /sys/class/net/<iface>/duplex Flags *int64 // /sys/class/net/<iface>/flags IfAlias string // /sys/class/net/<iface>/ifalias IfIndex *int64 // /sys/class/net/<iface>/ifindex IfLink *int64 // /sys/class/net/<iface>/iflink LinkMode *int64 // /sys/class/net/<iface>/link_mode MTU *int64 // /sys/class/net/<iface>/mtu NameAssignType *int64 // /sys/class/net/<iface>/name_assign_type NetDevGroup *int64 // /sys/class/net/<iface>/netdev_group OperState string // /sys/class/net/<iface>/operstate PhysPortID string // /sys/class/net/<iface>/phys_port_id PhysPortName string // /sys/class/net/<iface>/phys_port_name PhysSwitchID string // /sys/class/net/<iface>/phys_switch_id Speed *int64 // /sys/class/net/<iface>/speed TxQueueLen *int64 // /sys/class/net/<iface>/tx_queue_len Type *int64 // /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 RaplZone ¶ added in v0.0.6
type RaplZone struct { Name string // name of RAPL zone from file "name" Index int // index (different value for duplicate names) Path string // filesystem path of RaplZone MaxMicrojoules uint64 // max RAPL microjoule value }
RaplZone stores the information for one RAPL power zone
func GetRaplZones ¶ added in v0.0.6
GetRaplZones returns a slice of RaplZones When RAPL files are not present, returns nil with error https://www.kernel.org/doc/Documentation/power/powercap/powercap.txt
func (RaplZone) GetEnergyMicrojoules ¶ added in v0.0.6
GetEnergyMicrojoules returns the current microjoule value from the zone energy counter https://www.kernel.org/doc/Documentation/power/powercap/powercap.txt
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/...
type VMStat ¶ added in v0.3.0
type VMStat struct { NrFreePages uint64 NrZoneInactiveAnon uint64 NrZoneActiveAnon uint64 NrZoneInactiveFile uint64 NrZoneActiveFile uint64 NrZoneUnevictable uint64 NrZoneWritePending uint64 NrMlock uint64 NrPageTablePages uint64 NrKernelStack uint64 NrBounce uint64 NrZspages uint64 NrFreeCma uint64 NumaHit uint64 NumaMiss uint64 NumaForeign uint64 NumaInterleave uint64 NumaLocal uint64 NumaOther uint64 NrInactiveAnon uint64 NrActiveAnon uint64 NrInactiveFile uint64 NrActiveFile uint64 NrUnevictable uint64 NrSlabReclaimable uint64 NrSlabUnreclaimable uint64 NrIsolatedAnon uint64 NrIsolatedFile uint64 WorkingsetNodes uint64 WorkingsetRefault uint64 WorkingsetActivate uint64 WorkingsetRestore uint64 WorkingsetNodereclaim uint64 NrAnonPages uint64 NrMapped uint64 NrFilePages uint64 NrDirty uint64 NrWriteback uint64 NrWritebackTemp uint64 NrShmem uint64 NrShmemHugepages uint64 NrShmemPmdmapped uint64 NrFileHugepages uint64 NrFilePmdmapped uint64 NrAnonTransparentHugepages uint64 NrVmscanWrite uint64 NrVmscanImmediateReclaim uint64 NrDirtied uint64 NrWritten uint64 NrKernelMiscReclaimable uint64 NrFollPinAcquired uint64 NrFollPinReleased uint64 }
type Vulnerability ¶ added in v0.0.4
Vulnerability represents a single vulnerability extracted from /sys/devices/system/cpu/vulnerabilities/