linux下Nagios的安装和配置
Nagios是企业普遍使用的最具影响力的网络信息监视系统之一,它可以动态监视指定的网络状态,并在状态异常时发出警告音或邮件报警通知运维人员。监控的类型和警报定时器是完全可定制的。
Nagios的另一强大功能是它能同时监测主机和服务。例如,它可以同时监测到IP地址和TCP/UDP端口号。为进一步阐述此功能,我们假定有台需要监测的web服务器,Nagios可运用在服务器上基于IP/服务器名运行ping命令的方法检测服务器是否在线,同时当服务器的RTT(往返时延)增加时,Nagios会随时告警。另外,Nagios还能检测TCP的80端口(web服务器)是否可达,比如可能出现服务器在线但Apache/IIS没有响应的情况。
而基于Nagios的第三方监测工具如Centreon, FAN , op5 Monitor 在界面设计,自动化运行和技术支持方面在独立的Nagios引擎基础上提供了相应的补充。
centos7下
先安装所有需要的套件
yum install httpd php php-cli gd gd-devel gcc glibc glibc-common net-snmp wget
# useradd nagios # passwd nagios # groupadd nagcmd # usermod -a -G nagcmd nagios # usermod -a -G nagcmd apache
创建用户以及用户组
# cd /usr/local/src # wget http://liquidtelecom.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.8/nagios-4.0.8.tar.gz # tar xzf nagios-4.0.8.tar.gz # cd nagios-4.0.8 # ./configure –with-command-group=nagcmd # make all # make install # make install-init # make install-config # make install-commandmode # make install-webconf
安装nagios
d /usr/local/src # wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz # tar xzf nagios-plugins-2.0.3.tar.gz # cd nagios-plugins-2.0.3 # ./configure –with-nagios-user=nagios –with-nagios-group=nagios # make # make install
安装插件
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin # systemctl start httpd # systemctl enable httpd
设置密码,启动httpd服务
# systemctl start nagios # systemctl enable nagios
启动nagios并设置开机自启动
下面是用yum下载
yum install nagios nagios-plugins
1、本机监控HTTP SSH的Notifications显示警告错误,解决方法:
#vim /usr/local/nagios/etc/objects/localhost.cfg
define service{
use local-service ; Name of service template to use
host_name localhost
service_description SSH
check_command check_ssh
notifications_enabled 1 #改为1,即可
}
# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.
define service{
use local-service ; Name of service template to use
host_name localhost
service_description HTTP
check_command check_http
notifications_enabled 1 #改为1,即可
}
2、Nagios显示类似错误:HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.002 second response time。
该错误表明在apache web根目录没有index.html文件。解决方法:在web根目录(如:/var/www/html/目录)建立index.html文件,重启apache和nagios即可。
参考自https://www.phpini.com/linux/rhel-centos-7-install-nagios
http://www.sosidc.com/post-41.html