File: lmsensors.pl

package info (click to toggle)
netmrg 0.20-7
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,896 kB
  • ctags: 2,012
  • sloc: php: 9,401; sh: 4,791; cpp: 2,898; perl: 621; ansic: 381; makefile: 337; xml: 92; sql: 71; sed: 16
file content (28 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl
use strict;

### argument processing
my $sensor=$ARGV[0];
my $hwmon=$ARGV[1] || "hwmon0";
if (@ARGV < 1 or @ARGV > 2 or $sensor !~ /^\w+$/ or $hwmon !~ /^\w+$/)
{
	print "U\n";
	print "\n";
	print "$0 <sensor> [monitor]\n";
	print "\n";
	print "Reports sensor gauges for use as a NetMRG test script.\n";
	print "\n";
	print "Options:\n";
	print "  sensor  Is the sensor value to report\n";
	print "  monitor The hardware monitor the sensor is attached to, 'hwmon0' by default\n";
	print "\n";
	exit 1;
}


# read the data from the correct path
my $path = "/sys/class/hwmon/$hwmon/device/${sensor}_input";
open(STAT, $path) || die ("U\nERROR: couldn't open $path\n\n");
my $value = <STAT>;
close(STAT);
print $value;