Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设备,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
Nagios 可以监控的功能有: 1、监控网络服务(SMTP、POP3、HTTP、NNTP、PING等); 2、监控主机资源(处理器负荷、磁盘利用率等); 3、简单地插件设计使得用户可以方便地扩展自己服务的检测方法; 4、并行服务检查机制; 5、具备定义网络分层结构的能力,用"parent"主机定义来表达网络主机间的关系,这种关系可被用来发现和明晰主机宕机或不可达状态; 6、当服务或主机问题产生与解决时将告警发送给联系人(通过EMail、短信、用户定义方式); 7、可以定义一些处理程序,使之能够在服务或者主机发生故障时起到预防作用; 8、自动的日志滚动功能; 9、可以支持并实现对主机的冗余监控; 10、可选的WEB界面用于查看当前的网络状态、通知和故障历史、日志文件等;[1] 11、可以通过手机查看系统监控信息; 12、可指定自定义的事件处理控制器;
nagiso部署略
往nagios中添加主机,需要在nagios主机服务器中操作
在/usr/local/nagios/etc/objects目录下新建编辑需要添加的主机的cfg文件,最好用IP.cfg命名
以下是xm脚本模板
define host{
use linux-server host_name controller alias controller address 192.168.96.61 check_command check-host-alive max_check_attempts 2 notification_period 24x7 notification_interval 3600 notification_options d,u,r }
define service{ use generic-service host_name controller max_check_attempts 2 normal_check_interval 300 retry_check_interval 15 notification_interval 3600 notification_period 24x7 notification_options w,u,c,r service_description PING check_command check_ping!100.0,20%!500.0,60% }
define service{ use generic-service host_name controller max_check_attempts 2 normal_check_interval 300 retry_check_interval 15 notification_interval 3600 notification_period 24x7 notification_options w,u,c,r service_description SSH check_command check_ssh }
define service{ use generic-service host_name controller max_check_attempts 2 normal_check_interval 300 retry_check_interval 15 notification_interval 3600 notification_period 24x7 notification_options w,u,c,r service_description Horizon check_command check_http! -H 192.168.96.61 -u /horizon/ }
define service{ use generic-service host_name controller max_check_attempts 2 normal_check_interval 300 retry_check_interval 15 notification_interval 3600 notification_period 24x7 notification_options w,u,c,r service_description cinder check_command check_tcp!8776 } define service{ use generic-service host_name controller max_check_attempts 2 normal_check_interval 300 retry_check_interval 15 notification_interval 3600 notification_period 24x7 notification_options w,u,c,r service_description glance check_command check_tcp!9292 } 然后编辑/usr/local/nagios/etc/nagios.cfg添加如下:
cfg_file=/usr/local/nagios/etc/objects/192.168.1.100.cfg
重启服务服务service nagios restart
nagios就可以监控到192.168.1.100这台主机了
