Nagios monitoring production environment redis cluster service practice

Source: Internet
Author: User
Tags redis cluster install redis
Previously, a cacti redis performance report chart was created to show the performance change trend chart of redis. However, the real-time alarm notification function is missing. In case of redis service bottlenecks or exceptions, even if an alarm is triggered, the dba can handle the maintenance immediately. 1. Download The redis monitoring plug-in. Redis has been installed on the server,

Previously, a cacti redis performance report chart was created to show the performance change trend chart of redis. However, the real-time alarm notification function is missing. In case of redis service bottlenecks or exceptions, even if an alarm is triggered, the dba can handle the maintenance immediately. 1. Download The redis monitoring plug-in. Redis has been installed on the server,

Preface: In the past, cacti showed the redis performance report graph. We can see the performance change trend graph of redis, However, the real-time alarm notification function is missing. Now, we need to complete this step. In case of redis service bottlenecks or exceptions, even if an alarm is triggered, the dba can handle the maintenance immediately.
1. Download The redis monitoring plug-in

Redis has been installed on the server, so it can be directly monitored. For details about how to install redis clusters, refer.

2. Grant the execution permission

Copy check_redis.php and check_redis.pl to the/usr/lib/nagios/plugins/directory, and grant the execution permission,

[Root @ wgq_41 plugins] # cd/usr/lib/nagios/plugins/

[Root @ wgq_41 plugins] # chown-R nagios. nagios check_redis .*

[Root @ wgq_41 plugins] # chmod 750 check_redis .*

3. Define monitoring commands

[Root @ wgq objects] vim/usr/local/nagios/etc/objects/commands. cfg

# Add by tim on 20141010, for redis

# Check redis

Define command {

Command_name check_redis

Command_line/usr/lib/nagios/plugins/check_redis.pl-H $ HOSTADDRESS $-p $ ARG1 $-a $ ARG2 $-w $ ARG3 $-c $ ARG4 $-f

}

4. Define the redis monitoring host

[Root @ wgq etc] # vim/usr/local/nagios/etc/hosts. cfg

# No. 018, redis master server

Define host {

Use linux-server

Host_name cache-1

Alias cache-1

Address 10. xxx.3.x0

Check_command check-host-alive

Max_check_attempts 5

Check_period 24x7

Contact_groups ops

Icationication_interval 30

Icationication_period 24x7

Notification_options d, u, r

}

# No. 020 cache-3 redis slave server

Define host {

Use linux-server

Host_name cache-3

Alias cache-3

Address 10. xx.3.x2

Check_command check-host-alive

Max_check_attempts 5

Check_period 24x7

Contact_groups ops

Icationication_interval 30

Icationication_period 24x7

Notification_options d, u, r

}

5. Define the redis monitoring host Group

Define hostgroup {

Hostgroup_name Redis_Servers

Alias Redisservices

Members cache-1, cache-2

}

6. Define redis monitoring service options

[Root @ wgq objects] # vim/usr/local/nagios/etc/objects/services_redis.cfg

# Redis Master monitoring options

Define service {

Host_name cache-1

Servicegroups Redisservices

Service_description Redis Master Clients

Check_command check_redis! 6379! 'Connected_clients, blocked_clients, client_longest_output_list, client_biggest_input_buf '! , 50 ,~,~! 600,150 ,~,~

Max_check_attempts 5

Normal_check_interval 3

Retry_check_interval 2

Check_period 24x7

Icationication_interval 10

Icationication_period 24x7

Notification_options w, u, c, r

Contact_groups ops

}

Define service {

Host_name cache-1

Servicegroups Redisservices

Service_description Redis Master Memory

Check_command check_redis! 6379! 'Used _ memory_human, used_memory_peak_human '!~,~!~,~

Max_check_attempts 5

Normal_check_interval 3

Retry_check_interval 2

Check_period 24x7

Icationication_interval 10

Icationication_period 24x7

Notification_options w, u, c, r

Contact_groups ops

}

