CentOS 6.5下快速安装编译配置Nagios文档


CentOS 6.5下快速安装编译配置Nagios文档-全部虚拟环境。

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

网络监控器Nagios全攻略

Nagios搭建与配置详解

Nginx环境下构建Nagios监控平台

在RHEL5.3上配置基本的Nagios系统(使用Nagios-3.1.2)

CentOS 5.5+Nginx+Nagios监控端和被控端安装配置指南

Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用

一、下载并安装所需软件

1,yum install gcc mysql httpd php gd openssl openssl-devel mysql-server vim wget

Wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.7.tar.gz

Wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

Wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

Ls 可以看到nagios-4.0.7.tar.gz nagios-plugins-2.0.3.tar.gz nrpe-2.14.tar.gz

yum install wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

useradd nagios

passwd nagios

groupadd nagcmd

usermod –a –G nagcmd nagios

(nagcmd:x:504:nagios)

tar –xvzf nagios-4.0.7.tar.gz

cd nagios-4.0.7

./configure –with-command-group=nagcmd

可以先./configure –help先看看帮助,应为默认为主是用nagios用户,不需要指定—with-nagios-user或其它什么的。

make all

make install

make install-init

这个安装/etc/rc.d/init.d中的init脚本

make install-commandmode

这个安装和配置权限

  目录的外部命令文件

make install-config

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

  你必须修改这些示例文件之前

  使用Nagios。阅读HTML文档

make install-webconf

 这个安装Nagios的Apache配置文件

  Web界面

Cp –R contrib/eventhandlers/ /usr/local/nagios/libexec/

(-R:递归复制目录,即连同目录下的子目录和文件一起复制。)

Chown –R nagios:nagios /usr/local/nagios/libexec/eventhandlers

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

{ [root@Nagios libexec]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers/

[root@Nagios libexec]# ll

total 4

drwxr-xr-x. 4 nagios nagios 4096 Oct 21 01:16 eventhandlers}

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

Chkconfig --add nagios

Chkconfig nagios on

Chkconfig httpd on

Service httpd start

二、创建web用户

切换到ngios用户

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

输入密码nagios

三、安装nagios-plugins

Tar –xvzf 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

前面这步做了可以略过,反正要做一次。

Chkconfig nagios on 或者chkconfig –level 35 nagios on

Chkconfig httpd on 或者 chkconfig –level 35 httpd on

四、关闭防火墙和selinux

service iptables stop

Vim /etc/sysconfig/selinux 把selinux改成disabled这个需重启生效。

http://192.168.1.202/nagios/ 这个是nagios地址,要输入用户名和密码的nagiosadmin nagios

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

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

这个主要是apache 用户 没有执行权限 /usr/local/nagios/var/rw/nagios.cmd 造成,

解决方法:

usermod -a -G nagcmd apache

将apache用户添加到nagios用户组,就OK了。

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

五、安装NRPE插件。

Tar –xvzf nrpe-2.14.tar.gz

Cd nrpe-2.14

./configure

make && make install

make install-plugin

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

***********************************************************************************

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

在被监控机器上安装。

Nagios-plugins安装.

Useradd nagios

Passwd nagios

Tar –xvzf nagios-plugins-2.0.3.tar.gz

Cd nagios-plugins

./configure

Make

Make install

Chown –R nagios:nagios /usr/local/nagios

安装nrpe-2.14

Tar –xvzf nrpe-2.14.tar.gz

Cd nrpe-2.14

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

yum install xinetd

chkconfig --add xinetd

chkconfig xinetd on

make install-xinetd

vim /etc/xinetd.d/nrpe

在该文件的only_from  = 127.0.0.1 192.168.1.107  //在后面增加监控主机的地址,以空格间隔

vim /usr/local/nagios/etc/nrpe.cfg 这里也是充许访问里添加 192.168.107

vim /etc/services

启动nrpe就好了。

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

service xinetd restart

netstat -at |grep nrpe

Netstat –an | grep 5666

Vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT (该语句有待,不过我另一台也是这样配的)

好像不添加上面这个不得行,会报check_nrpe:Error - Could not complete SSL handshake

运行ipables –F 清空一下规则,然后保存。

然后iptables –L –n 查看确认后。

Service iptables save

Service iptables restart

2、配置文件方面:

(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  逗号之后不能有空格;

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

被控端:

vi /etc/xinetd.d/nrpe

only_from 增加主控IP

vi /usr/local/nagios/etc/nrpe.cfg

allowed_hosts 增加主控IP

service xinetd restart

主控端:

/usr/local/nagios/libexec/check_nrpe -H 被监控端IP地址      测试是否连接成功

修改nrpe.cfg后一定要重启nrpe,大侠我是这样做的:

pkill nrpe;

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

二、添加监控节点及service

三】增加验证用户

也就是通过web访问nagios的时候,必须要用这个用户登陆.在这里我们增加用户test:密码为12345

64.  [root@localhost nagios-plugins-1.4.13]# htpasswd -c /usr/local/nagios/etc/htpasswd test

可以用 which命令查看 htpasswd命令的位置,如果是源码安装的apache这里就写htpasswd的全路径。用户是test,命令结束会提示你输入密码,这里输入123456即可。

65.  查看认证文件的内容

66.  [root@localhost nagios-plugins-1.4.13]# less /usr/local/nagios/etc/htpasswd

67.  到这里nagios的安装也就基本完成了,你可以通过web来访问了.

更多详情见请继续阅读下一页的精彩内容:

  • 1
  • 2
  • 下一页

相关内容