Support different sensors types

tags/zabbix-agent-addons-0.2.20-1 0.1.27_el5
Daniel Berteaud 9 years ago
parent 0a99008074
commit da771ec287
  1. 7
      conf/sensors.conf
  2. 2
      zabbix_conf/sensors.conf
  3. 19
      zabbix_scripts/check_sensors_sudo
  4. 22
      zabbix_scripts/disco_sensors

@ -1,7 +1,9 @@
# You can configure here the sensors
# Format is <sensors_name>=<command>!<high threshold>!<low threshold>
# Format is <sensors_name>=<command>!<high threshold>!<low threshold>!<sensor type>
# An alert is triggerd if the temperature is above the high threshold
# The alert is cleared if the temperature is less than low threshold
# the last field (sensor type) is optional and defaults to temp
# It's used if you want to monitor other sensors, like fan, or power
# Example:
#
#
@ -9,6 +11,9 @@
# cpu0 = /usr/bin/ipmitool sdr get 'P1 Therm Margin' | grep 'Sensor Reading' | cut -d':' -f 2 | awk '{print$1}'!-30!-39
# mb = /usr/bin/ipmitool sdr get 'Baseboard Temp' | grep 'Sensor Reading' | cut -d':' -f 2 | awk '{print$1}'!50!45
#
# fan1 = fan1a=/usr/bin/ipmitool sdr get 'Fan1A RPM' | grep 'Sensor Reading' | cut -d':' -f 2 | awk '{print$1}'!0!0!fan
# pwr1=/usr/bin/ipmitool sdr get 'Pwr Consumption' | grep 'Sensor Reading' | cut -d':' -f 2 | awk '{print$1}'!0!0!power
#
## Examples with smartctl
# sda = /usr/sbin/smartctl -a /dev/sda | grep Temperature_Celsius | awk '{print $10}'!45!40
# sdb = /usr/sbin/smartctl -a /dev/sdb | grep Temperature_Celsius | awk '{print $10}'!45!50

@ -1,6 +1,6 @@
# Sensors discovery
# See /etc/zabbix/sensors.conf
UserParameter=hardware.sensor.discovery,/var/lib/zabbix/bin/disco_sensors
UserParameter=hardware.sensor.discovery[*],/var/lib/zabbix/bin/disco_sensors --type=$1
# Sensors
UserParameter=hardware.sensor[*],/usr/bin/sudo /var/lib/zabbix/bin/check_sensors_sudo $1 $2

@ -1,7 +1,6 @@
#!/usr/bin/perl -w
my $what = $ARGV[0];
my $thres = $ARGV[1];
unless (defined $what){
usage();
@ -14,23 +13,9 @@ open SENSORS, ('</etc/zabbix/sensors.conf') ||
my $ret = 'ZBX_NOTSUPPORTED';
foreach (<SENSORS>){
next unless (/^$what(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/);
next unless (/^$what(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)(!(\w+))?$/);
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);
}
$ret = `$cmd`;
}
print $ret;
exit(0);

@ -1,6 +1,16 @@
#!/usr/bin/perl -w
use JSON;
use Getopt::Long;
my $sensor_type = 'temp';
GetOptions(
"type:s" => \$sensor_type
);
# empty means temp
$sensor_type = ($sensor_type eq '') ? 'temp' : $sensor_type;
my $json;
@{$json->{data}} = ();
@ -9,14 +19,18 @@ open SENSORS, ('</etc/zabbix/sensors.conf') ||
foreach (<SENSORS>){
next unless (/^(\w+)(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/);
my ($sensor,$threshigh,$threslow) = ($1,$5,$6);
next unless (/^(\w+)(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)(!(\w+))?$/);
my ($sensor,$threshigh,$threslow,$type) = ($1,$5,$6,$8);
$type ||= 'temp';
next if ($sensor_type ne 'all' && $type ne $sensor_type);
push @{$json->{data}}, {
"{#SENSORNAME}" => $sensor,
"{#SENSORNAME}" => $sensor,
"{#SENSORTHRESHIGH}" => $threshigh,
"{#SENSORTHRESLOW}" => $threslow
"{#SENSORTHRESLOW}" => $threslow,
"{#SENSORTYPE}" => $type
};
}
close SENSORS;
print to_json($json);
exit(0);

Loading…
Cancel
Save