你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS 6.7 安装Nagios教程

[日期:2015-11-23] 来源:Linux社区  作者:caoguo [字体: ]

CentOS 6.7 安装Nagios教程
参考文档:https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart-Fedora.html

一.安装依赖包

[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

--------------------------------------分割线 --------------------------------------

Ubuntu下配置Mrtg监控Nginx和服务器系统资源 http://www.linuxidc.com/Linux/2013-08/88417.htm

使用 snmp+Mrtg 监控 Linux 系统 http://www.linuxidc.com/Linux/2012-11/73561.htm

Mrtg服务器搭建(监控网络流量) http://www.linuxidc.com/Linux/2012-07/64315.htm

网络监控器Nagios全攻略 http://www.linuxidc.com/Linux/2013-07/87067.htm

Nagios搭建与配置详解 http://www.linuxidc.com/Linux/2013-05/84848.htm

Nginx环境下构建Nagios监控平台 http://www.linuxidc.com/Linux/2011-07/38112.htm

在RHEL5.3上配置基本的Nagios系统(使用Nagios-3.1.2) http://www.linuxidc.com/Linux/2011-07/38129.htm

CentOS 5.5+Nginx+Nagios监控端和被控端安装配置指南 http://www.linuxidc.com/Linux/2011-09/44018.htm

Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用 http://www.linuxidc.com/Linux/2013-11/93047.htm

--------------------------------------分割线 --------------------------------------

Nagios 的详细介绍请点这里
Nagios 的下载地址请点这里

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-11/125427.htm

linux
相关资讯       Nagios  CentOS 6.7 安装Nagios 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款