Zabbix UserParameters

Linux

Parameters

UserParameter=mysql.ping,sudo mysqladmin ${MYSQLAUTH} ping|grep alive|wc -l
UserParameter=mysql.uptime,sudo mysqladmin ${MYSQLAUTH} status|cut -f2 -d':'|cut -f1 -d'T'
UserParameter=mysql.threads,sudo mysqladmin ${MYSQLAUTH} status|cut -f3 -d':'|cut -f1 -d'Q'
UserParameter=mysql.threadsp,echo "scale=4; $(sudo mysqladmin ${MYSQLAUTH} status|cut -f3 -d':'|cut -f1 -d'Q')/ $(sudo mysql ${MYSQLAUTH} --batch -r -s -e "show variables like 'max_connections';" | cut -f2) * 100" | bc
UserParameter=mysql.questions,sudo mysqladmin ${MYSQLAUTH} status|cut -f4 -d':'|cut -f1 -d'S'
UserParameter=mysql.slowqueries,sudo mysqladmin ${MYSQLAUTH} status|cut -f5 -d':'|cut -f1 -d'O'
UserParameter=mysql.qps,sudo mysqladmin ${MYSQLAUTH} status|cut -f9 -d':'
UserParameter=mysql.slaverunning,sudo mysql ${MYSQLAUTH} -e 'show slave status \G' | egrep 'Slave_IO_Running|Slave_SQL_Running' | awk '{print $2}' | xargs
UserParameter=mysql.slaverunning.numeric,sudo mysql ${MYSQLAUTH} -e 'show slave status \G' | egrep 'Slave_IO_Running|Slave_SQL_Running' | awk '{print $2}' | xargs | grep -q "No"; echo $?
UserParameter=mysql.secondsbehindmaster,sudo mysql ${MYSQLAUTH} -e 'show slave status \G' | egrep 'Seconds_Behind_Master' | awk '{print $2}'
UserParameter=mysql.ifslave,([ "x$(sudo mysql ${MYSQLAUTH} -e 'show slave status \G;' | egrep 'Slave_IO_State' | awk '{print $2}')" = "x" ] && echo "0") || echo "1"
UserParameter=mysql.version,sudo mysql -V
UserParameter=qmail.queue,sudo /var/qmail/bin/qmail-qstat | grep 'messages in queue:' | awk '{print $4}'
UserParameter=exim.queue,if [ -n "$(which exim4)" ]; then sudo exim4 -bpc; else sudo exim -bpc; fi
UserParameter=raid.3ware,for i in $(sudo /usr/sbin/tw_cli info | awk '{print $1}' | grep "^c"); do sudo /usr/sbin/tw_cli info $i | grep "^u" | awk '{print $3}' | xargs; done
UserParameter=raid.areca,/usr/local/bin/areca_cli rsf info | awk '{print $10}' | grep -v "^$" | grep -v State
UserParameter=raid.lsimpt,/bin/bash -c 'CL="0"; CT=0; for ((i=0;i<=128;i++)); do if [ -z "$(sudo mpt-status -i $i -s 2>&1 | egrep "no SCSI disks attached|mptctl")" ]; then let CT=$CT+$(sudo mpt-status -i $i -s | egrep -v "(OPTIMAL|ONLINE)" | wc -l); CL="1"; fi; done; ([ "${CL}" -eq "0" ] && echo 1) || echo ${CT}'
UserParameter=raid.lsimegaraid,if [ "$(sudo megacli -ldinfo -lall -aall | wc -l)" -le "1" ]; then echo 1; else sudo megacli -ldinfo -lall -aall | grep State | grep -v Optimal | wc -l; fi
UserParameter=raid.software,sed -ne 's/^.*blocks.*\(\[.\+\]\)$/\1/gp' /proc/mdstat
UserParameter=raid.vortex,cat /proc/scsi/gdth/* | grep Status | sed -e 's/^.*:\W*//g' | xargs
UserParameter=fs.writecheck,(sudo touch /etc/passwd /var/log/messages && echo "1") || echo "0"
UserParameter=nfs.filelocking,sudo /etc/zabbix/flockmonitor.sh 2>/dev/null
UserParameter=vz.ubc,failcnt=0 && for i in $(sudo cat /proc/user_beancounters | egrep -v "Version|failcnt" | sed -e 's/.* \(.*\)/\1/g' | grep -v '^$'); do let failcnt=$failcnt+$i; done; echo $failcnt
UserParameter=system.ethspeed[*],ZBX_ETHSPEED=$(sudo ethtool $1 | grep "Speed:" | awk '{print $$2}' | cut -d'M' -f1); if [ "${ZBX_ETHSPEED}" = 'Unknown!' ]; then ZBX_ETHSPEED=0; fi; echo ${ZBX_ETHSPEED}
UserParameter=system.ethlink[*],if [ "$(sudo ethtool $1 | grep "Link detected:" | awk {'print $$3'})" = "yes" ]; then echo "1"; else echo "0"; 
UserParameter=vz.licence,sudo /etc/zabbix/zabbix_check_virtuozzo_licence.sh expire
UserParameter=vz.freeves,sudo /etc/zabbix/zabbix_check_virtuozzo_licence.sh ve_free
UserParameter=landscape.kvm,ps x | grep "kvm.*landscape" | grep -v grep | wc -l
UserParameter=routing.extern,ping -q -n -l 3 -c 3 $(ip r l | grep default | awk '{print $3}') &>/dev/null; echo $?

