CentOS 6.7 安装Nagios教程

make install-webconf

[root@Nagios ~]# cd /usr/local/src
[root@Nagios src]# wget

[root@Nagios src]# wget

[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

3.
useradd nagios; passwd nagios

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

图片 1

启动xinetd

make install

[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

ss
-an | grep 5666

vi /etc/xinetd.d/nrpe

一.安装依赖包

 

65.  查看认证文件的内容

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

nrpe
5666/tcp # NRPE

Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’
for update!

[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

首先是远程被监控主机的操作

Wget

二.nagios的安装

21.
设置Nagios开机自启动

(1)/usr/local/nagios/etc/nrpe.cfg
此配置文件是配置正确,多个IP地址逗号隔开,且要注意空格:allowed_host=127.0.0.1, 
192.168.0.1 这是不对的,必须是allowed_host=127.0.0.1,192.168.1.202 
逗号之后不能有空格;

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

  1. tar
    xvfz nrpe-2.13.tar.gz

  2. cd
    nrpe-2.13

  3. ./configure

cd nagios-4.0.7

[root@Nagios src]# wget

[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

假设我的监控主机ip是192.168.122.3,远程被监控主机是192.168.122.14.两个系统都是CentOS6.3系统。首先介绍监控本地主机。这部分很简单,可以参考Nagios
官方指导文档http://nagios.sourceforge.net/docs/3_0/quickstart-[Fedora](https://www.linuxidc.com/topicnews.aspx?tid=5).html,下面我只写操作命令,不多赘述了。

passwd nagios

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

command[check_load]=/usr/local/nagios/libexec/check_load
-w 15,10,5 -c 30,25,20

图片 2

#如果不配置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

  1. wget

  2. wget

Chkconfig nagios on 或者chkconfig –level 35 nagios on

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

更改
/usr/local/nagios/etc/nrpe.cfg
nrpe.cfg文件里包含需要监控远程主机的命令,如:

date -s 调整日期时间  clock -w 保存

# 自带了启动脚本
[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

  1. /usr/local/nagios/libexec/check_nrpe
    -H localhost

  2. NRPE
    v2.13

这个安装* * /usr/local/nagios/etc配置文件示例

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

  1. chown
    -R nagios.nagios /usr/local/nagios/libexec/

  目录的外部命令文件

CentOS 6.7
安装Nagios教程

参考文档:

在/etc/services结尾增加

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
(检测配置文件是否有错误)

四.nrpe插件安装

service
xinetd restart

二、创建web用户

————————————–分割线

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

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

图片 3

 

二、添加监控节点及service

[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
        }

添加nagios
帐号

四、关闭防火墙和selinux

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

23.
如果没有,就启动nagios

(nagcmd:x:504:nagios)

三.nagios plugins的安装

/usr/local/nagios/bin/nagios
-v /usr/local/nagios/etc/nagios.cfg

Chkconfig httpd on 或者 chkconfig –level 35 httpd on

[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-plugin

Passwd nagios

[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

chkconfig nagios on

pkill nrpe;

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

安装nrpe

/etc/init.d/nagios start 或者service nagios start

六.配置邮件发送

22
测试配置文件是否有错误

Chkconfig httpd on

————————————–分割线

在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

下面是介绍使用nrpe监控远程主机

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

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

测试nrpe是否正常工作

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

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

 

only_from 增加主控IP

图片 4

only_from
= 127.0.0.1 192.168.122.3

Make

五.配置并启动服务

service nagios start

*********************************2***************************************************

验证nrpe是否监听

  使用Nagios。阅读HTML文档

图片 5

Useradd nagios

1.  tar
    xzf nagios-plugins-1.4.16.tar.gz

2.  cd
    nagios-plugins-1.4.16

3.  ./configure
    --with-nagios-user=nagios --with-nagios-group=nagios

4.  make

5.  make
    install

Cd nagios-plugins-2.0.3

 

******无法开题notifications报错****************************************

  1. yum
    -y install httpd httpd-devel php openssl-devel gcc glibc
    glibc-common gd gd-devel

  2. /usr/sbin/useradd
    -m nagios

  3. /usr/sbin/groupadd
    nagcmd

  4. /usr/sbin/usermod
    -a -G nagcmd nagios

  5. /usr/sbin/usermod
    -a -G nagcmd apache

  6. wget
    http://iweb.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.1/nagios-3.4.1.tar.gz

  7. wget http://iweb.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz

  8. tar
    xzf
    nagios-3.4.1.tar.gz

  9. cd
    nagios

  10. ./configure
    –with-command-group=nagcmd

  11. make
    all

  12. make
    install

  13. make
    install-init

  14. make
    install-config

  15. make
    install-commandmode

  16. vi
    /usr/local/nagios/etc/objects/contacts.cfg
    修改你的email地址

  17. make
    install-webconf

  18. 为登录Nagios
    Web接口创建nagiosadmin帐号。记住下面你设置的密码,之后登录用到
    htpasswd
    -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

  19. service
    httpd restart

  20. 安装Nagios插件

Wget

command[check_users]=/usr/local/nagios/libexec/check_users
-w 5 -c 10

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

  1. make
    all

  2. make
    install-plugin

  3. make
    install-daemon

  4. make
    install-daemon-config

  5. yum
    install xinetd

  6. make
    install-xinetd

./configure

更改/etc/xinetd.d/nrpe文件,设置允许nagios服务器连接,如nagios服务器的ip为192.168.122.3

Make

chkconfig –add nagios

Make install

  1. tar
    xvfz nagios-plugins-1.4.16.tar.gz

  2. cd
    nagios-plugins-1.4.16

  3. export
    LDFLAGS=-ldl

     

  4. ./configure
    –with-nagios-user=nagios –with-nagios-group=nagios
    –enable-RedHat-pthread-workaround

  5. make

  6. make
    install

     

  7. chown
    nagios.nagios /usr/local/nagios

把check_nrpe放到/usr/local/nagios/libex下。才能使用check_nrpe。

make install-daemon-config

make install-init

(2)检查是否配置里限制了,在 /etc/xinetd.d/nrpe
文件中要添加允许访问的服务器的IP地址,在 “only_from = ” 这一行添加,
多个IP地址用空格隔开,例如:only_from      = 192.168.0.8 192.168.1.202

Make install

Nagios-plugins安装.

chkconfig xinetd on

make install-plugin

写这个文档的目的,就是为了方便
快捷的部署Nagios,涉及到个人喜好的配置,大家自行修改,可以套用。

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg  -d

发表评论

电子邮件地址不会被公开。 必填项已用*标注