Centos6.7 安装Naigos教程

Centos6.7 安装Naigos教程
参考文档:https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart-fedora.html

blog地址:http://www.cnblogs.com/caoguo


一.安装依赖包

[root@Nagios ~]# yum install -y httpd php
[root@Nagios ~]# yum install -y gcc glibc glibc-common
[root@Nagios ~]# yum install -y gd gd-devel
[root@Nagios ~]# yum install -y perl ntp unzip
[root@Nagios ~]# yum install -y openssl-devel

[root@Nagios ~]# /etc/init.d/ntpd start
[root@Nagios ~]# chkconfig ntpd on

[root@Nagios ~]# /usr/sbin/useradd -m nagios
[root@Nagios ~]# passwd nagios

[root@Nagios ~]# /usr/sbin/groupadd nagcmd
[root@Nagios ~]# /usr/sbin/usermod -a -G nagcmd nagios
[root@Nagios ~]# /usr/sbin/usermod -a -G nagcmd apache
[root@Nagios ~]# id nagios
uid=500(nagios) gid=500(nagios) groups=500(nagios),501(nagcmd)
[root@Nagios ~]# id apache
uid=48(apache) gid=48(apache) groups=48(apache),501(nagcmd)

 

二.nagios的安装

 

[root@Nagios ~]# cd /usr/local/src
[root@Nagios src]# wget http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
[root@Nagios src]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
[root@Nagios src]# tar zxvf nagios-4.1.1.tar.gz
[root@Nagios src]# cd nagios-4.1.1
[root@Nagios nagios-4.1.1]# ./configure --prefix=/usr/local/nagios --with-comand-group=nagcmd
[root@Nagios nagios-4.1.1]# make all
[root@Nagios nagios-4.1.1]# make install
[root@Nagios nagios-4.1.1]# make install-init
[root@Nagios nagios-4.1.1]# make install-config
[root@Nagios nagios-4.1.1]# make install-commandmode
[root@Nagios nagios-4.1.1]# make install-webconf
[root@Nagios nagios-4.1.1]# cp -rf contrib/eventhandlers /usr/local/nagios/libexec/
[root@Nagios nagios-4.1.1]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

 

 

 

 

三.nagios plugins的安装

[root@Nagios src]# tar xzf nagios-plugins-2.1.1.tar.gz 
[root@Nagios src]# cd nagios-plugins-2.1.1
[root@Nagios nagios-plugins-2.1.1]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
[root@Nagios nagios-plugins-2.1.1]# make && make install

 

四.nrpe插件安装

[root@Nagios src]# wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
[root@Nagios src]# tar zxf nrpe-2.15.tar.gz 
[root@Nagios src]# cd nrpe-2.15
[root@Nagios nrpe-2.15]# ./configure --prefix=/usr/local/nagios
[root@Nagios nrpe-2.15]# make all
[root@Nagios nrpe-2.15]# make install-plugin
[root@Nagios nrpe-2.15]# make install-daemon
[root@Nagios nrpe-2.15]# make install-daemon-config


# 测试启动
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

# 自带了启动脚本
[root@Nagios nrpe-2.15]# cp -rf init-script.in /etc/init.d/nrpe
[root@Nagios nrpe-2.15]# chmod a+x /etc/init.d/nrpe 
[root@Nagios ~]# /etc/init.d/nrpe start

 

注:其实nagios获取信息都是靠/usr/local/nagios/libexec/check_nrpe 这个脚本主动获取nrpe服务端信息

 

五.配置并启动服务

 

[root@Nagios ~]# vi /usr/local/nagios/etc/objects/contacts.cfg
define contact{
        contact_name                    nagiosadmin             
        use                             generic-contact         
        alias                           Nagios Admin            
        email                           ca0gu0@126.com 
        }

[root@Nagios ~]# vi /usr/local/nagios/etc/objects/commands.cfg        
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H "$HOSTADDRESS$" -c "$ARG1$"
}
        
[root@Nagios ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

# 检查配置文件是否正确
[root@Nagios ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

[root@Nagios ~]# chkconfig nagios on
[root@Nagios ~]# service nagios start

[root@Nagios ~]# chkconfig nrpe on
[root@Nagios ~]# /etc/init.d/nrpe start

[root@Nagios ~]# chkconfig httpd on
[root@Nagios ~]# service httpd start
[root@Nagios ~]# touch /var/www/html/index.html

 

 

 

 

 

 

 

六.配置邮件发送

[root@Nagios ~]# yum -y install mailx
[root@Nagios ~]# echo "mail test" | mail -s test ca0gu0@126.com

#如果不配置mail.rc默认会用本地postfix发送邮件
#email send tools
#nano /etc/mail.rc
#set from=s0lence@126.com smtp=smtp.126.com
#set smtp-auth-user=xx@oo smtp-auth-password=xxoo
#set smtp-auth=login

 

 

 

结束!!!!!

posted @ 2015-11-20 18:58  ca0guo  阅读(971)  评论(0编辑  收藏  举报