nagios_server和client(nagios监控)
网上找了一些资料,结合自己搭建总结的文章,希望对需要的朋友有帮助!
创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、网站制作、外贸营销网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的融水网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
实验环境配置
1、 环境搭建
Server: nagios nagios-plugins nrpe
工作站:nagios-plugins nrpe
检查一下包的安装情况
# rpm -q httpd gcc glibc glibc-common gd gd-devel
#yum -y httpd gcc glibc glibc-common gd gd-devel
-----------------------------------------------------
在server 端配置
1、安装nagios
#tar zxvf tar zxvf nagios-3.2.1.tar.gz
#cd nagios-3.2.1
#./configure --prefix=/usr/local/nagios --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include
#make all
#make install
#make install-init
#make install-config
#make install-commandmode
#make install-webconf //可以自动安装在httpd.conf中的配置,生成nagios.conf;
2、安装nagios-plugins
#tar zxvf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#make
#make install
3、安装nrpe
#tar zxvf nagios-nrpe_2.8.1.orig.tar.gz
#cd nrpe-2.8.1
#./configure --enable-ssl --with-ssl-lib=/lib/
#rpm -qa | grep ssl 保证:能够抓到 前两个
openssl-0.9.8e-12.el5
openssl-devel-0.9.8e-12.el5
openssl-perl-0.9.8e-12.el5
#make all
#make install-plugin
4、vim 编辑commands.cfg文件定义nrpe对的使用
#vim /usr/local/nagios/etc/objects/commands.cfg
//添加如下几行使支持check_nrep
#check_nrep
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
5、配置监控对象(工作站及其服务等)
#vim /usr/local/nagios/etc/nagios.cfg
//在losthost.cfg下添加
cfg_file=/usr/local/nagios/etc/objects/linux.cfg
6、新建linux.cfg设置要监控的内容
#vim /usr/local/nagios/etc/object/linux.cfg
define host{
use linux-server
host_name mylinux //需要修改工作站的主机名
alias mylinux
address 192.168.0.44 //工作站主机IP
}
define service{
use generic-service
host_name mylinux
service_description check-swap //对下面操作的描述
check_command check_nrpe!check_swap //执行检测交换分区命令,监控swap
}
define service{
use generic-service
host_name mylinux
service_description check-load
check_command check_nrpe!check_load //监控负载
}
define service{
use generic-service
host_name mylinux
service_description check-disk
check_command check_nrpe!check_had1 //监控硬盘
}
define service{
use generic-service
host_name mylinux
service_description check-users
check_command check_nrpe!check_users //监控用户(使用)情况
}
define service{
use generic-service
host_name mylinux
service_description otal_procs
check_command check_nrpe!check_total_procs //监控进程
}
//对以上的linux.cfg文件编辑如果有错,将会导致nagios无法启动;
//修改工作站主机的主机名为mylinux,保证能够#ping mylinux 通信正常,可以选择
#echo "192.168.0.44 mylinux " >> /etc/hosts
#echo"192.168.0.15 nagios " >> /etc/hosts
//在服务器端
#echo"192.168.0.15 nagios " >> /etc/hosts
#echo "192.168.0.44 mylinux " >> /etc/hosts
7、准备启动nagios服务
#setenforce 0 保证selinux处于关闭状态
#service iptables stop 或者开放80,5666端口(http/nrep)
#chkconfig --add nagios //添加nagios服务到系统服务队列
#chkconfig nagios on //开机自动启动服务
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
//检查nagios的配置文件的正确性
//如果上面有错误,请检查系统服务时间是否同步,新建的linux.cfg是否有语法错误!
//在commands.cfg是否添加对nrep使用等
//保证上述命令争取执行
// 参考:
//Total Warnings: 0
//Total Errors: 0
#service nagios start
3、配置工作站上的nagios-plugin/nrpe等
1、安装nagios-plugin
#useradd nagios
#passwd nagios
#tar -zxvf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#make
#make install
2、改变目录权限使nagios用户能够访问
#chown –R nagios.nagios /usr/local/nagios
3、安装nrpe服务使之能够通信
#tar zxvf nagios-nrpe_2.8.1.orig.tar.gz
#cd nagios-nrpe_2.8.1
#./configure --enable-ssl --with-ssl-lib=/usr/lib/
#make all
#make install-plugin
#make install-daemon
#make install-daemon-config
4、配置nrpe信息
#vim /usr/local/nagios/etc/nrpe.cfg
allowed_host=192.168.0.15,127.0.0.1 //允许192.168.0.15服务器端对其监控
#/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d
//检测nrep配置文件的正确性
#netstat -an | grep 5666 //是否监听5666用于nrpe通信的端口
//在服务端执行检测工作站nrpe信息
#/usr/local/nagios/libexec/check_nrpe -H 192.168.0.44
NRPE v2.8.1
//在工作站执行检测自己的nrpe信息
#/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v2.8.1
5、配置工作站上的被检测上网信息
#vim/usr/local/nagios/etc/nrpe.cfg
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 /dev/hda1
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 150 -c 200
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
分享题目:nagios_server和client(nagios监控)
网站URL:http://azwzsj.com/article/peocjp.html