Nagios的PassiveChecks是什么
Nagios是一款开源的网络监控工具,用于监控网络设备、服务器和应用程序的性能和可用性,在Nagios中,Passive Checks是一种被动检查方法,它不需要从被监控对象获取实时数据,而是通过查询外部资源来获取所需的信息,这种方法可以降低对被监控对象的负载,提高监控效率。
Passive Checks的原理
Passive Checks的原理是通过查询外部资源(如DNS、SNMP等)来获取被监控对象的状态信息,当Nagios执行一个Passive Check时,它会向指定的外部资源发送请求,然后根据返回的数据来判断被监控对象的状态,这种方法不需要在被监控对象上运行任何插件或代理,因此对被监控对象的负载影响较小。
Passive Checks的类型
Nagios支持多种类型的Passive Checks,包括:
1、DNS Check:通过查询DNS服务器来获取主机名对应的IP地址,从而判断主机是否可达。
2、TCP Check:通过尝试与目标主机建立TCP连接,判断主机是否可达。
3、POP3 Check:通过查询邮件服务器的POP3服务,判断邮件服务器是否正常运行。
4、ICMP Check:通过发送ICMP回显请求包,判断目标主机是否可达。
5、JDBC Check:通过查询数据库服务器的JDBC服务,判断数据库服务器是否正常运行。
6、Ping Check:通过发送ICMP回显请求包,判断目标主机是否可达。
7、SSH Check:通过SSH协议连接到目标主机,判断主机是否可达。
8、SMTP Check:通过查询邮件服务器的SMTP服务,判断邮件服务器是否正常运行。
9、SSL Check:通过SSL协议连接到目标主机,判断主机是否可达。
10、TELNET Check:通过TELNET协议连接到目标主机,判断主机是否可达。
Passive Checks的配置
在Nagios中配置Passive Checks非常简单,首先需要在Nagios的主配置文件(nagios.cfg)中启用相应的插件,要启用DNS插件,可以在nagios.cfg文件中添加以下内容:
cfg_dir=/usr/local/nagios/etc/objects cfg_file=/usr/local/nagios/etc/objects/commands.cfg include_dir=/usr/local/nagios/etc/servers command_file=/usr/local/nagios/etc/objects/commands.cfg ... 启用DNS插件 object_cache_entries=10000 enable_passive_checks=1 ...
接下来,需要在Nagios的命令配置文件(commands.cfg)中定义Passive Check的命令,要定义一个DNS Check,可以在commands.cfg文件中添加以下内容:
define command{ command_name check_dns command_line $USER1$/check_dns H $HOSTADDRESS$ w 5,8,10 c 1 p 5,8,10 $ARG1$ }
在Nagios的服务配置文件(service.cfg)中为服务定义Passive Check,要为一个Web服务定义一个DNS Check,可以在service.cfg文件中添加以下内容:
define service{ use genericservice ; Inherit default values from a templated service.id file. host_name webserver ; Define the host name we are monitoring. This could be a fully qualified domain name or a IP address. alias Web Server ; This is just an arbitrary name for us to identify this service by within Nagios. It is not used by Nagios itself. service_description Apache Web Server ; A brief description of what this service does. This can be left blank if not needed. check_command check_dns ; The actual check we will be performing on the host. This should be defined in the commands.cfg file above. normal_check_interval 60 ; How often to check the host in normal operation (in seconds). If this value is set to zero, then the host will only be checked in response to a problem being reported for it. retry_check_interval 120 ; How often to retry a check if one fails (in seconds). If this value is set to zero, then retries are disabled and a failed check will not be retried until manually restarted by the administrator. max_check_attempts 3 ; The maximum number of times to retry a check before declaring it has failed permanently (unless 'check_freshness' is set to 'true'). If this value is set to zero, then retries are disabled and a failed check will not be retried until manually restarted by the administrator. check_period 24x7 ; When to check the host (in days, hours, minutes, and seconds). For example, '24x7' means check the host every day of the week at all times of day and night. If this value is set to zero, then the host will only be checked in response to a problem being reported for it. check_freshness true ; Whether to consider the state of any dependent services when checking the host (see below). If this value is set to false, then the host will be considered up if all its dependent services are up regardless of their actual state. active_checks_enabled false ; Whether to allow active checks to be performed on this host (see below). If this value is set to false, then passive checks will be used instead of active checks for this host. passive_checks_enabled true ; Whether to allow passive checks to be performed on this host (see below). If this value is set to false, then active checks will be used instead of passive checks for this host. event_handler root ; The user that Nagios should use as the owner of events generated by this service definition (e.g., host notifications). This user must have write permission on the log files specified in the log_location parameter below and must also have access to any external command or program specified in the check_command parameter above. log_location /var/log/nagios3/rw/nagios.log ; Where Nagios should store its log files for this service definition (see above). This directory must exist and must be writable by the user specified in the event_handler parameter above and by all users that may need to read these log files (e.g., system administrators). }
Passive Checks的优势和局限性
优势:
1、对被监控对象的负载影响较小:Passive Checks不需要在被监控对象上运行任何插件或代理,因此对被监控对象的负载影响较小。
2、提高监控效率:由于Passive Checks不需要实时获取数据,因此可以提高监控效率,特别是在网络环境较差的情况下,Active Checks可能会因为超时而失败,而Passive Checks则不会受到影响。
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/574845.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复