-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathsensorz.pl
More file actions
executable file
·52 lines (46 loc) · 1.21 KB
/
sensorz.pl
File metadata and controls
executable file
·52 lines (46 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
my @sensor_lines = `sensors`;
my @sensor_devices = [];
my %sensor_readings = ();
my $temp = 0;
my $device = "Unknown";
for my $line (@sensor_lines) {
next if ($line =~ /^\s*$/);
chomp $line;
if ($line =~ /^[^: ]+$/) {
($::device) = $line =~ /^(.*?-[\da-f]+)$/;
if (!(defined $::device)) {
print STDOUT "not a device? [$line]\n";
}
next if ($line !~ /^(k10temp-pci|mt7915_|ath10k_hwmon-pci|physical|coretemp|Core )/);
if ( !defined $::sensor_readings{$::device}) {
$::sensor_readings{$::device} = 0;
push(@::sensor_devices, $::device);
}
next;
}
next if ($line !~ /^(temp|physical|coretemp|Core )/i);
my $t = 0;
if ($line =~ m{.*?:\s+N/A}) {
$t = 0;
}
else {
($t) = $line =~ /.*?:\s+[+](\d+(\.\d+)?)°C/;
}
$::temp = $t if (!defined $::temp || $t > $::temp);
$::sensor_readings{ $::device } = $::temp;
#print "Device[$::device] temp[$::temp]\n";
#$::device = "Unknown";
$::temp = 0;
}
for my $dev (@::sensor_devices) {
print "$dev, ";
}
print "\n";
for my $dev (@::sensor_devices) {
print "$::sensor_readings{$dev}, ";
}
print "\n";