Reading Sensor Values from the Filesystem

Alveo X3522 User Guide (UG1523)

Document ID
UG1523
Release Date
2023-08-25
Revision
1.4 English

Sensors for Linux devices output their values into the /sys/class/hwmon hierarchy, in a directory named /sys/class/hwmon/hwmon<n>/device.

To determine which of the hwmon<n>/device directories contain sensor data from the X3522 card, search for a driver file within the directory that is a soft link to the xilinx_efct driver:

$ for dir in /sys/class/hwmon/*/device
> do
> readlink $dir/driver | grep -Eq '/xilinx_efct$' && echo $dir
> done
/sys/class/hwmon/hwmon1/device
/sys/class/hwmon/hwmon2/device
/sys/class/hwmon/hwmon3/device
/sys/class/hwmon/hwmon4/device

So in the above example, the four directories /sys/class/hwmon/hwmon1/device to /sys/class/hwmon/hwmon4/device (inclusive) contain sensor data from adapters using the xilinx_efct driver.

Within these directories, each sensor has the following files:

  • <sensor>_label contains a description of the sensor
  • <sensor>_input contains the current value of the sensor, in thousandths of the base unit (°C, V or A)
  • <sensor>_max contains the warning maximum threshold for the sensor, in thousandths of the base unit (°C, V or A)
  • <sensor>_min contains the warning minimum threshold for the sensor, in thousandths of the base unit (°C, V or A)
  • <sensor>_crit contains the critical maximum threshold of the sensor, in thousandths of the base unit (°C, V or A)
  • <sensor>_alarm contains 1 if an alarm condition exists for the sensor, else 0.

Read the <sensor>_label files to determine the files correspond to a given sensor. For example:

$ cd /sys/class/hwmon/hwmon1/device
$ grep -HT . *_label
curr1_label:    12V PCI
curr2_label:    3V3 AUX PCI
curr3_label:    3V3 PCI
curr4_label:    VCCINT OUT
in0_label:      VCC0V85
in10_label:     3V3 PCI
in11_label:     VCCINT OUT
in1_label:      VCC1V8
in2_label:      1V2VCCO
in3_label:      1V2AVTT
in4_label:      0V9AVCC
in5_label:      3V3
in6_label:      3V3 CAGES
in7_label:      5V0
in8_label:      12V PCI
in9_label:      3V3 AUX PCI
temp1_label:    Tdiode (FPGA)
temp2_label:    Ambient (FPGA)
temp3_label:    Ambient (left)
temp4_label:    Ambient (right)
temp5_label:    VCCINT
Note: The sensor names in these files are the same names that are output by the sensors command. See Getting Output for a Specific Device.

Then read the appropriate set of files to get information for a particular sensor. For example, if you wanted to get information about the ambient temperature sensor for the FPGA, the previous output shows that this information is in the temp2_* files, and so:

$ cd /sys/class/hwmon/hwmon1/device
$ grep -HT . temp2_*
temp2_input:    48000
temp2_label:    Ambient (FPGA)
temp2_max:      0
temp2_min:      0

This output shows that the ambient temperature is currently 48°C.