最新 centos7下zabbix 监控redis状态

2019-07-18  本文已影响0人  运维工程师日常

准备

先准备两台服务器,已经部署好了zabbix-sever和zabbix-agent

zabbix-server 192.168.1.70 centos7.2

zabbix-agent 192.168.1.70 centos7.2

zabbix-agent端 安装部署redis

redis的部署过程就不介绍了,百度一大堆
安装好redis之后,用redis info命令查看redis信息

[root@localhost zabbix_agentd.d]# redis-cli -a ac123456 info
# Server
redis_version:4.0.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:c69914497129c95c
redis_mode:standalone
os:Linux 3.10.0-693.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:16956
run_id:c9dc9487378a1dc42ee9e362c6bacae6dd8dcd3e
tcp_port:6379
uptime_in_seconds:140
uptime_in_days:0
hz:10
lru_clock:14818741
executable:/usr/local/redis-4.0.6/src/redis-server
config_file:/usr/local/redis-4.0.6/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:885434
used_memory_human:864.68K
used_memory_rss:2220032
used_memory_rss_human:2.12M
used_memory_peak:935546
used_memory_peak_human:913.62K
used_memory_peak_perc:94.64%
used_memory_overhead:884956
used_memory_startup:835326
used_memory_dataset:478
used_memory_dataset_perc:0.95%
total_system_memory:67240886272
total_system_memory_human:62.62G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:2.51
mem_allocator:libc
active_defrag_running:0
lazyfree_pending_objects:0

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1558322473
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0

# Stats
total_connections_received:146
total_commands_processed:278
instantaneous_ops_per_sec:3
total_net_input_bytes:5916
total_net_output_bytes:371281
instantaneous_input_kbps:0.08
instantaneous_output_kbps:4.93
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0

# Replication
role:master
connected_slaves:0
master_replid:71b0ed4332fc4a6319ec9aca91bd6bd42feca56a
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:0.13
used_cpu_user:0.06
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
[root@localhost zabbix_agentd.d]# 

参数讲解
-a ac123456是指定redis密码,如果redis没有密码 这个可以忽略

配置文件

在zabbix-agent端创建redis监控项的配置文件

[root@localhost zabbix_agentd.d]# cat /etc/zabbix/zabbix_agentd.d/redis.conf 
UserParameter=redis[*],redis-cli -a ac123456 info | grep $1":" | cut -d ':' -f 2
UserParameter=redis-ping,redis-cli -a 123456 ping | grep -c PONG
UserParameter=redis.version, redis-server --version | cut -d " " -f 3 | cut -d "=" -f 2
[root@localhost zabbix_agentd.d]# 

重启zabbix-agent服务

[root@localhost zabbix_agentd.d]# systemctl restart zabbix-agent
[root@localhost zabbix_agentd.d]# 

zabbix-server端通过zabbix-get测试获取数据

以下信息可以看出能成功的获取redis的信息

[root@localhost zabbix_agentd.d]# zabbix_get -s 192.168.1.70 -k redis.version
4.0.6
[root@localhost zabbix_agentd.d]#

去zabbix-server页面导入redis监控模板
监控模板我上传到百度云
地址:
链接:https://pan.baidu.com/s/15bp_uDhVRqIsKtDokyWmAg
提取码:0e9o
复制这段内容后打开百度网盘手机App,操作更方便哦

去主机关联导入的redis模板



添加上去后,等几分钟,去图形页面就可以看到redis的监控数据了



至此,已完成zabbix对redis的监控

微信公众号:[Kubernetes中文社区]
关注容器技术、关注Kubernetes。每天技术文章分享。
回复关键字视频Kubernetesdocker、获取视频学习资料

上一篇下一篇

猜你喜欢

热点阅读