Project

General

Profile

Zabbix Agent Config

Userparameter

Preliminary Note

Basically there is 2 ways to go the road. As the Agentd is run with the zabbix user
  • you will have to give zabbix sudo-rights for the programs needed
  • prepare via cron-jobs data for extraction which are accessible by the zabbix-user
    Both solutions have their shortcomings:
  • SUDO-Version
    • giving sudo-rights to zabbix might be considered a security risk
    • flooding logs with sudo-messages
    • you have to remove requiretty to make sudo work with zabbix
  • CRON-Version
    • if you cron-job doesn't deliver data, zabbix will reread old data over and over
    • the setup is more complex and not straight forward when it comes to debugging

Sample UserParameter-List

#UserParameter=ipmi.temp.ambient,sudo ipmitool sdr type "Temperature" |grep Ambient |sed -e 's/.* | \([0-9]\+\).*/\1/'
#UserParameter=ipmi.fan.1,sudo ipmitool sdr | grep FAN1 |sed -e 's/.* | \([0-9]\+\).*/\1/'
#UserParameter=ipmi.fan.2,sudo ipmitool sdr | grep FAN2 |sed -e 's/.* | \([0-9]\+\).*/\1/'
#UserParameter=ipmi.fan.3,sudo ipmitool sdr | grep FAN3 |sed -e 's/.* | \([0-9]\+\).*/\1/'
#UserParameter=ipmi.fan.4,sudo ipmitool sdr | grep FAN4 |sed -e 's/.* | \([0-9]\+\).*/\1/'
UserParameter=system.smartd[*],cat /var/cache/myzabbix/smart.$1.status| grep $2| tail -1| cut -c 88-|cut -f1 -d' '
UserParameter=system.smartd.value[*],cat /var/cache/myzabbix/smart.$1.status| grep $2| tail -1| cut -c 38-|cut -f1 -d' '
UserParameter=system.smartd.worst[*],cat /var/cache/myzabbix/smart.$1.status| grep $2| tail -1| cut -c 44-|cut -f1 -d' '
UserParameter=system.smartd.thres[*],cat /var/cache/myzabbix/smart.$1.status| grep $2| tail -1| cut -c 50-|cut -f1 -d' '
#UserParameter=system.apcups[*],cat /var/cache/myzabbix/apcups.status| grep $1| tail -1|cut -c 12-|sed 's/^[ ]*//'|cut -f1 -d' '

Sudo-Version

visudo

...
#
# Disable "ssh hostname sudo <cmd>", because it will show the password in clear. 
#         You have to run "ssh -t hostname sudo <cmd>".
#
#JKE 2012-09-20 commented out to make zabbix-sudo work
#Defaults    requiretty
...

...
## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

visudo -f /etc/sudoers.d/zabbix

zabbix ALL = (ALL) NOPASSWD:/usr/bin/ipmitool
zabbix ALL = (ALL) NOPASSWD:/usr/sbin/smartctl

Cron-Version

create zabbix-data exchange-directory

mkdir /var/cache/myzabbix

create zabbix-data-file
vim /usr/local/bin/smart_status.sh

/usr/sbin/smartctl -A /dev/sda > /var/cache/myzabbix/smart.sda.status
/usr/sbin/smartctl -A /dev/sdb > /var/cache/myzabbix/smart.sdb.status

/usr/sbin/smartctl -d sat+megaraid,10 -a /dev/sda > /var/cache/myzabbix/smart.sda.0.status
/usr/sbin/smartctl -d sat+megaraid,11 -a /dev/sda > /var/cache/myzabbix/smart.sda.1.status
/usr/sbin/smartctl -d sat+megaraid,12 -a /dev/sdb > /var/cache/myzabbix/smart.sdb.0.status
/usr/sbin/smartctl -d sat+megaraid,13 -a /dev/sdc > /var/cache/myzabbix/smart.sdc.0.status
/usr/sbin/smartctl -d sat+megaraid,14 -a /dev/sdc > /var/cache/myzabbix/smart.sdc.1.status

vim /usr/local/bin/apcups_status.sh

/etc/init.d/apcupsd status > /var/cache/myzabbix/apcups.status

create cron-job
vim /etc/cron.d/zabbix

# JKE 2012-10-19
#
# minute hour day month dayofweek
# m h d m d
# - - - - -
# | | | | |
# | | | | +-day of week (0-7) sunday=0 or 7
# | | | +---month (1-12)
# | | +-----day of month (1-31)
# | +-------hour (0-23)
# +---------min (0-59)
# 
#    */2    *    *    *    *    root    /usr/local/bin/apcups_status.sh
    */5    *    *    *    *    root    /usr/local/bin/smart_status.sh
    5    1    *    *    *    root    /usr/local/bin/zabbix-mysql-backupconf.sh