Zabbix Monitoring Redis Info Detail Monitoring sample

Source: Internet
Author: User
Tags redis

1. Create script directory scripts, place script in this directory
The script is as follows:

#!/bin/bash


Redispath= "/usr/local/bin/redis-cli"


Host= "127.0.0.1"


Port= "6379"


Redis_pa= "$REDISPATH-H $HOST-P $PORT Info"


if [[$# = 1]];then


Case is in


Cluster


result= ' $REDIS _pa|/bin/grep cluster|awk-f ': ' ' {print $NF} '


Echo $result


;;


Uptime_in_seconds)


result= ' $REDIS _pa|/bin/grep uptime_in_seconds|awk-f ': ' ' {print $NF} '


Echo $result


;;


connected_clients)


result= ' $REDIS _pa|/bin/grep connected_clients|awk-f ': ' ' {print $NF} '


Echo $result


;;


Client_longest_output_list)


result= ' $REDIS _pa|/bin/grep client_longest_output_list|awk-f ': ' ' {print $NF} '


Echo $result


;;


CLIENT_BIGGEST_INPUT_BUF)


result= ' $REDIS _pa|/bin/grep client_biggest_input_buf|awk-f ': ' ' {print $NF} '


Echo $result


;;


blocked_clients)


result= ' $REDIS _pa|/bin/grep blocked_clients|awk-f ': ' ' {print $NF} '


Echo $result


;;


#内存


Used_memory)


result= ' $REDIS _pa|/bin/grep used_memory|awk-f ":" ' {print $NF} ' |awk ' Nr==1 '


Echo $result


;;


Used_memory_human)


result= ' $REDIS _pa|/bin/grep used_memory_human|awk-f ': ' ' {print $NF} ' |awk-f ' K ' ' {print '} '


Echo $result


;;


USED_MEMORY_RSS)


result= ' $REDIS _pa|/bin/grep used_memory_rss|awk-f ': ' ' {print $NF} '


Echo $result


;;


Used_memory_peak)


result= ' $REDIS _pa|/bin/grep used_memory_peak|awk-f ":" ' {print $NF} ' |awk ' Nr==1 '


Echo $result


;;


Used_memory_peak_human)


result= ' $REDIS _pa|/bin/grep used_memory_peak_human|awk-f ': ' ' {print $NF} ' |awk-f ' K ' ' {print '} '


Echo $result


;;


Used_memory_lua)


result= ' $REDIS _pa|/bin/grep used_memory_lua|awk-f ': ' ' {print $NF} '


Echo $result


;;


Mem_fragmentation_ratio)


result= ' $REDIS _pa|/bin/grep mem_fragmentation_ratio|awk-f ': ' ' {print $NF} '


Echo $result


;;


#rdb


Rdb_changes_since_last_save)


result= ' $REDIS _pa|/bin/grep rdb_changes_since_last_save|awk-f ': ' ' {print $NF} '


Echo $result


;;


rdb_bgsave_in_progress)


result= ' $REDIS _pa|/bin/grep rdb_bgsave_in_progress|awk-f ': ' ' {print $NF} '


Echo $result


;;


Rdb_last_save_time)


result= ' $REDIS _pa|/bin/grep rdb_last_save_time|awk-f ': ' ' {print $NF} '


Echo $result


;;


Rdb_last_bgsave_status)


result= ' $REDIS _pa|/bin/grep-w "Rdb_last_bgsave_status" | Awk-f ': ' {print $} ' | /bin/grep-c OK '


Echo $result


;;


RDB_CURRENT_BGSAVE_TIME_SEC)


result= ' $REDIS _pa|/bin/grep-w "Rdb_current_bgsave_time_sec" | Awk-f ': ' {print $} '


Echo $result


;;


#rdbinfo


aof_enabled)


result= ' $REDIS _pa|/bin/grep-w "aof_enabled" | Awk-f ': ' {print $} '


Echo $result


;;


aof_rewrite_scheduled)


result= ' $REDIS _pa|/bin/grep-w "aof_rewrite_scheduled" | Awk-f ': ' {print $} '


