码迷,mamicode.com
首页 > 移动开发 > 详细

Nagios+NSClient+nrpe环境搭建

时间:2017-06-23 10:40:35      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:nagios   nginx   zabbix   nrpe   nsclient   

Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设备,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。

NSClient:Windows 7监控插件

NRPE是监控软件nagios的一个扩展,它被用于被监控的服务器上,向nagios监控平台提供该服务器的一些本地的情况。例如,cpu负载、内存使用、硬盘使用等等。NRPE可以称为nagios的for linux 客户端。



1.安装软件:

yum install -y gcc*

yum install -y httpd mysql mysql-server mysql-devel php php-mysql glibc glibc-common *gd*


2.添加用户:

技术分享


3.编译安装nagios:

此次安装使用的软件包是 nagios.iso

技术分享

tar -xvf nagios-3.3.1.tar.gz -C /root/

然后进入nagios目录下

./configure --with-command-group=nagcmd --enable-event-broker

make all

make install

make install-init

make install-commandmode

make install-config

make install-webconf


4.生成密码配置文件:

技术分享

技术分享


开启Apache服务

5.浏览器查看:

技术分享

技术分享


6.安装插件管理器nagios-plugins:

tar -xvf nagios-plugins-1.4.14.tar.gz -C /root/

进入目录编译安装(nagios-plugins-1.4.14)

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql  --enable-perl-modules

make && make install

技术分享

检查配置文件是否有错误:

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

技术分享


重启nagios服务

此时再去浏览器检查:

技术分享



Windows主机的监控:

7.Windows安装NSClient:

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享


服务器设置监控Windows:

技术分享

技术分享

技术分享


检测并重新启动nagios

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

service nagios restart

浏览器再查看:

技术分享


Linux客户机监控:


8.Linux客户端的监控:

在Linux客户的上面:

安装环境支持:

yum install -y gcc* openssl openssl-devel

编译安装nagios-plugins

tar -xvf nagios-plugins-1.4.14.tar.gz

需要创建用户

useradd nagios

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

make all

make install

编译安装nrpe-2.8.1.tar.gz

./configure --enable-ssl --with-ssl-lib=/usr/lib

技术分享

技术分享

技术分享


回到服务器端:

安装nagios-plugins(已安装)

安装nrpe

tar -xvf nrpe-2.8.1.tar.gz -C /root/

./configure --enable-ssl --with-ssl-lib=/usr/lib

make all

make install-plugin

不用启用daemon和daemon-config

技术分享

define host{

use linux-server

host_name nagios

address 192.168.115.174

}

define service{

use generic-service

host_name nagios

service_description check-load

check_command check_nrpe!check_load

}

define service{

use generic-service

host_name nagios

service_description check-users

check_command check_nrpe!check_users

}

技术分享

技术分享


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

service nagios restart

再检查浏览器:

技术分享


9.服务的监控:

Linux客户端:

安装软件:

yum install -y mysql mysql-server

service mysqld start

mysqladmin -uroot password ‘123456’

技术分享


服务器端:

测试连接:

/usr/local/nagios/libexec/check_mysql -H 192.168.115.174 -u nagios -d nagios -p 123456

技术分享

技术分享

define host{

use linux-server

host_name Mysql

address 192.168.115.174

}

define service{

host_name Mysql

check_period 24x7

max_check_attempts 2

normal_check_interval 1

retry_check_interval 1

contact_groups admins

notification_interval 5

notification_period 24x7

notification_options w,u,c,r

check_command check_mysql

}技术分享

技术分享

技术分享


service nagios restart

技术分享

本文出自 “Change life Start fresh.” 博客,请务必保留此出处http://ahcwy.blog.51cto.com/9853317/1941079

Nagios+NSClient+nrpe环境搭建

标签:nagios   nginx   zabbix   nrpe   nsclient   

原文地址:http://ahcwy.blog.51cto.com/9853317/1941079

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!