@@ -237,13 +237,50 @@ public function getDiskInfo(): array {
237237
238238 #[\Override]
239239 public function getThermalZones (): array {
240+ return array_merge ($ this ->readHwmonSensors (), $ this ->readThermalZoneSensors ());
241+ }
242+
243+ /**
244+ * Read temperatures from the hwmon sensor interface (/sys/class/hwmon).
245+ *
246+ * @return ThermalZone[]
247+ */
248+ protected function readHwmonSensors (): array {
240249 $ data = [];
241250
242- $ zones = glob ('/sys/class/thermal/thermal_zone* ' );
243- if ($ zones === false ) {
244- return $ data ;
251+ $ drivers = glob ('/sys/class/hwmon/hwmon* ' ) ?: [];
252+ foreach ($ drivers as $ driver ) {
253+ try {
254+ $ name = $ this ->readContent ($ driver . '/name ' );
255+ } catch (RuntimeException ) {
256+ // driver without a name, skip it
257+ continue ;
258+ }
259+
260+ $ zones = glob ($ driver . '/temp*_label ' ) ?: [];
261+ foreach ($ zones as $ zone ) {
262+ try {
263+ $ type = $ name . ' ' . $ this ->readContent ($ zone );
264+ $ temp = (float )((int )$ this ->readContent (str_replace ('_label ' , '_input ' , $ zone )) / 1000 );
265+ $ data [] = new ThermalZone (md5 ($ zone ), $ type , $ temp );
266+ } catch (RuntimeException ) {
267+ // unable to read sensor
268+ }
269+ }
245270 }
246271
272+ return $ data ;
273+ }
274+
275+ /**
276+ * Read temperatures from the thermal zone interface (/sys/class/thermal).
277+ *
278+ * @return ThermalZone[]
279+ */
280+ protected function readThermalZoneSensors (): array {
281+ $ data = [];
282+
283+ $ zones = glob ('/sys/class/thermal/thermal_zone* ' ) ?: [];
247284 foreach ($ zones as $ zone ) {
248285 try {
249286 $ type = $ this ->readContent ($ zone . '/type ' );
0 commit comments