nagios状态数据更新不及时问题

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

 1 host {
 2 host_name=DianAn-MSR5400
 3 alias=********
 4 display_name=DianAn-MSR5400
 5 modified_attributes=0
 6 check_command=
 7 check_period=24x7
 8 notification_period=24x7
 9 event_handler=
10 has_been_checked=0
11 check_execution_time=0.000
12 check_latency=0.056
13 check_type=0
14 current_state=0
15 last_state=0
16 last_hard_state=0
17 last_event_id=0
18 current_event_id=0
19 current_problem_id=0
20 last_problem_id=0
21 plugin_output=
22 long_plugin_output=
23 performance_data=
24 last_check=0
25 next_check=1323659506
26 check_options=0
27 current_attempt=1
28 max_attempts=1
29 normal_check_interval=1.000000
30 retry_check_interval=1.000000
31 state_type=1
32 last_state_change=1323659204
33 last_hard_state_change=1323659204
34 last_time_up=0
35 last_time_down=0
36 last_time_unreachable=0
37 notified_on_down=0
38 notified_on_unreachable=0
39 last_notification=0
40 current_notification_number=0
41 current_notification_id=0
42 notifications_enabled=1
43 problem_has_been_acknowledged=0
44 acknowledgement_type=0
45 active_checks_enabled=1
46 passive_checks_enabled=1
47 event_handler_enabled=1
48 flap_detection_enabled=0
49 failure_prediction_enabled=1
50 process_performance_data=1
51 obsess_over_host=1
52 is_flapping=0
53 percent_state_change=0.00
54 check_flapping_recovery_notification=0
55 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
56 }

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

原文地址:https://www.cnblogs.com/wowchky/p/2729024.html