nagios安装

操作系统centos5.5 64

参考官方安装文档

http://assets.nagios.com/downloads/nagioscore/docs/Installing_Nagios_Core_From_Source.pdf


1.下载安装包nagios-3.5.0.tar.gz nagios-plugins-1.4.16.tar.gz

2.配置yum

3.yum install httpd php gcc glibcglibc-common gd gd-devel make net-snmp

4.useradd nagios

groupadd nagcmd

usermod -a -G nagcmd nagios

5.yum install openssl openssl-devel

6.tar -zxf nagios-3.5.0.tar.gz

tar -zxf nagios-plugins-1.4.16.tar.gz

7.cd nagios

8../configure--with-command -group=nagcmd

make all

make install

make install-init

make install-config

make install-commandmode

make install-webconf

9.cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/

10.chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers/

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

12./etc/init.d/nagios start

13./etc/init.d/httpd start

14.vim /etc/httpd/conf/httpd.conf

User nagios

Group nagios

ServerName 192.168.1.2 #本机IP

15./etc/init.d/httpd restart

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

17.cd nagios-plugins-1.4.16

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

make && make install

19./etc/init.d/iptables stop

20.setenforce 0

21.登陆地址:http://192.168.1.2/nagios/

用户名/密码:nagiosadmin/nagios

IP为安装nagios机器IP,密码是用htpasswd生成的密码


安装nrpe监控远程

在被监控的主机上操作

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

tar -zxf nrpe-2.14.tar.gz

2.yum install gcc

3.yum install opensslopenssl-devel

4.useradd nagios

5.mkdir /usr/local/nagios

6.cd nagios-plugins-1.4.16

7. ./configure--prefix=/usr/local/nagios/

make

make install

8.cd nrpe-2.14

9../configure --prefix=/usr/local/nagios/

make all

make install-plugin

make install-daemon

make install-daemon-config

make install-xinetd

make install

10.vim /etc/xinetd.d/nrpe

only_from = 127.0.0.1 192.168.1.2 #监控机器IP

11.vim /etc/services 添加

nrpe 5666/tcp

12./etc/init.d/xinetd restart

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

13.在本机验证nrpe是否安装成功

[root@tvie3etc]# /usr/local/nagios/libexec/check_nrpe -H localhost

NRPE v2.14

14.check_nrpe传到监控机器上

scp check_nrpe [email protected]:/usr/local/nagios/libexec/

15.vim /usr/local/nagios/etc/nrpe.cfg

allowed_hosts=127.0.0.1,192.168.1.2

16./etc/init.d/iptables stop

17.setenforce 0

在监控机器上执行

18.验证nrpe是否正常工作

[root@tvie2etc]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.3 -c check_load

OK - loadaverage: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0;load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0;

19.定义nrpe命令

vim /usr/local/nagios/etc/objects/commands.cfg

define command{

command_name check_nrpe

command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c$ARG1$

}

20.新添加一台被监控的主机,并加入到组中

vim /usr/local/nagios/etc/objects/localhost.cfg

define host{

use linux-server

host_name 192.168.1.3

alias 192.168.1.3

address 192.168.1.3

}

define hostgroup{

hostgroup_name linux-servers

alias Linux Servers

members localhost,192.168.1.3

}


21.为添加的主机添加被监控的服务

vim /usr/local/nagios/etc/objects/localhost.cfg

define service{

use local-service

host_name 192.168.1.3

service_description load

check_command check_nrpe!check_load

notifications_enabled 0

}


define service{

use local-service

host_name 192.168.1.3

service_description Total_procs

check_command check_nrpe!check_total_procs

notifications_enabled 0

}

22./etc/init.d/nagios restart

23.web页面观看效果

164609226.png



你可能感兴趣的:(安装,nagios)