mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-10-30 18:27:53 +00:00
More scripts from tools dir.
This commit is contained in:
49
sensorz.pl
Executable file
49
sensorz.pl
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/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 =~ /^(.*?-\d+)$/;
|
||||
next if ($line !~ /^(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)/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";
|
||||
Reference in New Issue
Block a user