nagios与zorka是如何协作的
来自:网络
*简介:Nagios是一款开源的免费网络监视工具,Zorka增加了与nagios连接的NRPE协议和基本的bsh配置文件。
我在之前的博客(fliguo/article/details/45367043)详细介绍了如何配置zorka对tomcat的监控 nagios培训
在此基础上我们配置nagios,使之与zorka协同运行。
官网([ ttp://www. /download]http://www. /download)下载Nagios core和Nagios plugins
这里([ ttp://exchange. /directory/Addons/Monitoring-Agents/NRPE--2D-Nagios-Remote-Plugin-Executor/details]http://exchange. /direc ... in-Executor/details)下载NRPE插件
被监控端zorka配置,启动tomcat:添加至nagios配置项到zorka.properties:
?
1
2
3
4
5
# nagios setting
nagios = yes
nagios.listen.addr = 202.117.10.234
nagios.listen.port = 5669
nagios.server.addr = 192.168.60.129
监控主机端Ubuntu 15.04下配置nagios:环境配置:?
1
2
3
4
5
6
7
8
9
10
11
apt-get install apache2 php5 libssl0.9.8 libssl-dev openssl libgd2-xpm-dev apache2-utils mailx openssl libssl-dev
useradd -m nagios
passwd nagios
usermod -G nagios nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd www-data
mkdir /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios
ll -d /usr/local/nagios/
测试php安装成功:
?
1
2
3
4
gedit var/www/phpindex.php
<?php
phpinfo();
?>
解压nagios,编译安装:? nagios实施
1
2
3
4
5
6
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
安装Nagios的WEB配置文件
?
1
2
3
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf-enabled/nagios.conf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service apache2 restart
安装Nagios 插件
?
1
2
3
cd ../nagios-plugins-2.0.3
./configure --prefix=/usr/local/nagios
make && make install
开启apache对cgi的支持:
?
1
ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load
设置启动Nagios的服务:?
1
2
3
4
<pre name="code" class="plain">ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
(这里也可以用service nagios start或者 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg)
访问 http://localhost/nagios/就可以得到结果 监控软件 -u nagiosadmin
-p yourpassword
这是可以访问nagios,查看预定义的对本机监控的结果了。
uploads/img/201505/25104645_gwVc.jpg
编译安装活动监控代理NRPE:安装NRPE后nagios定时查询将有NRPE代理
?
1
2
3
./configure -prefix=/usr/local/nagios -with-ssl-inc=/usr/include -with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all
make install-plugin
测试连接:?
1
/usr/local/nagios/libexec/check_nrpe-n -H 202.117.54.248 -p 5669 -c 'nagios.cmd["MEM_POOL"]'
uploads/img/201505/25104645_vFsP.jpg
nagios配置完成后添加host,command, service,指定被监控的主机地址以及相关属性信息:
?
1
2
3
4
5
6
7
8
9
10
11
12
gedit /usr/local/nagios/etc/objects/hosts.cfg
define host{
use linux-server
host_name Nagios-Linux
alias Nagios-Linux
address 192.168.60.134 #被监控的主机地址,这个地址可以是ip,也可以是域名。
}
define hostgroup{
hostgroup_name zorka-servers
alias zorka servers
members Nagios-Linux
}
指定NRPE发送的命令格式: nagios配置 ?
1
2
3
4
5
6
gedit /usr/local/nagios/etc/objects/commands.cfg
# 'check_zorka' command definition
define command{
command_name check_zorka
command_line $USER1$/check_nrpe -n -H $HOSTADDRESS$ -p 5669 -c 'nagios.cmd["$ARG1$"]'
}
添加监控的service,这里以监控内存为例:
?
1
2
3
4
5
6
7
gedit /usr/local/nagios/etc/objects/services.cfg
define service{
use local-service
host_name Nagios-Linux
service_description Check Memory
check_command check_zorka!MEM_POOL
}
将配置文件包含在nagios配置文件中,重新加载nagios配置文件: 开源监控软件
?
1
2
3
4
gedit /usr/local/nagios/etc/nagios.cfg
# nrpe remote host monitoring
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
重新加载nagios:? nagios安装
1
service nagios reload
转至 nagios/ ,点击services
uploads/img/201505/25104645_312U.jpg
uploads/img/201505/25104645_73ct.jpg
想做Nagios, Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流QQ群号 :476809427
页:
[1]