nagios监控redis

一、环境概述

nagios服务端:192.168.203.10

nagios客户端(redis):192.168.203.20

redis版本:Redis 2.8 release

 

二、下载并安装redis监控插件

https://github.com/willixix/WL-NagiosPlugins

将perl文件放到nagios的指定libexec路径下,赋执行权限

/usr/local/nagios/libexec/check_redis.pl

需要安装perl的Redis.pm模块,否则报错

(No output on stdout) stderr: 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 /usr/local/nagios/libexec/check_redis.pl line 421. 

#yum install -y perl-YAML

#perl -MCPAN -e shell

cpan[1]> install Redis

一路回车,可能需要安装的依赖包太多,一直安装就好。

Result: PASS

  DAMS/Redis-1.975.tar.gz

  /usr/bin/make test -- OK

Running make install

Prepending /root/.cpan/build/Redis-1.975-TazMoi/blib/arch /root/.cpan/build/Redis-1.975-TazMoi/blib/lib to PERL5LIB for ‘install‘

Installing /usr/local/share/perl5/Redis.pm

Installing /usr/local/share/perl5/Redis/List.pm

Installing /usr/local/share/perl5/Redis/Sentinel.pm

Installing /usr/local/share/perl5/Redis/Hash.pm

Installing /usr/local/share/man/man3/Redis::Hash.3pm

Installing /usr/local/share/man/man3/Redis::Sentinel.3pm

Installing /usr/local/share/man/man3/Redis::List.3pm

Installing /usr/local/share/man/man3/Redis.3pm

Appending installation info to /usr/lib64/perl5/perllocal.pod

  DAMS/Redis-1.975.tar.gz

  /usr/bin/make install  -- OK

 

cpan[2]> quit

 

#cp -p /usr/local/share/perl5/Redis.pm  /usr/lib64/perl5/

 

三、定义监控命令

在commands.cfg添加下面内容:

#vi /usr/local/nagios/etc/objects/commands.cfg

# check redis

define command {

        command_name    check_redis

        command_line    $USER1$/check_redis.pl -H $HOSTADDRESS$ -p $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -f

}

定义主机监控项

#vi /usr/local/nagios/etc/objects/192.168.203.20.cfg

define service {

      use                     local-service

      service_description     Redis Client

      check_command           check_redis!6379!‘connected_clients,blocked_clients,client_longest_output_list,client_biggest_input_buf‘!100,5,~,~!500,10,~,~

      host_name               192.168.203.20

}

 

安装完成之后,具体情况如下:

 

nagios监控redis,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。