You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
707 B
44 lines
707 B
#!/usr/bin/perl -w
|
|
|
|
my $what = $ARGV[0];
|
|
my $thres = $ARGV[1];
|
|
|
|
unless (defined $what){
|
|
usage();
|
|
exit(1);
|
|
}
|
|
|
|
open SENSORS, ('</etc/zabbix/sensors.conf') ||
|
|
die "Couldn't open /etc/zabbix/sensors.conf: $!\n";
|
|
|
|
my $ret = 'ZBX_NOTSUPPORTED';
|
|
|
|
foreach (<SENSORS>){
|
|
next unless (/^$what(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/);
|
|
my $cmd = $3;
|
|
my $high = $4;
|
|
my $low = $5;
|
|
if (!defined $thres){
|
|
$ret = `$cmd`;
|
|
}
|
|
elsif ($thres eq 'high'){
|
|
$ret = $high
|
|
}
|
|
elsif ($thres eq 'low'){
|
|
$ret = $low;
|
|
}
|
|
else {
|
|
usage();
|
|
exit(1);
|
|
}
|
|
}
|
|
print $ret;
|
|
exit(0);
|
|
|
|
sub usage {
|
|
print <<"EOF";
|
|
|
|
Usage: $0 sensor_name [high|low]
|
|
|
|
EOF
|
|
}
|
|
|