nagios 数据更新不及时的问题

配置nagios的时候发现一个问题,就是改变了某个主机或者服务的描述之后,在主页信息总是更新很慢,而且告警信息还是老的信息,重启多次 nagios甚至重启主机都没有解决,其实这些都是由于nagios每次关闭的时候都会保存数据到/usr/local/nagios/var /retention.dat这个文件中,然后启动的时候读取这个文件的数据,打开这个文件发现都是一些nagios各个监控对象的状态参数,如:

host {
host_name=DianAn-MSR5400
alias=********
display_name=DianAn-MSR5400
modified_attributes=0
check_command=
check_period=24x7
notification_period=24x7
event_handler=
has_been_checked=0
check_execution_time=0.000
check_latency=0.056
check_type=0
current_state=0
last_state=0
last_hard_state=0
last_event_id=0
current_event_id=0
current_problem_id=0
last_problem_id=0
plugin_output=
long_plugin_output=
performance_data=
last_check=0
next_check=1323659506
check_options=0
current_attempt=1
max_attempts=1
normal_check_interval=1.000000
retry_check_interval=1.000000
state_type=1
last_state_change=1323659204
last_hard_state_change=1323659204
last_time_up=0
last_time_down=0
last_time_unreachable=0
notified_on_down=0
notified_on_unreachable=0
last_notification=0
current_notification_number=0
current_notification_id=0
notifications_enabled=1
problem_has_been_acknowledged=0
acknowledgement_type=0
active_checks_enabled=1
passive_checks_enabled=1
event_handler_enabled=1
flap_detection_enabled=0
failure_prediction_enabled=1
process_performance_data=1
obsess_over_host=1
is_flapping=0
percent_state_change=0.00
check_flapping_recovery_notification=0
state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
}

从这些信息可以看出,nagios每次启动都能延续上次关闭前的状态,是读取了这个文件的内容所致,这对维护长期状态监测数据统计等工作有利,但也会造成 nagios启动慢和信息不能及时更新的问题,要及时更新数据,可以先stop nagios,删除掉相应的host部分,或者清空文件echo > /usr/local/nagios/var/retention.dat,然后再启动nagios即可。如果不想在nagios关闭前保存主机和服务的 状态信息,可以在nagios的配置主文件里找到retain_state_information,改为0即可。

转自:http://blog.csdn.net/jack161641/article/details/7062851

原文地址:https://www.cnblogs.com/nhlinkin/p/3603594.html