Echo $result


;;


AOF_LAST_REWRITE_TIME_SEC)


result= ' $REDIS _pa|/bin/grep-w "Aof_last_rewrite_time_sec" | Awk-f ': ' {print $} '


Echo $result


;;


AOF_CURRENT_REWRITE_TIME_SEC)


result= ' $REDIS _pa|/bin/grep-w "Aof_current_rewrite_time_sec" | Awk-f ': ' {print $} '


Echo $result


;;


Aof_last_bgrewrite_status)


result= ' $REDIS _pa|/bin/grep-w "Aof_last_bgrewrite_status" | Awk-f ': ' {print $} ' | /bin/grep-c OK '


Echo $result


;;


#aofinfo


Aof_current_size)


result= ' $REDIS _pa|/bin/grep-w "Aof_current_size" | Awk-f ': ' {print $} '


Echo $result


;;


Aof_base_size)


result= ' $REDIS _pa|/bin/grep-w "Aof_base_size" | Awk-f ': ' {print $} '


Echo $result


;;


Aof_pending_rewrite)


result= ' $REDIS _pa|/bin/grep-w "Aof_pending_rewrite" | Awk-f ': ' {print $} '


Echo $result


;;


Aof_buffer_length)


result= ' $REDIS _pa|/bin/grep-w "Aof_buffer_length" | Awk-f ': ' {print $} '


Echo $result


;;


Aof_rewrite_buffer_length)


result= ' $REDIS _pa|/bin/grep-w "Aof_rewrite_buffer_length" | Awk-f ': ' {print $} '


Echo $result


;;


Aof_pending_bio_fsync)


result= ' $REDIS _pa|/bin/grep-w "Aof_pending_bio_fsync" | Awk-f ': ' {print $} '


Echo $result


;;


Aof_delayed_fsync)


result= ' $REDIS _pa|/bin/grep-w "Aof_delayed_fsync" | Awk-f ': ' {print $} '


Echo $result


;;


#stats


total_connections_received)


result= ' $REDIS _pa|/bin/grep-w "total_connections_received" | Awk-f ': ' {print $} '


Echo $result


;;


total_commands_processed)


result= ' $REDIS _pa|/bin/grep-w "total_commands_processed" | Awk-f ': ' {print $} '


Echo $result


;;


INSTANTANEOUS_OPS_PER_SEC)


result= ' $REDIS _pa|/bin/grep-w "Instantaneous_ops_per_sec" | Awk-f ': ' {print $} '


Echo $result


;;


Rejected_connections)


result= ' $REDIS _pa|/bin/grep-w "Rejected_connections" | Awk-f ': ' {print $} '


Echo $result


;;


Expired_keys)


result= ' $REDIS _pa|/bin/grep-w "Expired_keys" | Awk-f ': ' {print $} '


Echo $result


;;


Evicted_keys)


result= ' $REDIS _pa|/bin/grep-w "Evicted_keys" | Awk-f ': ' {print $} '


Echo $result


;;


Keyspace_hits)


result= ' $REDIS _pa|/bin/grep-w "Keyspace_hits" | Awk-f ': ' {print $} '


Echo $result


;;


keyspace_misses)


result= ' $REDIS _pa|/bin/grep-w "keyspace_misses" | Awk-f ': ' {print $} '


Echo $result


;;


Pubsub_channels)


result= ' $REDIS _pa|/bin/grep-w "Pubsub_channels" | Awk-f ': ' {print $} '


Echo $result


;;


Pubsub_channels)


result= ' $REDIS _pa|/bin/grep-w "Pubsub_channels" | Awk-f ': ' {print $} '


Echo $result


;;


Pubsub_patterns)


result= ' $REDIS _pa|/bin/grep-w "Pubsub_patterns" | Awk-f ': ' {print $} '


Echo $result


;;


LATEST_FORK_USEC)


result= ' $REDIS _pa|/bin/grep-w "Latest_fork_usec" | Awk-f ': ' {print $} '


Echo $result


