1.Получение информации с NTP-службы
1 |
# ntpq -pn 127.0.0.1 |
1 2 3 4 5 6 |
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-агенте Выполнить скрипт
1 |
# nano ntp-prepare.sh |
1 2 3 4 5 6 7 8 9 |
#!/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-статистики
1 |
# 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-агента
1 |
# nano /etc/zabbix/zabbix_agentd.d/userparameter_ntp.conf |
1 2 |
# NTP monitoring UserParameter=ntp[*],/etc/zabbix/scripts/ntp.sh $1 |
Перезапуск Zabbix-агента # Ubuntu14
1 |
# service zabbix-agent restart |
#Ubuntu16
1 |
# systemctl restart zabbix-agent |
Проверка получений NTP-метрик локально с Zabbix-клиента
1 |
# sudo -u zabbix /etc/zabbix/scripts/ntp.sh delay |
1 |
8.384 |
1 |
# zabbix_get -s 127.0.0.1 -k ntp[delay] |
1 |
8.384 |
С Zabbix-сервера
1 |
# zabbix_get -s ip-address-zabbix-client -k ntp[delay] |
1 |
8.384 |
4.Настройка Zabbix-сервера Скачиваем,распаковываем и импортируем […]