背景:
阅读新闻
Nagios本机及其他主机监控安装部署详解
[日期:2017-03-09] 来源:Linux社区 作者:firelowrie [字体:]
3.远程监控服务端2的根分区和用户数
A)安装nagios插件及nrpe
服务端2
[root@server2 mnt]# ls
nagios-plugins-2.1.1.tar.gz nrpe-2.15.tar.gz
[root@server2 mnt]# tar zxf nagios-plugins-2.1.1.tar.gz #解压plugins插件
[root@server2 mnt]# cd nagios-plugins-2.1.1
[root@server2 nagios-plugins-2.1.1]# ./configure
[root@server2 nagios-plugins-2.1.1]# make
[root@server2 nagios-plugins-2.1.1]# make install
[root@server2 mnt]# cd /usr/local/nagios/
[root@server2 nagios]# ls
include libexec share
[root@server2 nagios]# useradd -u 1001 nagios #创建nagios用户
[root@server2 nagios]# chown nagios.nagios * -R #修改文件权限
[root@server2 nagios]# ll #查看
total 12
drwxr-xr-x 2 nagios nagios 4096 Oct 23 10:50 include
drwxr-xr-x 2 nagios nagios 4096 Oct 23 10:50 libexec
drwxr-xr-x 3 nagios nagios 4096 Oct 23 10:50 share
[root@server2 libexec]# cd /mnt/
[root@server2 mnt]# tar zxf nrpe-2.15.tar.gz #解压nrpe
[root@server2 mnt]# cd nrpe-2.15
[root@server2 nrpe-2.15]# ./configure #配置
[root@server2 nrpe-2.15]# make all
[root@server2 nrpe-2.15]# make install-plugin
[root@server2 nrpe-2.15]# make install-daemon
[root@server2 nrpe-2.15]# make install-daemon-config
[root@server2 nrpe-2.15]# yum install -y xinetd
[root@server2 nrpe-2.15]# make install-xinetd
[root@server2 nrpe-2.15]# vim /etc/services #添加nrpe的端口
nrpe 5666/tcp
[root@server2 nrpe-2.15]# cd /etc/xinetd.d/
[root@server2 xinetd.d]# vim nrpe #进入配置文件
15 only_from = 172.25.25.1 #允许172.25.25.1监听
[root@server2 etc]# cd /usr/local/nagios/etc/
[root@server2 etc]# ls
nrpe.cfg
[root@server2 etc]# vim nrpe.cfg #修改命令
221 command[check_disk]=/usr/local/nagios/libexec/check_disk -w20% -c 10% -p /
[root@server2 etc]# cd ..
[root@server2 nagios]# ls
bin etc include libexec share
[root@server2 nagios]# cd libexec/
[root@server2 libexec]# ./check_disk -w 20% -c 10% -p / #测试
DISK OK - free space: / 6222 MB (85% inode=93%);|/=1057MB;6135;6902;0;7669
[root@server2 libexec]# /etc/init.d/xinetd start #开启xinetd
Starting xinetd: [ OK ]
[root@server2 libexec]# netstat -antple |grep 5666 #查看端口,开启
tcp 0 0 :::5666 :::* LISTEN 0 23552 23120/xinetd
[root@server2 libexec]# scp check_nrpe172.25.25.1:/usr/local/nagios/libexec/
root@172.25.25.1's password: #将nrpe传给服务端1
check_nrpe 100% 75KB 75.0KB/s 00:00
B) 将根分区和用户数(服务端2)添加到nagios(服务端1)
服务端1
[root@server1 libexec]# pwd
/usr/local/nagios/libexec
[root@server1 libexec]# chown nagios.nagios check_nrpe #修改权限
[root@server1 libexec]# ./check_nrpe -H 172.25.25.2 #测试
NRPE v2.15
[root@server1 libexec]# cd ..
[root@server1 nagios]# cd etc/objects/
[root@server1 objects]# vim services.cfg #添加服务
####################check_nrpe#######################
define service{
use local-service
host_name server2.example.com
service_description 根分区
check_command check_nrpe!check_disk
}
define service{
use local-service
host_name server2.example.com
service_description 登录用户数
check_command check_nrpe!check_users
}
[root@server1 objects]# vim commands.cfg #添加命令
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c$ARG1$
}
[root@server1 objects]# /usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during thepre-flight check
[root@server1 objects]# /etc/init.d/nagios reload #刷新
C)测试
相关资讯 Nagios监控
本文评论 查看全部评论 (0)
尊重网上道德,遵守中华人民共和国的各项有关法律法规 承担一切因您的行为而直接或间接导致的民事或刑事法律责任 本站管理人员有权保留或删除其管辖留言中的任意内容 本站有权在网站内转载或引用您的评论 参与本评论即表明您已经阅读并接受上述条款
评论声明
最新资讯