Nagios monitors redis and rabbitmq
After installing and using nagios, the relevant server-related parameters were initially monitored, including disk, memory, CPU and network, etc. Middleware such as redis/rabbitmq was also used in the project, so learn to summarize relevant online materials and carry out The practical operation, installation and configuration have completed the monitoring of redis and rabbitmq, and the process is summarized and recorded here, so as to facilitate continuous in-depth study and provide reference for latecomers. There are inevitably omissions in the article, and readers are welcome to correct them. Thank you very much!
1. nagios monitoring redis
1.1 Install the check_redis plugin
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 Configure monitoring items
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 monitoring rabbitmq
2.1 Install monitoring plug-in
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 Configure monitoring items
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. References
https://blog.csdn.net/weixin_30885111/article/details/96524338
https://blog.51cto.com/xiao987334176/1669330