nagios监控redis和rabbitmq

安装使用nagios后,初始对相关的服务器相关参数进行了监控,包括对磁盘、内存、CPU和网络等,在项目中也使用了redis/rabbitmq等中间件,因此学习汇总相关线上资料,并进行实践操作安装配置完成对redis和rabbitmq的监控,于此对过程进行汇总记录,以便后续持续深入学习以及为后来者提供参考借鉴,文中不免疏漏之处,望读者予以指正,不胜感激!

1. nagios监控redis

1.1 安装check_redis插件

1)下载 check_redis.pl  check_redis.php
https://exchange.nagios.org/directory/Plugins/Databases/check_redis-2Epl/details

2)放到 /usr/local/nagios/libexec目录下,修改可执行
Mv check_redis.p* /usr/local/nagios/libexec
Chmod +x check_redis.p*

3)测试
./check_redis.pl -v

4)安装组件
提示问题:
Can't locate Redis.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./check_redis.pl line 421.
BEGIN failed--compilation aborted at ./check_redis.pl line 421.

解决:
yum install perl-CPAN
yum install -y perl-YAML
perl -MCPAN -e shell
cpan[1]>install YAML
cpan[2]>install Build
cpan[3]> install Redis
注意:cpan地址设置,网络要可访问,可选择国内镜像地址,比如http://mirrors.ustc.edu.cn/CPAN/

测试
./check_redis.pl -v

在这里插入图片描述

1.2 配置监控项

1)被监控端测试插件
command[check_redis_conn_time]=/usr/local/nagios/libexec/check_redis.pl -H localhost -p 6379 -x pwd -T 0.5,1

2)监控端配置
配置command.cfg
#check Redis
define command {
    command_name    check_redis
    command_line    $USER1$/check_redis.pl -H $HOSTADDRESS$ -p $ARG1$ -x $ARG2$ -a $ARG3$ -w $ARG4$ -c $ARG5$ -f
}

#check redis connect
define command {
    command_name    check_redis_conn_time
    command_line    $USER1$/check_redis.pl -H $HOSTADDRESS$ -p $ARG1$ -x $ARG2$ -T $ARG3$
}

配置service
define service{
    host_name               HostName
    service_description     Check_redis_conn_time
    check_command           check_nrpe!check_redis_conn_time!6379!pwd!0.5,1
    max_check_attempts      5
    check_interval          5
    retry_interval          2
    check_period            24x7
    notification_interval   10
    notification_period     24x7
    notification_options    w,u,c,r
    contact_groups          admins
}

3)被监控端配置
command[check_redis_conn_time]=/usr/local/nagios/libexec/check_redis.pl -H localhost -p 6379 -x Pwd -T 0.5,1
可传递参数时可使用如下
command[check_redis_conn_time]=/usr/local/nagios/libexec/check_redis.pl -H localhost -p $ARG1$ -x $ARG2$ -T $ARG3$

监控端和被监控端设置好参数可传递后,可以在其中一方设置参数即可

分别重启nagios和nrpe

在这里插入图片描述
在这里插入图片描述

2. nagios监控rabbitmq

2.1 安装监控插件

1)安装perl相关组件
nagios-plugins-rabbitmq 使用 perl 语言写的,这里需要安装perl 环境
yum install perl-CPAN
yum install -y perl-YAML

2)下载插件
wget --no-check-certificate https://github.com/jamesc/nagios-plugins-rabbitmq/archive/master.zip
unzip master.zip
mv nagios-plugins-rabbitmq-master nagios-plugins-rabbitmq

3)放入nagios插件目录
mv nagios-plugins-rabbitmq /usr/local/nagios/libexec
cd /usr/local/nagios/libexec/
 
chown -R nagios:nagios nagios-plugins-rabbitmq/
 
cd /usr/local/nagios/libexec/nagios-plugins-rabbitmq/scripts
 
./check_rabbitmq_server
Can't locate Monitoring/Plugin.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./check_rabbitmq_server line 12.
BEGIN failed--compilation aborted at ./check_rabbitmq_server line 12.

4)安装缺少perl模块
Perl安装模块 install模块
perl -MCPAN -e shell
install Module::Install
install Monitoring:Plugin
install LWP

2.2 配置监控项

1)监控端配置
配置command.cfg
define command{
    command_name check_rabbitmq_overview
    command_line $USER1$/nagios-plugins-rabbitmq/scripts/check_rabbitmq_overview -H $HOSTADDRESS$ --port=$ARG1$ -u $ARG2$ -p $ARG3$
}

配置service
define service{
    host_name               hostname
    service_description     Check_rabbitmq_overview
    check_command           check_nrpe!check_rabbitmq_overview!5672!account!pwd
    max_check_attempts      5
    check_interval          5
    retry_interval          2
    check_period            24x7
    notification_interval   10
    notification_period     24x7
    notification_options    w,u,c,r
    contact_groups          admins
}

验证配置文件
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重启nagios
systemctl restart nagios

2)客户端配置
客户端配置nrpe
command[check_rabbitmq_overview]=/usr/local/nagios/libexec/nagios-plugins-rabbitmq/scripts/check_rabbitmq_overview -H localhost --port=5672 -u Account -p Pwd

重启nrpe
systemctl restart nrpe

在这里插入图片描述
在这里插入图片描述

3. 参考资料

https://blog.csdn.net/weixin_30885111/article/details/96524338
https://blog.51cto.com/xiao987334176/1669330

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值