/etc/sudoers

Defaults:zabbix !requiretty
zabbix ALL=NOPASSWD:/usr/bin/mailq,/usr/local/bin/mpt-status,/usr/sbin/mpt-status,/usr/sbin/tw_cli,/usr/bin/mysql,/usr/bin/mysqladmin,/bin/cat,/var/qmail/bin/qmail-qstat,/usr/bin/megacli,/usr/sbin/exim,/usr/sbin/exim4,/bin/touch,/usr/local/sbin/arcconf,/usr/local/bin/areca_cli,/sbin/ethtool,/usr/sbin/ethtool

Scripts

zabbix_check_virtuozzo_licence.sh
#!/bin/bash
 
case "$1" in
        expire)
                a=`/usr/sbin/vzlicview | grep expiration | tail -n1 | cut -d"\"" -f2`
                if [ "${a}" != "unlimited" ]; then
                        if [ "$((($(date -d "${a}" +"%s")-$(date +"%s"))/60/60/24))" -le "7" ]; then
                                echo "1"
                        else
                                echo "0"
                        fi
                else
                        echo "0"
                fi
                ;;
        ve_free)
                VELIC=$(/usr/sbin/vzlicview | grep ct_total | cut -d'=' -f2 | awk '{print $1}')
                VEINUSE=$(/usr/sbin/vzlicview | grep ct_total | cut -d'=' -f2 | awk '{print $2}' | sed 's/[\(\)]//g')
                VEFREE=$(($VELIC-$VEINUSE))
                echo "${VEFREE}"
                ;;
        *)
                echo "Following Paramters are allowed:"
                echo -e "\texpire - to check if the Licence about to expire"
                echo -e "\tve_free - to check if the Licence have enough free VEs"
                ;;
esac
 
exit 0

Windows

Parameters

UserParameter=raid.areca,C:\Windows\system32\areca_cli.exe rsf info | find /C "Normal"
UserParameter=raid.3ware,cmd /D /V:ON /E:ON /Q /C "for /F "usebackq tokens=1,2,3" %a in (`C:\tw_cli.exe info c0`) do (set zz=%a && set zz=!zz:~0,1! && if "!zz!"=="u " echo %c)"
UserParameter=raid.lsimegaraid,C:\Windows\system32\MegaCli.exe -ldinfo -lall -aall | find "State" | find /V /C "Optimal"
UserParameter=raid.winswde,(echo list volume | diskpart | find "NTFS" | find /V /C "Fehlerfre" > NUL && echo 0) || echo 1
UserParameter=raid.winswen,(echo list volume | diskpart | find "NTFS" | find /V /C "Healthy" > NUL && echo 0) || echo 1
UserParameter=mssql.run,tasklist /FI "IMAGENAME eq sqlservr.exe" | find /C "sqlservr.exe"