Define service {

Host_name cache-1

Servicegroups Redisservices

Service_description Redis Master CPU

Check_command check_redis! 6379! 'Used _ cpu_sys, used_cpu_user, used_cpu_sys_children, used_cpu_user_children '!~,~,~,~!~,~,~,~ ; # Undefined monitoring alarm threshold

Max_check_attempts 5

Normal_check_interval 3

Retry_check_interval 2

Check_period 24x7

Icationication_interval 10

Icationication_period 24x7

Notification_options w, u, c, r

Contact_groups ops

}

# Redis Slave monitoring options

Define service {

Host_name cache-3

Servicegroups Redisservices

Service_description Redis Slave Clients

Check_command check_redis! 6379! 'Connected_clients, blocked_clients, client_longest_output_list, client_biggest_input_buf '! , 50 ,~,~! 600,150 ,~,~

Max_check_attempts 5

Normal_check_interval 3

Retry_check_interval 2

Check_period 24x7

Icationication_interval 10

Icationication_period 24x7

Notification_options w, u, c, r

Contact_groups ops

}

Define service {

Host_name cache-3

Servicegroups Redisservices

Service_description Redis Slave Memory

Check_command check_redis! 6379! 'Used _ memory_human, used_memory_peak_human '!~,~!~,~

Max_check_attempts 5

Normal_check_interval 3

Retry_check_interval 2

Check_period 24x7

Icationication_interval 10

Icationication_period 24x7

Notification_options w, u, c, r

Contact_groups ops

}

Define service {

Host_name cache-3

Servicegroups Redisservices

Service_description Redis Slave CPU

Check_command check_redis! 6379! 'Used _ cpu_sys, used_cpu_user, used_cpu_sys_children, used_cpu_user_children '!~,~,~,~!~,~,~,~ ; # Undefined monitoring alarm threshold

Max_check_attempts 5

Normal_check_interval 3

Retry_check_interval 2

Check_period 24x7

Icationication_interval 10

Icationication_period 24x7

Notification_options w, u, c, r

Contact_groups ops

}

Grant nagios user execution permission

[Root @ wgq objects] # chown-R nagios. nagios services_redis.cfg

[Root @ wgq objects] # chmod 777 services_redis.cfg

Add monitoring service item to nagios. cfg

[Root @ wgq etc] # vim/usr/local/nagios/etc/nagios. cfg

Export _file =/usr/local/nagios/etc/objects/services_redis.cfg

7. Test the redis Monitoring Service.

Run the command/usr/lib/nagios/plugins/check_redis.pl-H cache-1-a 'connected_clients, blocked_clients '-w ~,~ -C ~,~ -M-M 4G-A-R-T to test whether redis monitoring is normal

[Root @ wgq plugins] #/usr/lib/nagios/plugins/check_redis.pl-H 10.2xx.3.x0-a 'connected_clients, blocked_clients '-w ~,~ -C ~,~ -M-M 4G-A-R-T

