#!/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;
