TA的每日心情 | 难过 昨天 22:31 |
---|
签到天数: 1652 天 [LV.Master]伴坛终老
|
nagios监控linux服务器
监控端(linux主机) 被监控端(linux主机)
那么他们如何通信呢?
他们之间是通过nrpe来完成通信的。
首先客户端(被监控端)进行配置:
安装顺序:先安装插件程序,再安装nrpe程序,因为nrpe程序依赖插件程序
添加nagios用户
useradd -s /sbin/nologin nagios
安装nagios插件
tar xf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
安装nrpe程序
tar xf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
make all
make install-plugin
make install-daemon
make install-daemon-config
配置nrpe
vim /usr/local/nagios/etc/nrpe.cfg
修改allowed_hosts=192.168.10.129 (监控端的ip)
通过nrpe检测本地磁盘使用大小:
修改nrpe配置文件:
command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda2
sda1和sda2是被监控端上的磁盘。
添加nrpe服务启动脚本
vim /etc/init.d/nrped
#! /bin/bash
# chkconfig: 2345 88 12
# description: NRPE DAEMON
NRPE=/usr/local/nagios/bin/nrpe
NRPECONF=/usr/local/nagios/etc/nrpe.cfg
case "$1" in
start)
echo -n "Starting NRPE daemon..."
$NRPE -c $NRPECONF -d
echo " done."
;;
stop)
echo -n "Stopping NRPE daemon..."
pkill -u nagios nrpe
echo " done."
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: $0 start|stop|restart"
;;
esac
exit 0
再者就是启动nrpe服务
service nrped start
chkconfig nrped on
下面再安装监控端相应的程序:
nagios程序和插件程序安装完成之后,再安装nrpe程序,这里nrpe的版本号是4.0.7
tar xf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure --prefix=/service/nagios --datadir=/service/apache2.2/htdocs/nagios --sysconfdir=/service/nagios/etc --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
make all
make install-plugin
在commands.cfg里添加相应的命令,即check_nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H "$HOSTADDRESS$" -c $ARG1$
}
在/service/nagios/etc/objects/路径下单独新建一个控制linux主机(被监控端)配置文件
vim linhost.cfg
define host {
use linux-server
host_name linhost (这里的主机名称不要和其它主机名称一样,不然冲突)
alias My Linux Host
address 192.168.10.130 (被监控端的ip地址)
}
define service{
use generic-service
host_name linhost
service_description CHECK USERS
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name linhost
service_description Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name linhost
service_description CHECK sda1
check_command check_nrpe!check_sda1
}
define service{
use generic-service
host_name linhost
service_description CHECK sda2
check_command check_nrpe!check_sda2
}
define service{
use generic-service
host_name linhost
service_description Zombie
check_command check_nrpe!check_zombie_procs
}
define service{
use generic-service
host_name linhost
service_description Total procs
check_command check_nrpe!check_total_procs
}
接着在nagios主配置文件当中添加一条信息,引用linhost.cfg配置文件,加载进来
vim /service/nagios/etc/nagios.cfg
cfg_file=/service/nagios/etc/objects/linhost.cfg (添加的信息)
最后在检查nagios配置文件语法对错:
/service/nagios/bin/nagios -v /etc/nagios/nagios.cfg
没出错,就重启nagios服务
service nagios restart
验证:
相关文章:nagios安装配置
|
|