Add sensors checks, discovery and conf

tags/zabbix-agent-addons-0.2.20-1
Daniel Berteaud 12 years ago
parent 79c3a90cf0
commit 105b0d2d82
  1. 24
      conf/sensors.conf
  2. 3
      zabbix-agent-addons.spec
  3. 6
      zabbix_conf/sensors.conf
  4. 25
      zabbix_scripts/check_sensors_sudo
  5. 21
      zabbix_scripts/disco_sensors

@ -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

@ -39,6 +39,8 @@ LVM, RAID status, S.M.A.R.T. drives, BackupPC etc...
# Install Zabbix conf
%{__install} -d $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_agentd.conf.d/
%{__install} -m 0755 zabbix_conf/* $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_agentd.conf.d/
# Install sensors conf
%{__install} -m 0755 conf/sensors.conf $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/
# Install sudo conf
%{__install} -d 750 $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d
%{__install} -m 600 conf/sudo.conf $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d/zabbix_agent
@ -57,6 +59,7 @@ LVM, RAID status, S.M.A.R.T. drives, BackupPC etc...
%doc README CHANGELOG.git
%dir %attr(0750,zabbix,zabbix) %{_localstatedir}/lib/zabbix/bin
%{_localstatedir}/lib/zabbix/bin/*
%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/zabbix/sensors.conf
%{_sysconfdir}/zabbix/zabbix_agentd.conf.d/*
%{_sysconfdir}/sudoers.d/*

@ -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…
Cancel
Save