1.Получение информации с NTP-службы
|
remote refid st t when poll reach delay offset jitter ============================================================================== +176.221.42.125 37.120.191.245 3 u 806 1024 377 8.638 -1.089 0.978 +144.76.19.215 122.227.206.195 3 u 427 1024 377 0.685 -0.124 0.422 5.9.118.105 193.79.237.14 2 u 37d 1024 0 0.434 -31.270 0.000 *138.201.16.225 131.188.3.221 2 u 130 1024 377 0.314 -1.047 0.611 |
2.Настройка скрипта на Zabbix-агенте Выполнить скрипт
|
#!/bin/bash [ -d /etc/zabbix/scripts ] || mkdir /etc/zabbix/scripts/ chown root:zabbix -R /etc/zabbix/scripts/ chmod 750 /etc/zabbix/scripts/ [ -f /etc/zabbix/scripts/ntp.sh ] || touch /etc/zabbix/scripts/ntp.sh chown root:zabbix /etc/zabbix/scripts/ntp.sh chmod 550 /etc/zabbix/scripts/ntp.sh |
Создание скрипта для снятия NTP-статистики
|
# nano /etc/zabbix/scripts/ntp.sh |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#!/bin/bash VERSION="1.0" function usage() { echo "ntpcheck version: $VERSION" echo "usage:" echo " $0 jitter - Check ntp jitter delay" echo " $0 offset - Check ntp offset" echo " $0 delay - Check ntp delay" } ######## # Main # ######## if [[ $# != 1 ]];then #No Parameter usage exit 0 fi case "$1" in 'jitter') value=`ntpq -pn 127.0.0.1 | /usr/bin/awk 'BEGIN { jitter=0 } $1 ~/\*/ { jitter=$10 } END { print jitter }'` rval=$?;; 'offset') value=`ntpq -pn 127.0.0.1 | /usr/bin/awk 'BEGIN { offset=0 } $1 ~/\*/ { offset=$9 } END { print offset }'` rval=$?;; 'delay') value=`ntpq -pn 127.0.0.1 | /usr/bin/awk 'BEGIN { delay=0 } $1 ~/\*/ { delay=$8 } END { print delay }'` rval=$?;; 'health') primary=`ntpq -pn 127.0.0.1 | grep ^\* |grep -v grep | wc -l` rval=$? if [ "${primary}" -eq "1" ] ; then value="1" else value="0" fi ;; *) usage exit 1;; esac if [ "$rval" -eq 0 -a -z "$value" ]; then rval=1 fi if [ "$rval" -ne 0 ]; then echo "ZBX_NOTSUPPORTED" fi echo $value |
3.Настройка Zabbix-агента
|
# nano /etc/zabbix/zabbix_agentd.d/userparameter_ntp.conf |
|
# NTP monitoring UserParameter=ntp[*],/etc/zabbix/scripts/ntp.sh $1 |
Перезапуск Zabbix-агента # Ubuntu14
|
# service zabbix-agent restart |
#Ubuntu16
|
# systemctl restart zabbix-agent |
Проверка получений NTP-метрик локально с Zabbix-клиента
|
# sudo -u zabbix /etc/zabbix/scripts/ntp.sh delay |
|
# zabbix_get -s 127.0.0.1 -k ntp[delay] |
С Zabbix-сервера
|
# zabbix_get -s ip-address-zabbix-client -k ntp[delay] |
4.Настройка Zabbix-сервера Скачиваем,распаковываем и импортируем […]