mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-03 12:18:00 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
#!/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";
 |