安装配置Nagios客户端、服务端

安装配置nagios 客户端 以及服务端 我先说下我的环境

nagios服务器:192.168.6.103

web服务器:192.168.6.100(nagios客户端)

mysql服务器:192.168.6.101 (nagios客户端)

一.Nagios 监控客户端

1.在客户端安装监控插件

useradd -s /usr/sbin/nologin nagios

tar zxvf nagios-plugins-1.4.14.tar.gz

cd nagios-plugins-1.4.14

./configure

make

make install设置插件目录权限

chown nagios.nagios /usr/local/nagios

chown -R nagios.nagios /usr/local/nagios/libexec2.安装 nrpe daemon

tar zxvf nrpe-2.12.tar.gz

cd nrpe-2.12

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config作为 xinetd 服务nrpe守护进程

make install-xinetd配置 xinetd nrpe 只能由监控服务器监控

vim /etc/xinetd.d/nrpe

only_from       = 127.0.0.1 <改为nagios服务器IP地址>添加nrpe守护进程

vim  /etc/services最后加入

nrpe      5666/tcp       #NRPE随后重启 xinetd 服务

/etc/init.d/xinetd restart3.查看服务器是否起来了

netstat -ant |grep 5666tcp        0      0 0.0.0.0:5666            0.0.0.0:*               LISTEN看到 5666 端口已经开始监听了,说明没问题

测试本地是否可以通信

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

NRPE v2.124.设置监控服务器内容

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

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

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /

command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z

command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 250 -c 300

command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20 -c 10二.在服务端安装nrpe和配置nagios 服务

1.安装nrpe

tar zxvf nrpe-2.12.tar.gz

cd nrpe-2.12

./configure

make all安装nrpe 插件

make install-plugin2.测试插件与客户端是否能正常通信

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

NRPE v2.123.创建一个check_nrpe 监控配制文件

vim /usr/local/nagios/etc/commands.cfgdefine command{

command_name check_nrpe

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

}4.修改nagios.cfg 添加一个配制文件

创建存放配置文件目录

mkdir -p /usr/local/nagios/etc/monitor修改配置文件

vim /usr/local/nagios/etc/nagios.fgcfg_dir=/usr/local/nagios/etc/monitor5.创建 主机 服务 主机组 联系人组

cd /usr/local/nagios/etc/monitora.创建hosts.Cfg

define host{

use                     linux-server

host_name               web

alias                   edgora-web

address                 192.168.6.100

}

define host{

use                     linux-server

host_name               mysql

alias                   edgora-mysql

address                 192.168.6.102

}b.创建 services.Cfg

#################  edgora   web  #####################

define service{

use                             local-service

host_name                       web

service_description             PING

check_command                   check_ping!100.0,20%!500.0,60%

}

define service{

use                             local-service

host_name                       web

service_description             SSH

check_command                   check_ssh!8022

}

define service{

use                             local-service

host_name                       web

service_description             DISK

check_command                   check_nrpe!check_hda1

define service{

use                             local-service

host_name                       web

service_description             Load

check_command                   check_nrpe!check_load

}

define service{

use                             local-service

host_name                       web

service_description             SWAP

check_command                   check_nrpe!check_swap

}

define service{

use                             local-service

host_name                       web

service_description             User

check_command                   check_nrpe!check_users

}

define service{

use                             local-service

host_name                       web

service_description             Zombie_procs

check_command                   check_nrpe!check_zombie_procs

}

define service{

use                             local-service

host_name                       web

service_description             total_procs

check_command                   check_nrpe!check_total_procs

}

##################################  MYSQL  #######################

define service{

use                             local-service

host_name                       mysql

service_description             PING

check_command                   check_ping!100.0,20%!500.0,60%

}

define service{

use                             local-service

host_name                       mysql

service_description             SSH

check_command                   check_ssh!8022

}

define service{

use                             local-service

host_name                       mysql

service_description             DISK

check_command                   check_nrpe!check_hda1

}

define service{

use                             local-service

host_name                       mysql

service_description             Load

check_command                   check_nrpe!check_load

}

define service{

use                             local-service

host_name                       mysql

service_description             User

check_command                   check_nrpe!check_users

}

define service{

use                             local-service

host_name                       mysql

service_description             Zombie_procs

check_command                   check_nrpe!check_zombie_procs

}

define service{

use                             local-service

host_name                       mysql

service_description             total_procs

check_command                   check_nrpe!check_total_procs

}

define service{

use                             local-service

host_name                       mysql

service_description             SWAP

check_command                   check_nrpe!check_swap

}c.创建主机租配制文件

vim hostgroups.Cfgdefine hostgroup {

hostgroup_name  sa-servers

alias           sa servers

members         web,mysql

}d.创建联系人组

vim contactgroup.cfgdefine contactgroup {

contactgroup_name    sagroup

alias                system administrator group

members              ludy

} 三. 测试脚本没有问题

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg四. 重启 nagios

/etc/init.d/nagios restart五. 连接web 测试

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/psdgg.html