#!/usr/bin/perl -w

use strict;
use warnings;
use Config::Simple;

my $what = $ARGV[0];

unless (defined $what){
  usage();
  exit(1);
}

my $cfg = new Config::Simple;
$cfg->read('/etc/zabbix/sensors.ini');

my $ret = 'ZBX_NOTSUPPORTED';
my $sensor = $cfg->get_block($what);
if ($sensor && $sensor->{cmd}){
  $ret = qx($sensor->{cmd});
}

print $ret;
exit(0);

sub usage {
    print <<"EOF";

Usage: $0 sensor_name

EOF
}