;;


connected_slaves)


result= ' $REDIS _pa|/bin/grep-w "connected_slaves" | Awk-f ': ' {print $} '


Echo $result


;;


Master_link_status)


result= ' $REDIS _pa|/bin/grep-w ' master_link_status ' |awk-f ': ' {print $} ' |/bin/grep-c up '


Echo $result


;;


Master_last_io_seconds_ago)


result= ' $REDIS _pa|/bin/grep-w ' Master_last_io_seconds_ago ' |awk-f ': ' {print $} '


Echo $result


;;


master_sync_in_progress)


result= ' $REDIS _pa|/bin/grep-w ' master_sync_in_progress ' |awk-f ': ' {print $} '


Echo $result


;;


slave_priority)


result= ' $REDIS _pa|/bin/grep-w ' slave_priority ' |awk-f ': ' {print $} '


Echo $result


;;


#cpu


Used_cpu_sys)


result= ' $REDIS _pa|/bin/grep-w ' Used_cpu_sys ' |awk-f ': ' {print $} '


Echo $result


;;


Used_cpu_user)


result= ' $REDIS _pa|/bin/grep-w ' used_cpu_user ' |awk-f ': ' {print $} '


Echo $result


;;


Used_cpu_sys_children)


result= ' $REDIS _pa|/bin/grep-w ' Used_cpu_sys_children ' |awk-f ': ' {print $} '


Echo $result


;;


Used_cpu_user_children)


result= ' $REDIS _pa|/bin/grep-w ' Used_cpu_user_children ' |awk-f ': ' {print $} '


Echo $result


;;


*)


        echo "Usage:$0{uptime_in_seconds|connected_clients|client_longest_ Output_list|client_biggest_input_buf|blocked_clients|used_memory|used_memory_human|used_memory_rss|used_memory _peak|used_memory_peak_human|used_memory_lua|mem_fragmentation_ratio|rdb_changes_since_last_save|rdb_bgsave_in _progress|rdb_last_save_time|rdb_last_bgsave_status|rdb_current_bgsave_time_sec|aof_enabled|aof_rewrite_ scheduled|aof_last_rewrite_time_sec|aof_current_rewrite_time_sec|aof_last_bgrewrite_status|aof_current_size| Aof_base_size|aof_pending_rewrite|aof_buffer_length|aof_rewrite_buffer_length|aof_pending_bio_fsync|aof_ Delayed_fsync|rejected_connections|instantaneous_ops_per_sec|total_connections_received|total_commands_ Processed|expired_keys|evicted_keys|keyspace_hits|keyspace_misses|pubsub_channels|pubsub_patterns|latest_fork_ usec|connected_slaves|master_link_status|master_sync_in_progress|master_last_io_seconds_ago|connected_slaves| Slave_priority|used_cpu_user|useD_cpu_sys|used_cpu_sys_children|used_cpu_user_children} "


;;


Esac


#db0: Key


elif [[$# = 2]];then


Case $ in


Keys


result= ' $REDIS _pa| /bin/grep-w "Db0" | /bin/grep-w "$" | /bin/grep-w "Keys" | Awk-f ' =|, ' {print $} '


Echo $result


;;


Expires


result= ' $REDIS _pa| /bin/grep-w "Db0" | /bin/grep-w "$" | /bin/grep-w "Expires" | Awk-f ' =|, ' {print $} '


Echo $result


;;


AVG_TTL)


result= ' $REDIS _pa|/bin/grep-w "Db0" | /bin/grep-w "$" | /bin/grep-w "Avg_ttl" | Awk-f ' =|, ' {print $} '


Echo $result


;;


*)


echo "Usage:$0{db0 keys|db0 expires|db0 Avg_ttl}"


;;


Esac


Fi


2. Modify zabbix-agentd.conf Add the following


Userparameter=redis_info[*],/etc/zabbix/scripts/redis_info.sh $ $


3. Import Template


http://pan.baidu.com/share/init?shareid=3363881681&uk=1074693321


Link Password: obnt

Related Article

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.