Support different sensors types
This commit is contained in:
parent
0a99008074
commit
da771ec287
|
@ -1,7 +1,9 @@
|
||||||
# You can configure here the sensors
|
# 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
|
# 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 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:
|
# 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
|
# 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
|
# 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
|
## Examples with smartctl
|
||||||
# sda = /usr/sbin/smartctl -a /dev/sda | grep Temperature_Celsius | awk '{print $10}'!45!40
|
# 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
|
# sdb = /usr/sbin/smartctl -a /dev/sdb | grep Temperature_Celsius | awk '{print $10}'!45!50
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Sensors discovery
|
# Sensors discovery
|
||||||
# See /etc/zabbix/sensors.conf
|
# 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
|
# Sensors
|
||||||
UserParameter=hardware.sensor[*],/usr/bin/sudo /var/lib/zabbix/bin/check_sensors_sudo $1 $2
|
UserParameter=hardware.sensor[*],/usr/bin/sudo /var/lib/zabbix/bin/check_sensors_sudo $1 $2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
my $what = $ARGV[0];
|
my $what = $ARGV[0];
|
||||||
my $thres = $ARGV[1];
|
|
||||||
|
|
||||||
unless (defined $what){
|
unless (defined $what){
|
||||||
usage();
|
usage();
|
||||||
|
@ -14,23 +13,9 @@ open SENSORS, ('</etc/zabbix/sensors.conf') ||
|
||||||
my $ret = 'ZBX_NOTSUPPORTED';
|
my $ret = 'ZBX_NOTSUPPORTED';
|
||||||
|
|
||||||
foreach (<SENSORS>){
|
foreach (<SENSORS>){
|
||||||
next unless (/^$what(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/);
|
next unless (/^$what(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)(!(\w+))?$/);
|
||||||
my $cmd = $3;
|
my $cmd = $3;
|
||||||
my $high = $4;
|
$ret = `$cmd`;
|
||||||
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;
|
print $ret;
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
use JSON;
|
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;
|
my $json;
|
||||||
@{$json->{data}} = ();
|
@{$json->{data}} = ();
|
||||||
|
|
||||||
|
@ -9,14 +19,18 @@ open SENSORS, ('</etc/zabbix/sensors.conf') ||
|
||||||
|
|
||||||
|
|
||||||
foreach (<SENSORS>){
|
foreach (<SENSORS>){
|
||||||
next unless (/^(\w+)(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/);
|
next unless (/^(\w+)(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)(!(\w+))?$/);
|
||||||
my ($sensor,$threshigh,$threslow) = ($1,$5,$6);
|
my ($sensor,$threshigh,$threslow,$type) = ($1,$5,$6,$8);
|
||||||
|
$type ||= 'temp';
|
||||||
|
next if ($sensor_type ne 'all' && $type ne $sensor_type);
|
||||||
push @{$json->{data}}, {
|
push @{$json->{data}}, {
|
||||||
"{#SENSORNAME}" => $sensor,
|
"{#SENSORNAME}" => $sensor,
|
||||||
"{#SENSORTHRESHIGH}" => $threshigh,
|
"{#SENSORTHRESHIGH}" => $threshigh,
|
||||||
"{#SENSORTHRESLOW}" => $threslow
|
"{#SENSORTHRESLOW}" => $threslow,
|
||||||
|
"{#SENSORTYPE}" => $type
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
close SENSORS;
|
close SENSORS;
|
||||||
print to_json($json);
|
print to_json($json);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue