linux nagios 监控,Nagios 监控 Linux 主机

1. 在需要被监控的linux 主机上创建nagios用户

su -l

/usr/sbin/useradd nagios

passwd nagios

2. 下载安装nagios-plugins

链接:

tar xzf nagios-plugins-1.4.13.tar.gz

cd nagios-plugins-1.4.13

Compile and install the plugins.

./configure

make

make install

需要设置下相关权限:

chown nagios.nagios /usr/local/nagios

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

3. 安装NRPE服务

链接:

tar xzf nrpe-2.8.tar.gz

cd nrpe-2.8

Compile the NRPE addon.

./configure

如果出现如下错误:checking for SSL headers... configure: error: Cannot find ssl headers

请安装openssl-devel包即可!

make all

Install the NRPE plugin (for testing), daemon, and sample daemon config file.

make install-plugin

make install-daemon

make install-daemon-config

Install the NRPE daemon as a service under xinetd.

make install-xinetd

编辑/etc/xinetd.d/nrpe添加Nagios服务器端的的地址到only_from.

only_from       = 172.18.127.48

添加nrpe服务端口到/etc/services中.

nrpe            5666/tcp # NRPE

重启nrpe服务

Restart the xinetd service.

service xinetd restart

测试端口是否有正常监听

# netstat -at |grep nrpe

tcp        0      0 *:nrpe                      *:*                         LISTEN

# netstat -ant |grep :5666

tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN

检测NRPE服务是否有正常工作,此处需要only_from=127.0.0.1,才能测试通过

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

You should get a string back that tells you what version of NRPE is installed, like this:

NRPE v2.8

4. 自定义NRPE命令

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

这里先使用默认的一些设置

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_users

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_load

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_hda1

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_zombie_procs

5. 服务器端设置

服务器端安装NRPE,就是用先前的包即可

tar xzf nrpe-2.8.tar.gz

cd nrpe-2.8

Compile the NRPE addon.

./configure

make all

Install the NRPE plugin.

make install-plugin

不需要安装daemon可daemon的配置了

测试下与客户端NRPE daemon的通讯

/usr/local/nagios/libexec/check_nrpe -H xxx.xxxx.xxx.xxx(客户端的地址)

这里测试时,要确定客户机的only_from已经从127.0.0.1改为了服务器端的IP地址

否则,SSL是过不去的!

6. 定义服务器端配置

定义command:

vi /usr/local/nagios/objects/command.cfg

加入以下行:

define command{

command_name    check_nrpe

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

}

定义配置文件中的host及service

vi /usr/local/nagios/objects/localhost.cfg

增加host定义:

define host{

use                     linux-server

host_name               winbak

alias                   winbak

address                 172.18.127.163

check_command           check-host-alive

max_check_attempts      10

notification_interval   120

notification_period     24x7

notification_options    d,r

contact_groups  admins

}

增加service定义:

define service{

use                             local-service

host_name                       winbak

service_description             CPU Load

check_command                   check_nrpe!check_load

}

define service{

use                             local-service

host_name                       winbak

service_description             Current Users

check_command                   check_nrpe!check_users

}

define service{

use                             local-service

host_name                       winbak

service_description             Total Processes

check_command                   check_nrpe!check_total_procs

}

define service{

use                             local-service

host_name                       winbak

service_description             Zombie Processes

check_command                   check_nrpe!check_zombie_procs

}

重启nagios

service nagios restart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值