OK: REDIS 2.8.8 on 10.2xx.3.x0: 6379 has 1 databases (db0) with 28497 keys, up 76 days 2 hours-response in 0.004 s, hitrate is 12.83%, memory use is 194.14 M (peak 205.14 M, 6.49% of max, fragmentation 1.37%), connected_clients is 35, blocked_clients is 11 | redis_build_id = primary partition = 341191c partition = 33792 partition = 0 used_memory_rss = 278720.4b partition = 0 loading = 0 redis_mode = standalone partition = 5588 partition = 0 partition = 0 master_repl_offset = records = 76c records = 0 lru_clock = 3649276 records = 0 rejected_connections = 0 repl_backlog_active = 0 records = 1 sync_full = 0 process_id = 7776 records = 194.14 M records =-1 used_memory = 203570960 aof_enabled = 1 blocked_clients = 11 records = OK records = 0 records = 0 used_cpu_sys_children = 2222.75 connected_slaves = 0 repl_backlog_histlen = 0 records = 6576292c repl_backlog_size = 1048576 OS = Linux 2.6.32-358. el6.x86 _ 64 x86_64 used_cpu_sys = 32640.80 kernel = 0 connected_clients = 35 kernel = 1 kernel = 205.14 M run_id = running kernel = OK pubsub_patterns = 8 kernel = 0 keyspace_hits = 42175896c kernel = 1412935342 kernel = 318 db0_keys = 28497 db0_expires = 7 db0_avg_ttl = 34003 aof_pending_rewrite = 0 aof_buffer_length = 0 config_file =/usr/local/redis-2.8.8/etc/redis. conf pubsub_channels = 0 rows = 21375.34 hz = 10 rows = 2 rows = OK aof_base_size = 82883253 used_cpu_user = 18460.42 keyspace_misses = export tcp_port = 6379 rows = export rows = 1.37 aof_current_size = 146485850 rows =- 1 records = 0 records = 114 evicted_keys = 0c records = 215106272B expired_keys = 58977c total_keys = 28497 total_expires = 7 response_time = 0.003802 s hitrate = 12.8281% memory_utilization = 6.49013519287109%

[Root @ wgq plugins] #

8. view the redis Monitoring Service Status

Reload nagios to make the newly added redis monitoring configuration take effect.

[Root @ wgq objects] # service nagios reload

Running configuration check...

Reloading nagios configuration...

Done

[Root @ wgq objects] #

The redis monitoring service interface is shown in:


9. error handling process during the operation

Error:

[Root @ wgq_line_cache_3_41 plugins] #./check_redis.pl -- help

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.

[Root @ wgq_line_cache_3_41 plugins] #

[Root @ wgq_line_cache_3_41 plugins] # perl-MCPAN-e shell

Terminal does not support AddHistory.

Cpan shell -- CPAN configuration and modules installation (v1.9402)

Enter 'H' for help.

Cpan [1]> install Redis

...

Can't locate Module/Build/Tiny. 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 Build. PL line 2.

BEGIN failed -- compilation aborted at Build. PL line 2.

Warning: No success on command [/usr/bin/perl Build. PL -- installdirs site]

Warning (usually harmless): 'yaml' not installed, will not store persistent state

DAMS/Redis-1.976.tar.gz

/Usr/bin/perl Build. PL -- installdirs site -- NOT OK

Running Build test

Make had some problems, won't test

Running Build install

Make had some problems, won't install

Cocould not read '/root/. cpan/build/Redis-1.976-Zhz6xI/META. yml'. Falling back to other methods to determine prerequisites ......

YAML is a data-centric markup language. It uses ASCII codes (such as hyphens, question marks, colons, and commas) to construct data blocks (scalar values or hash codes ). Similar to XML, YAML is also a machine recognition language that can be combined with Multiple scripting languages. One of them is Perl, which requires the installation of YAML, which is executed as follows:

Cpan [2]> install YAML

......

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

YAML-1.12.tar.gz/INGY

/Usr/bin/make install -- OK

CPAN: YAML loaded OK (v1.12)

PS: the installation may fail. The cause of the failure is network connection. You can run install YAML several times to complete the installation.

Run install Redis again. The following message is displayed:

Cpan [4]> install Redis

Running install for module 'redis'

Running Build for D/DA/DAMS/Redis-1.976.tar.gz

Has already been unwrapped into directory/root/. cpan/build/Redis-1.976-cUL4rt

'/Usr/bin/perl Build. PL -- installdirs site' returned status 512, won' t make

Running Build test

Make had some problems, won't test

Running Build install

Make had some problems, won't install

Cpan [5]>

Build failed, Build. PL failed, you need to reinstall and execute the command install Build

Cpan [5]> install Build

Then run install Redis.

Cpan [6]> install Redis

Redis installation is successful.

<版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!>

Reference: http://exchange.nagios.org/directory/Plugins/Databases/check_redis-2Epl/details

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.