ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码

zabbix zabbix监控服务器时间问题

来源:网络整理     时间:2017-06-16     关键词:zabbix

本篇文章主要介绍了"zabbix zabbix监控服务器时间问题",主要涉及到zabbix方面的内容,对于Windows Server 2008jrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播感兴趣的同学可以参考一下: zabbix中有自带对linux服务器时间进行监控的模板,用的key是system.localtime返回当前的系统时间,而配置tigger报警时是用的fuzz...

zabbix中有自带对linux服务器时间进行监控的模板,用的key是system.localtime返回当前的系统时间,而配置tigger报警时是用的fuzzytime(N)方法,该方法是将返回的系统时间与监控服务器的时间进行对比,如果大于N,则报警。

存在一下3个问题:

1、监控服务器并不一定是ntp服务器:这种情况下也就说是系统时间是与非NTP服务器对比的时间。

2、取到被监控系统的时间,然后再返回给监控服务器,当监控项数量大,或监控出现延时队列的时候。就会产生误报。

3、对于windows server服务器没有相应的模版。

正好业务上有一批搭载系统为windows server的服务器,而业务对时间要求比较高。

下面是我的解决办法:

第一,利用下面的bat脚本设置windos时间同步服务器

@echo off
@REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Parameters /v NtpServer /t REG_SZ /d "10.13.255.1,0x9\0 10.13.255.2,0x9\0 0.cn.pool.ntp.org,0x9" /f
@echo off
@REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Parameters /v Type /t REG_SZ /d NTP /f
@echo off
echo ------------------------------------
@echo off
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\TimeProviders\NtpClient /v SpecialPollInterval /t REG_DWORD /d 60 /f
@echo off
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Config /v MaxAllowPhaseOffset /t REG_DWORD /d 3600 /f
@echo off
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Config /v MaxNegPhaseCorrection /t REG_DWORD /d 3600 /f
@echo off
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Config /v MaxPosPhaseCorrection /t REG_DWORD /d 3600 /f
@echo off
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Config /v PhaseCorrectRate /t REG_DWORD /d 7 /f
@echo off
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Config /v MinPollInterval /t REG_DWORD /d 3 /f
@echo off
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Config /v MaxPollInterval /t REG_DWORD /d 4 /f
@echo off
sc triggerinfo w32time start/networkon
@echo off
gpupdate /force
@echo off
w32tm /resync
@echo off
net stop w32time
net start w32time

说明:

"10.13.255.1,0x9\0 10.13.255.2,0x9\0 0.cn.pool.ntp.org,0x9"

以上地址只适用于本人的托管机房

第二编写用于对比时间的python脚本

#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import time
import ntplib

def get_time():
    ntp_client = ntplib.NTPClient()
    response = ntp_client.request('s2g.time.edu.cn')
    wtime = time.strftime('%Y%m%d%H%M%S', time.localtime(response.tx_time))

    return wtime

if __name__ == '__main__':
    networktime = get_time()
    local_time = time.strftime('%Y%m%d%H%M%S')
    difference = abs(int(networktime) - int(local_time))

    print difference

windows下可以使用pyinstaller打包成exe可执行文件

第三在zabbix_agentd.conf中添加自定义的key

UserParameter=custom.timediff.count,"D:\bat\get_time.exe"

重启zabbix服务

第四添加监控和触发器,本人设置当时间不一致超过3秒就出发报警。

这个,相信大家都会,就不多说了

第五触发报警后,可在服务器上执行

同步时间

w32tm /resync

以上就介绍了zabbix zabbix监控服务器时间问题,包括了zabbix方面的内容,希望对Windows Server 2008jrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_4361691.html

zabbix相关图片

zabbix相关文章