温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS环境下Nagios的安装与配置

发布时间:2021-09-15 20:16:59 来源:亿速云 阅读:200 作者:chen 栏目:系统运维

本篇内容主要讲解“CentOS环境下Nagios的安装与配置”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“CentOS环境下Nagios的安装与配置”吧!

一、安装环境:CentOS5.4 + Apache2 + PHP5.2,请确保已安装PHP+Apache,可参看本博有关Apache与PHP的安装教程;

  二、创建Nagios用户及用户组,命令如下:

#useradd -m nagios

--创建nagcmd组用来运行通过web接口传输过来的命令,同时添加nagios和apache

#groupadd nagcmd   #usermod -a -G nagcmd nagios   #usermod -a -G nagcmd apache

三、下载安装Nagios及Nagios插件,过程如下:

——下载Nagios

#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz

——下载Nagios插件

#wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

——解压Nagios

#tar -zvxf nagios-3.2.1.tar.gz

#cd nagios-3.2.1

——编译

#./configure --with-command-group=nagcmd #make all

——安装Nagios,初始化脚本及配置文件,Nagios将会被安装至/usr/local/nagios #make install #make install-init #make install-config #make install-commandmode

——安装WEB界面,界面将会安装到 /usr/local/nagios/share ( http 配置文件默认添加到 /etc/httpd/conf.d/nagios.conf,如果没有则执行:#cp sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf )

#make install-webconf

——创建HTTP认证用户登录Nagios,用户名nagiosadmin,密码123456

#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

——重启apache

#service httpd restart

——安装Nagios插件

#tar -zvxf nagios-plugins-1.4.14.tar.gz

#cd nagios-plugins-1.4.14

#./configure --with-nagios-user=nagios --with-nagios-group=nagios #make && make install

——配置Nagios管理员接受告警信息的邮箱,写入管理员邮箱 #vim /usr/local/nagios/etc/objects/contacts.cfg email admin@admin.com ; ——校验Nagios配置文件,验证配置是否有误 #/usr/local/nagios/bin/nagios -v

——启动Nagios,配置在系统启动时运行Nagios

#chkconfig --add nagios   #chkconfig nagios on   #chkconfig httpd on

——运行Nagios

#service nagios start

四、登陆到Web界面,输入用户名密码:nagiosadmin 123456,http://localhost/nagios/

五、错误处理

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即可。

到此,相信大家对“CentOS环境下Nagios的安装与配置”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI