Скрипт TCPPing для Zabbix
net-analyzer/zabbix-2.0.9
net-analyzer/nmap-6.25
Установка скрипта
Создание папки для скриптов:
mkdir /etc/zabbix/scripts/ chown root:zabbix -R /etc/zabbix/scripts/ chmod 750 /etc/zabbix/scripts/
/etc/zabbix/scripts/tcpping.sh
#!/bin/bash if [[ -z "$1" || -z "$2" ]]; then exit 1 fi ##### PARAMETERS ##### ADDR="$1" PORT="$2" TIMEOUT=9 LOG="/var/log/zabbix/tcpping.${ADDR}.log" NOWDATE=`date '+%Y-%m-%d %H:%M:%S'` ##### RUN ##### OUTPUT=`{ TIMEFORMAT="%R"; time nc -w ${TIMEOUT} -zvv ${ADDR} ${PORT}; } 2>&1` EXITCODE=$? if [ ${EXITCODE} -ne 0 ]; then echo -e "-------------------------------------------------------------------------------- DATE:${NOWDATE} ADDRESS:${ADDR} PORT:${PORT} CODE:${EXITCODE} -------------------------------------------------------------------------------- ${OUTPUT}\n" >> ${LOG} echo 9.999 exit 1 fi echo "${OUTPUT}" | tail -n1
Установка прав
chown root:zabbix /etc/zabbix/scripts/nginx-stats.sh chmod 550 /etc/zabbix/scripts/nginx-stats.sh
Настройка Zabbix Agent
Настройка
/etc/zabbix/zabbix_agentd.conf
... UserParameter=tcpping[*],/etc/zabbix/scripts/tcpping.sh "$1" "$2"
/etc/init.d/zabbix-agentd restart
Проверка
zabbix_get -s HOST -k "tcpping[ya.ru,80]"
Обсуждение