Table of Contents

Zabbix UserParameters

Linux

Parameters

UserParameter=backup.cdp.dump,/usr/bin/find /backup/cdpConfigs/ -name \*.err -and ! -size 0 -or -size -4k -and -name \*.dmp | wc -l
UserParameter=backup.cdp.dump.num,/usr/bin/find /backup/cdpConfigs/ -name \*.dmp | wc -l
UserParameter=cerberus.jobstatus[*],/opt/cronjobs/bin/helpdesk_lastline "$1" | grep -qv ERR; echo $?
UserParameter=dmesg.errors,dmesg | tail -n+2 | egrep -i "error|warning|beyond|unable|could| bad|fail|corrupt|insufficient|too small|Can't|Cannot|inconsistent|Invalid" | egrep -v -i "UDP: bad checksum|.* iomem range .* could not be reserved|PM: Resume from disk failed|ACPI: Looking for DSDT in initramfs|unable to open rtc device|Calgary: Unable to locate Rio Grande table in EBDA - bailing|segfault|Scanning|bios|AER service|BAR .* can't allocate mem resource|CIFS VFS: Send error|NT_STATUS_LOGON_FAILURE|swapper: page allocation failure|nfs: RPC call returned error 88|CIFS VFS: cifs_mount failed w/return code = -11|pnp:.* iomem range .* could not be reserved|PCI: Failed to allocate mem resource .* for .*|Warning: pci_mmcfg_init marking .* space uncacheable|venet[0-9]{1,}: OUT accounting: IP header error|Neighbour table failure & not caching routes.|budBIOEndIO:.*|Non-Fatal|VZFS: dirindex corrupted|Failed to restore mount point|kernel/futex|error_exit|repair completed|Corrected error|power_meterInvalid|__brelse|fail2ban|apache|httpd|popuser|set_itimer|hcp1|hcp:|running e2fsck is recommended|Battery temperature is high" | wc -l
UserParameter=drbd.master.available,grep " cs:" /proc/drbd | grep -v "Primary" | wc -l
UserParameter=drbd.repl.uptodate,grep " cs:" /proc/drbd | grep -v "UpToDate/UpToDate" | wc -l
UserParameter=drbd.resource.discovery,echo '{"data":['; for RES in $(grep " cs:" /proc/drbd | cut -d':' -f1); do if [ "x${FIRST}" != "x1" ]; then FIRST=1; else echo ","; fi; echo "{ \"{#RESOURCE}\":\"$RES\"}"; done; echo "]}"
UserParameter=drbd.stats.al[*],grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^al:" | cut -d':' -f2
UserParameter=drbd.stats.ap[*],grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^ap:" | cut -d':' -f2
UserParameter=drbd.stats.bm[*],grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^bm:" | cut -d':' -f2
UserParameter=drbd.stats.dr[*],echo $(grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^dr:" | cut -d':' -f2)000
UserParameter=drbd.stats.dw[*],echo $(grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^dw:" | cut -d':' -f2)000
UserParameter=drbd.stats.ep[*],grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^ep:" | cut -d':' -f2
UserParameter=drbd.stats.lo[*],grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^lo:" | cut -d':' -f2
UserParameter=drbd.stats.nr[*],echo $(grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^nr:" | cut -d':' -f2)000
UserParameter=drbd.stats.ns[*],echo $(grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^ns:" | cut -d':' -f2)000
UserParameter=drbd.stats.oos[*],echo $(grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^oos:" | cut -d':' -f2)000
UserParameter=drbd.stats.pe[*],grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^pe:" | cut -d':' -f2
UserParameter=drbd.stats.ua[*],grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^ua:" | cut -d':' -f2
UserParameter=drbd.stats.wo[*],grep -A1 "$1: cs:" /proc/drbd | xargs -n1 echo | grep "^wo:" | cut -d':' -f2
UserParameter=exim.queue,if [ -n "$(which exim4 2> /dev/null)" ]; then sudo exim4 -bpc; else sudo exim -bpc; fi
UserParameter=fs.writecheck,(sudo touch /etc/passwd /var/log/messages && echo "1") || echo "0"
UserParameter=gds2.tomcat.status,read tomcatRoles tomcatUser tomcatPass <<< $(sudo cat /etc/tomcat/tomcat-users.xml | xmlstarlet sel -T -t -m '//user' -v 'concat(@roles," ",@name," ",@password)' -n | egrep -e '^[^ ]*manager-script[, ]'|head -1); tomcatState=$(curl -f -s http://${tomcatUser}:${tomcatPass}@127.0.0.1:8081/manager/text/list); echo -n 0; for serv in authgw cmis provisioning-gw adminapi host-manager; do echo "$tomcatState" | egrep -q  "/${serv}:(running):" || echo $? && break; done
UserParameter=ipmi.sensors,sudo ipmitool sdr list | egrep -v " ok$| ns$| nc$" | wc -l
UserParameter=mem.sreclaimable,MEM=$(grep '^SReclaimable:' /proc/meminfo | awk '{print $2*1024 }') && ([ -z "${MEM}" ] && echo 0) || echo ${MEM}
UserParameter=mmm.checks,sudo /usr/sbin/mmm_control checks | grep -v OK | grep -v "^$" | wc -l
UserParameter=mmm.nodestatus,sudo /usr/sbin/mmm_control show | grep -vi online | head -n-1 | wc -l
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.percona.status,((sudo mysql --defaults-extra-file=/root/.my.cnf -N -B -e "show status where variable_name in ('wsrep_local_state_comment','wsrep_connected','wsrep_cluster_status','wsrep_ready','wsrep_desync');" 2>/dev/null || echo "OFF") | egrep -q -v "Synced|Primary|ON" 2>/dev/null && echo 0) || echo 1
UserParameter=mysql.ping,sudo mysqladmin ${MYSQLAUTH} ping | grep alive | wc -l
UserParameter=mysql.qps,sudo mysqladmin ${MYSQLAUTH} status | cut -f9 -d':'
UserParameter=mysql.questions,sudo mysqladmin ${MYSQLAUTH} status|cut -f4 -d':' | cut -f1 -d'S'
UserParameter=mysql.secondsbehindmaster,sudo mysql ${MYSQLAUTH} -e 'show slave status \G' | egrep 'Seconds_Behind_Master' | awk '{print $2}'
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,ret=0; str=$(sudo mysql ${MYSQLAUTH} -e 'show slave status \G' | egrep 'Slave_IO_Running|Slave_SQL_Running' | awk '{print $2}' | xargs | grep No); if [ "x${str}" = "x" ]; then ret=1; fi; if [ "x${str}" = "xNo Yes" ]; then ret=-1; fi; echo ${ret}
UserParameter=mysql.slowqueries,sudo mysqladmin ${MYSQLAUTH} status|cut -f5 -d':' | cut -f1 -d'O'
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.timezone,(sudo mysql ${MYSQLAUTH} -sNLe "select unix_timestamp();" && date "+%s") | uniq -c | tail -n1 | awk '{print $1}'
UserParameter=mysql.uptime,sudo mysqladmin ${MYSQLAUTH} status|cut -f2 -d':' | cut -f1 -d'T'
UserParameter=mysql.version,sudo mysql -V
UserParameter=net.bond.status,for i in /proc/net/bonding/*; do cat "$i" | egrep -e '^(MII Status|Speed|Duplex|Slave queue ID):'|sort|uniq -u; done | wc -l
UserParameter=ntp.offset[*],ntpdate -q $1 | tail -n1 | xargs echo | sed -E 's/.*(( [\+-]*[0-9]+\.[0-9]+ sec)|( [\+-]*[0-9]+\.[0-9]+ \+\/- )).*/\1/g' | cut -d' ' -f2
UserParameter=pacemaker.status,sudo crm_mon -s | egrep -q -v "^Ok: |^CLUSTER OK: "; echo $?
UserParameter=packages.apt.available.security_updates,if [ -x /usr/lib/update-notifier/apt-check ] ; then /usr/lib/update-notifier/apt-check 2>&1 | cut -d ';' -f2; else yum -e 0 -d 0 --security check-update | tail -n +1| wc -l; fi
UserParameter=packages.apt.available.updates,if [ -x /usr/lib/update-notifier/apt-check ] ; then /usr/lib/update-notifier/apt-check 2>&1 | cut -d ';' -f1; else yum -e 0 -d 0 check-update | tail -n +2| wc -l; fi
UserParameter=postfix.queue,if [ -n "$(which postqueue)" ]; then echo -n "0"; /usr/sbin/postqueue -p | tail -n1 | cut -d" " -f5; else echo "-1"; fi
UserParameter=qmail.queue,sudo /var/qmail/bin/qmail-qstat | grep 'messages in queue:' | awk '{print $4}'
UserParameter=raid.3ware,(sudo /usr/sbin/tw_cli help >/dev/null 2>&1 || (echo "INOPERABLE" ; false)) && 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.adaptec,(sudo /usr/local/sbin/arcconf getconfig 1 al | grep Status | egrep -i -q -v "Optimal|Charging|Not Installed|Status of Enclosure services device" && echo 0) || echo 1
UserParameter=raid.adaptec.errorcounter,(sudo /usr/local/sbin/arcconf getlogs 1 device tabular 2>/dev/null || echo "           abortedCmds -1" ) | egrep "numParityErrors|linkFailures|hwErrors|abortedCmds|mediumErrors|smartWarning" | cut -d ' ' -f13 | awk 'BEGIN{ SUM = 0 } { SUM += $1} END { print SUM }'
UserParameter=raid.adaptec.temperature,(sudo /usr/local/sbin/arcconf getconfig 1 al | grep -i Temperature | egrep -v -q "Normal|: No$" && echo 0) || echo 1
UserParameter=raid.areca,sudo /usr/local/bin/areca_cli rsf info | awk '{print $10}' | grep -v "^$" | egrep -v "DiskChannels|=====|GuiErrMsg|Normal" | wc -l
UserParameter=raid.hpacucli,sudo /usr/sbin/hpacucli controller all show config detail 2>&1 | grep Status | egrep -v "OK|Not Authenticated|LOCKED|Disabled|Initialization Completed" | wc -l
UserParameter=raid.hpacucli.bbu,sudo /usr/sbin/hpacucli controller all show config detail 2>&1 | grep -q 'Battery/Capacitor Status: OK' && echo 1 || echo 0
UserParameter=raid.lsimegaraid,if [ "$(sudo megacli -ldinfo -lall -aall -NoLog 2>/dev/null | wc -l)" -le "1" ]; then echo 1; else sudo megacli -ldinfo -lall -aall -NoLog | grep State | grep -v Optimal | wc -l; fi
UserParameter=raid.lsimegaraid.bbu,if [ "$(sudo megacli -AdpBbuCmd -GetBbuStatus -aall -NoLog 2>/dev/null | wc -l)" -le "1" ]; then echo 1; else sudo megacli -AdpBbuCmd -GetBbuStatus -aall -NoLog | grep "Battery Replacement required" | grep -i yes | wc -l; fi
UserParameter=raid.lsimegaraid.mediaerrors,if [ "$(sudo megacli -ldinfo -lall -aall -NoLog | wc -l)" -le "1" ]; then echo 1; else sudo megacli -LDPDInfo -aALL -NoLog | egrep 'Error|state' | egrep -v ': 0|: Online' | wc -l; fi
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.software,(cat /proc/mdstat | grep blocks | sed 's/.* \[\(.*\)\]$/\1/g' | grep -q -v U && echo 0) || echo 1
UserParameter=raid.vortex,cat /proc/scsi/gdth/* | grep Status | sed -e 's/^.*:\W*//g' | xargs
UserParameter=routing.extern,ping -q -n -l 3 -c 3 $(ip r l | grep default | awk '{print $3}') >/dev/null 2>&1; echo $?
UserParameter=salt.offline_count,sudo salt -v -t 15 '*' test.ping | grep -c 'Minion did not return'
UserParameter=sflow.collectors,egrep -v "^#|^$" /etc/default/sfcapd.conf  | wc -l
UserParameter=system.ethlink[*],if [ "$(sudo ethtool $1 | grep "Link detected:" | awk {'print $$3'})" = "yes" ]; then echo "1"; else echo "0"; fi
UserParameter=system.ethspeed[*],ZBX_ETHSPEED=$(sudo ethtool $1 2>/dev/null | grep "Speed:" | awk '{print $$2}' | cut -d'M' -f1); if [ "x${ZBX_ETHSPEED}" = 'xUnknown!' ] || [ "x${ZBX_ETHSPEED}" = 'x' ]; then ZBX_ETHSPEED=0; fi; echo ${ZBX_ETHSPEED}
UserParameter=unbound_stats[*],grep $1 /dev/shm/unbound_stats | cut -d'=' -f2
UserParameter=vz.freeves,sudo /etc/zabbix/zabbix_check_virtuozzo_licence.sh ve_free
UserParameter=vz.licence,sudo /etc/zabbix/zabbix_check_virtuozzo_licence.sh expire

/etc/sudoers

Defaults:zabbix !requiretty
zabbix ALL=NOPASSWD:/bin/cat,/bin/touch,/etc/zabbix/flockmonitor.sh,/etc/zabbix/zabbix_check_virtuozzo_licence.sh,/sbin/ethtool,/usr/sbin/ethtool,/usr/bin/ipmitool,/usr/bin/mailq,/usr/bin/megacli,/usr/sbin/megacli,/usr/local/bin/megacli,/usr/bin/mysql,/usr/bin/mysqladmin,/usr/local/bin/areca_cli,/usr/local/bin/mpt-status,/usr/sbin/mpt-status,/usr/local/sbin/arcconf,/usr/sbin/exim,/usr/sbin/exim4,/usr/sbin/hpacucli,/usr/sbin/mmm_control,/opt/projects/tools_monitoring_pyro/bin/tools_monitoring_pyro.py,/usr/sbin/tw_cli,/var/qmail/bin/qmail-qssr/sbin/dhcpd,/usr/sbin/dhcpd3,/usr/local/bin/silentlyRemoved.shegaCli,/usr/sbin/icpcon,/usr/sbin/areca_cli,/usr/sbin/crm_mon,/usr/sbin/dhcpd,/usr/sbin/dhcpd3

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=bexec.status[*],"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -noprofile -file "C:\Program Files\Zabbix\bexec_status.ps1" $1 $2
UserParameter=bexec.tape.sunday,"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -noprofile -file "C:\Program Files\Zabbix\bexec_tape_sunday.ps1"
UserParameter=mssql.run,tasklist /FI "IMAGENAME eq sqlservr.exe" | find /C "sqlservr.exe"
UserParameter=net.interface,cscript //H:CScript //Nologo //T:25 "C:\Program Files\Zabbix\conn_check.vbs"
UserParameter=net.ping[*],(ping -S "$1" -n 1 "$2" >NUL && echo 1) || echo 0
UserParameter=raid.3ware,cmd /D /V:ON /E:ON /Q /C "for /F "usebackq tokens=1,2,3" %a in (`"C:\Program Files\Zabbix\RAID\tw_cli.exe" info c0`) do (set zz=%a && set zz=!zz:~0,1! && if "!zz!"=="u " echo %c)"
UserParameter=raid.adaptec,powershell "$return = (& 'C:\Program Files\Zabbix\RAID\arcconf.exe' getconfig 1 al | where { $_ -clike '*Status*' -and $_ -notlike '*Optimal*' -and $_ -notlike '*Charging*' -and $_ -notlike '*Not Installed*' -and $_ -notlike '*Status of Enclosure services device*' }); $return = ($return | measure | select Count).count; if($return -gt 0){write-host '0'}else{write-host '1'}"
UserParameter=raid.adaptec.temperature,powershell "$return = (& 'C:\Program Files\Zabbix\RAID\arcconf.exe' getconfig 1 al | where { $_ -clike '*Temperature*'}| %{ $_.Split(':')[1]; }| %{ $_.Split('/')[1]; }| %{ $_.Split(' ')[3]; }); if ($return -like '*normal*'){write-host '1'}else{write-host '0'}"
UserParameter=raid.areca,"C:\Program Files\Zabbix\RAID\areca_cli.exe" rsf info | findstr /V "DiskChannels ===== GuiErrMsg" | find /V /C "Normal"
UserParameter=raid.hpacucli,"C:\Program Files\Zabbix\RAID\hpacucli.exe" ctrl all show config detail | find "Status" | find /V "RAID 6 (ADG)" | find /V "Initialization Completed" | find /V "Not Authenticated" | find /V "Drive Authentication Status" | find /V /C "OK"
UserParameter=raid.lsimegaraid,"C:\Program Files\Zabbix\RAID\MegaCli.exe" -ldinfo -lall -aall | find "State" | find /V /C "Optimal"
UserParameter=raid.lsimegaraid.bbu,"C:\Program Files\Zabbix\RAID\MegaCli.exe" -adpbbucmd -getbbustatus -aall | find "Battery Replacement required" | find /V /C "No"
UserParameter=raid.lsimegaraid.mediaerrors,"C:\Program Files\Zabbix\RAID\MegaCli.exe" -LDPDInfo -aALL | findstr "Error state" | find /V ": 0" | find /V /C ": Online"
UserParameter=raid.software,(echo list volume | diskpart | find "NTFS" | findstr /V "Fehlerfre Healthy" > NUL && echo 0) || echo 1
UserParameter=system.ethspeed[*],wmic NIC where Name="$1" get Speed | more +1
UserParameter=wmi.powersupply,wmic /namespace:\\root\cimv2 path CIM_PowerSupply get Status | findstr /V "^$ Status" | find /V /C "OK"

Scripts

bexec_tape_sunday.ps1
$WarningPreference = "SilentlyContinue"
 
 
if ((Test-Path "${env:ProgramFiles}\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI.psd1") -eq $true){
 
    $module = "${env:ProgramFiles}\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI.psd1"
 
} elseif ((Test-Path "${env:ProgramFiles(x86)}\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI.psd1") -eq $true){
 
    $module = "${env:ProgramFiles(x86)}\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI.psd1"
 
} else {
    if ($debug -eq $true){
        Write-Host "Can't find BackupExec API Script. Aborting..."
    } else {
        Write "255"
        exit 255
    }
}
 
Import-Module $module
 
# 1 is ok, so no sunday found
$sunday = "1"
 
$tapelib = Get-BEStorage | where { $_.StorageType -eq "RoboticLibraryDevice" }
$medias = Get-BEMedia | where { $_.LocationName -eq $tapelib.Name -and $_.MediaSet -ne "Cleaning Media" }
 
foreach ($media in $medias) {
    if ($media.AllocatedDate.DayOfWeek -eq "Sunday") {
        $curr_date = get-date
        # check if tape is from last backup or reinserted tape from rotation
        if ($media.AllocatedDate -gt $curr_date.adddays(-20)) {
            # change sunday to 0, because 0 is problem = sunday found
            $sunday = 0
        }
    }
}
 
write $sunday
conn_check.vbs
On Error Resume Next
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter Where NetConnectionStatus <> 2 AND NetConnectionStatus Is Not NULL AND NetEnabled = TRUE")
 
ret = "0"
For Each objItem in colItems
    ret = "1"
        WScript.Echo objItem
Next
WScript.Echo ret