#!/usr/bin/perl
#
$machine="example.zive.net";                # ホスト名
$sensors=`/usr/bin/sensors`;               # sensorsコマンド
@sensor = split(/\n/, $sensors);
$err = 0;

if ($ARGV[0] eq '') {
    $err = 1;
}else{
    $sen0 = $ARGV[0];
}
if ($ARGV[1] ne '') {
    $sen1 = $ARGV[1];
}else{
    $sen1 = $ARGV[0];
}
if (!$err){
    foreach $data (@sensor){
        if($data =~ /$sen0:\ +([+\-0-9]*)/){
            $sensor0 = $1;
        }elsif($data =~ /$sen1:\ +([+\-0-9]*)/){
            $sensor1 = $1;
        }
    }

    $utime = `uptime`;
    $utime =~ /up(.*?),/;
    $uptime = $1;
    $uptime =~ s/^\s*//g;

    print "$sensor0\n";
    print "$sensor1\n";
    # Print uptime
    print "$uptime\n";
    # Print machine name for mrtg
    print "$machine\n";
}
exit $err;