parent
79c3a90cf0
commit
105b0d2d82
5 changed files with 79 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||||||
|
# You can configure here the sensors |
||||||
|
# Format is <sensors_name>=<command>!<high threshold>!<low 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 |
||||||
|
# Example: |
||||||
|
# |
||||||
|
# |
||||||
|
## Examples with ipmitool |
||||||
|
# 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 |
||||||
|
# |
||||||
|
## 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 |
||||||
|
# |
||||||
|
## Examples with lm_sensors |
||||||
|
# cpu0=/usr/bin/sensors | grep temp1 | cut -d':' -f 2 | awk '{print $1'} | sed -e "s/+//g" -e "s/.C//g"!65!55 |
||||||
|
# |
||||||
|
## Examples with acpi |
||||||
|
# cpu0=cat /proc/acpi/thermal_zone/THRM/temperature | awk '{print $2}'!65!55 |
||||||
|
# |
||||||
|
# |
||||||
|
# !!! WARNING !!! |
||||||
|
# All the commands will be executed with root privileges |
@ -0,0 +1,6 @@ |
|||||||
|
# Sensors discovery |
||||||
|
# See /etc/zabbix/sensors.conf |
||||||
|
UserParameter=hardware.sensor.discovery,/var/lib/zabbix/bin/disco_sensors |
||||||
|
|
||||||
|
# Sensors |
||||||
|
UserParameter=hardware.sensor[*],/usr/bin/sudo /var/lib/zabbix/bin/check_sensors $1 |
@ -0,0 +1,25 @@ |
|||||||
|
#!/usr/bin/perl -w |
||||||
|
|
||||||
|
my $what = $ARGV[0]; |
||||||
|
|
||||||
|
unless (defined $what){ |
||||||
|
print <<"EOF"; |
||||||
|
|
||||||
|
Usage: $0 sensor_name |
||||||
|
|
||||||
|
EOF |
||||||
|
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; |
||||||
|
$ret = `$cmd`; |
||||||
|
} |
||||||
|
print $ret; |
||||||
|
exit(0); |
@ -0,0 +1,21 @@ |
|||||||
|
#!/usr/bin/perl -w |
||||||
|
|
||||||
|
use JSON; |
||||||
|
my $json; |
||||||
|
|
||||||
|
open SENSORS, ('</etc/zabbix/sensors.conf') || |
||||||
|
die "Couldn't open /etc/zabbix/sensors.conf: $!\n"; |
||||||
|
|
||||||
|
|
||||||
|
foreach (<SENSORS>){ |
||||||
|
next unless (/^(\w+)(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/); |
||||||
|
my ($sensor,$threshigh,$threslow) = ($1,$5,$6); |
||||||
|
push @{$json->{data}}, { |
||||||
|
"{#SENSORNAME}" => $sensor, |
||||||
|
"{#SENSORTHRESHIGH}" => $threshigh, |
||||||
|
"{#SENSORTHRESLOW}" => $threslow |
||||||
|
}; |
||||||
|
} |
||||||
|
close SENSORS; |
||||||
|
print to_json($json, { pretty => 1 }); |
||||||
|
exit(0); |
Loading…
Reference in new issue