Module: LinuxStat::Thermal

Defined in:
lib/linux_stat/thermal.rb

Overview

Sensors are available to /sys/class/hwmon This module just reads the files inside them to get the sensor information.

www.kernel.org/doc/Documentation/thermal/sysfs-api.txt

Class Method Summary collapse

Class Method Details

.count_fansObject

Counts the number of fans (sensors are not counted)

The return type is an Integer.



59
60
61
62
63
# File 'lib/linux_stat/thermal.rb', line 59

def count_fans
	return 0 unless hwmon_readable?

	Dir["/sys/class/hwmon/hwmon[0-9]*/fan[0-9]*_input".freeze].size
end

.count_sensorsObject

Counts the number of sensors (fans are not counted)

The return type is an Integer.



49
50
51
52
53
# File 'lib/linux_stat/thermal.rb', line 49

def count_sensors
	return 0 unless hwmon_readable?

	Dir["/sys/class/hwmon/hwmon[0-9]*/temp[0-9]*_input".freeze].size
end

.fansObject

Get RPM from all fans.

The return value is an Array of Hashes.

It opens various files from /sys/, and it should be considered very slow.

Each hash may contain information including:

path, name, label rpm, temp_crit, temp_max

But if the info isn’t available, it will return an empty Array.



41
42
43
# File 'lib/linux_stat/thermal.rb', line 41

def fans
	query_hwmon('fan'.freeze, :rpm)
end

.temperaturesObject

Get temperatures from all sensors.

The return value is an Array of Hashes.

It opens various files from /sys/, and it should be considered very slow.

Each hash may contain information including:

path, name, label temperature, temp_crit, temp_max

But if the info isn’t available, it will return an empty Array.



23
24
25
# File 'lib/linux_stat/thermal.rb', line 23

def temperatures
	query_hwmon('temp'.freeze, :temperature, true)
end