{"id":751,"date":"2018-04-04T15:09:02","date_gmt":"2018-04-04T07:09:02","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=751"},"modified":"2018-04-04T15:09:02","modified_gmt":"2018-04-04T07:09:02","slug":"zabbix-%e7%9b%91%e6%8e%a7-redis-%e6%95%b0%e6%8d%ae%e5%ba%93%e6%80%a7%e8%83%bd","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=751","title":{"rendered":"Zabbix \u76d1\u63a7 Redis \u6570\u636e\u5e93\u6027\u80fd"},"content":{"rendered":"<p>\u8bf4\u660e\uff1a\u4ee5\u4e0b\u6240\u6709\u64cd\u4f5c\u5747\u5728 Zabbix Agent \u5ba2\u6237\u7aef\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u90e8\u7f72\u73af\u5883\uff1a<\/strong><\/p>\n<blockquote>\n<pre>OS\uff1aCentOS Linux release 7.4.1708 (Core) x64\nZabbix Servers\uff1a3.4\nRedis Servers\uff1a4.0<\/pre>\n<\/blockquote>\n<p><strong>\u5148\u51b3\u6761\u4ef6\uff1a<\/strong><\/p>\n<blockquote><p>\u300a<a href=\"https:\/\/renwole.com\/archives\/298\">Linux Centos7 Redis \u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u914d\u7f6e<\/a>\u300b<\/p><\/blockquote>\n<p><strong>1.\u4fee\u6539\u4e3b\u673a Host<\/strong><\/p>\n<blockquote><p>\u6587\u4ef6\u672b\u7aef\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>$ vim \/etc\/hosts\n\n10.28.204.65 s102820465<\/pre>\n<\/blockquote>\n<p><strong>2.\u5b89\u88c5 Python \u4f9d\u8d56\u5305<\/strong><\/p>\n<blockquote>\n<pre>$ yum -y install python-pip\n$ pip install argparse\n$ pip install redis<\/pre>\n<\/blockquote>\n<p><strong>3.\u4e0b\u8f7d Zabbix \u5b98\u65b9\u63d0\u4f9b\u7684 Template Redis \u6a21\u677f<\/strong><\/p>\n<blockquote><p>\u5c06\u4e0b\u8f7d\u5230\u672c\u5730\u7684\u538b\u7f29\u5305\u4f20\u5165\u5230tmp\u76ee\u5f55\u540e\u89e3\u538b\uff1a<\/p>\n<p>https:\/\/github.com\/adubkov\/zbx_redis_template<\/p>\n<pre>$ cd \/tmp\n$ tar zxvf zbx_redis_template-master.zip\n$ cd zbx_redis_template-master<\/pre>\n<p>\u5c06\u4ee5\u4e0b2\u4e2a\u914d\u7f6e\u6587\u4ef6\u62f7\u8d1d\u5230\u76f8\u5173\u76ee\u5f55\uff1a<\/p>\n<pre>$ cp zbx_redis_stats.py \/usr\/local\/zabbix\/bin\n$ cp zbx_redis.conf \/usr\/local\/zabbix\/etc\/zabbix_agentd.conf.d\/<\/pre>\n<p>\u6ce8\u610f\uff1a\u9664\u4e0a\u9762\u4e24\u4e2a\u6587\u4ef6\u5916\uff0c\u5176\u4ed6\u7684\u53ef\u4ee5\u5ffd\u7565\u3002\u56e0\u4e3a\u5b98\u65b9Zabbix template \u6a21\u677f\u63d0\u4f9b\u4e86\u4e24\u79cd\u76d1\u63a7redis\u7684\u65b9\u6848\uff0c\u5206\u522b\u662f\u00a0node.js \u3001python\u3002\u672c\u6587\u6559\u7a0b\u91c7\u7528\u540e\u8005\u3002<\/p><\/blockquote>\n<p><strong>4.\u914d\u7f6ezbx_redis_stats.py<\/strong><\/p>\n<blockquote><p>\u5c06\u4ee5\u4e0b\u6587\u4ef6\u4e2d\u7684\u53c2\u6570\u4fee\u6539\u4e3a Zabbix Server \u4e3b\u673aIP\u53ca\u7aef\u53e3\uff1a<\/p>\n<pre>$ cd \/usr\/local\/zabbix\/bin\n$ vim zbx_redis_stats.py\n...\nzabbix_host = '10.28.204.62' # Zabbix Server IP\nzabbix_port = 10051 # Zabbix Server Port\n...<\/pre>\n<p>\u7ed9\u8be5\u6587\u4ef6\u53ef\u6267\u884c\u6743\u9650\uff1a<\/p>\n<pre>$ chmod +x zbx_redis_stats.py<\/pre>\n<\/blockquote>\n<p><strong>5.\u914d\u7f6ezbx_redis.conf<\/strong><\/p>\n<blockquote>\n<pre>$ cd \/usr\/local\/zabbix\/etc\/zabbix_agentd.conf.d\/<\/pre>\n<p>\u5c06\u6587\u4ef6\u4fee\u6539\u4e3a\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>$ vim zbx_redis.conf\n\nUserParameter=redis[*],\/usr\/local\/zabbix\/bin\/zbx_redis_stats.py -p 6379 -a RenwoleQxl5qpKHrh $1 $2 $3<\/pre>\n<\/blockquote>\n<p><strong>6.\u6d4b\u8bd5zbx_redis_status.py\u662f\u5426\u53ef\u4ee5\u8fde\u63a5 Redis \u6570\u636e\u5e93<\/strong><\/p>\n<blockquote>\n<pre>$ cd \/usr\/local\/zabbix\/bin\n$ .\/zbx_redis_stats.py -h 127.0.0.1 -p 6379 -a RenwoleQxl5qpKHrh\n\nusage: zbx_redis_stats.py [-h] [-p REDIS_PORT] [-a REDIS_PASS]\n[redis_hostname] [metric] [db]\n\nZabbix Redis status script\n\npositional arguments:\nredis_hostname\nmetric\ndb\n\noptional arguments:\n-h, --help show this help message and exit\n-p REDIS_PORT, --port REDIS_PORT\nRedis server port\n-a REDIS_PASS, --auth REDIS_PASS\nRedis server pass<\/pre>\n<p>\u51fa\u73b0\u4ee5\u4e0a\u5185\u5bb9\u8bf4\u660e\u8fde\u63a5\u6b63\u5e38\u3002<\/p>\n<p>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<p>-h Redis\u00a0bind \u5730\u5740<br \/>\n-p Redis\u7aef\u53e3<br \/>\n-a Redis\u5bc6\u7801<\/p><\/blockquote>\n<p><strong>7.\u6d4b\u8bd5\u662f\u5426\u83b7\u53d6\u5230\u6570\u636e<\/strong><\/p>\n<blockquote>\n<pre>$ .\/zbx_redis_stats.py -p 6379 -a RenwoleQxl5qpKHrh S102820465 used_cpu_user_children none\n0.71<\/pre>\n<p>\u8fd4\u56de 0.71\uff0c\u6b64\u503c\u4e0d\u56fa\u5b9a\uff0c\u53ea\u8981\u6709\u6570\u636e\u8fd4\u56de\uff0c\u8bf4\u660e\u811a\u672c\u8fd0\u884c\u6b63\u5e38\u3002<\/p>\n<p>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<p>zbx_redis.conf\u6587\u4ef6\u4e2d\u7684$1 $2 $3\u8fd9\u65f6\u5c31\u6d3e\u4e0a\u7528\u573a\u4e86\u3002<\/p>\n<p>$1 \u5bf9\u5e94 S102820465 \u4e3b\u673aHost<br \/>\n$2 \u5bf9\u5e94 used_cpu_user_children<br \/>\n$3\u00a0\u5bf9\u5e94 none<\/p><\/blockquote>\n<p>\u6700\u540e\u5c06\u00a0<strong>zbx_redis_templates.xml<\/strong>\u00a0\u6a21\u677f\u5bfc\u5165\u5230\u00a0<strong>Zabbix Servers UI<\/strong>\u00a0\u4e2d\uff0c\u7136\u540e\u94fe\u63a5\u5230\u9700\u8981\u76d1\u63a7\u7684\u4e3b\u673a\u5373\u53ef\u3002<\/p>\n<p>\u5982\u679c\u5728Zabbix UI\u4e2d\u65e0\u6cd5\u83b7\u53d6\u7684\u5230\u6570\u636e\uff0c\u53ef\u4ee5\u5728\u00a0<strong>Zabbix Agent<\/strong>\u00a0\u5ba2\u6237\u7aef\u76f4\u63a5\u8fd0\u884c\u00a0<strong>zbx_redis_stats.py<\/strong>\u811a\u672c\uff0c\u5982\u679c\u6709\u914d\u7f6e\u4e0d\u6b63\u786e\u7684\u5730\u65b9\uff0c\u4f1a\u53cd\u9988\u51fa\u6765\uff0c\u518d\u6839\u636e\u62a5\u9519\u5904\u7406\u5373\u53ef\u3002<\/p>\n<p><strong>\u7ed3\u8bed\uff1a<\/strong><\/p>\n<p>\u5176\u5b9e\u76d1\u63a7redis\u72b6\u6001\u7684\u6a21\u677f\u592a\u591a\u4e86\uff0c\u57fa\u672c\u90fd\u662f\u5927\u540c\u5c0f\u5f02\uff0c\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u81ea\u5df1\u7684\uff0c\u6bd4\u5982\u76d1\u63a7\u9879\u76ee\u975e\u5e38\u591a\u7684\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4e86\u89e3redis\u66f4\u591a\u6027\u80fd\u6307\u6807\u3002<\/p>\n<p><strong>\u7248\u6743\u58f0\u660e\uff1a<\/strong>\u672c\u7ad9\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u4efb\u4f55\u5f62\u5f0f\u7684\u8f6c\u8f7d\u3002<br \/>\n<strong>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<\/strong><a href=\"https:\/\/renwole.com\/archives\/579\">Zabbix \u76d1\u63a7 Redis \u6570\u636e\u5e93\u6027\u80fd | \u4efb\u6211\u4e50<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf4\u660e\uff1a\u4ee5\u4e0b\u6240\u6709\u64cd\u4f5c\u5747\u5728 Zabbix Agent \u5ba2\u6237\u7aef\u64cd\u4f5c\u3002 \u90e8\u7f72\u73af\u5883\uff1a OS\uff1aCentOS Linux release 7.4.1708 (Core) x64 Zabbix Servers\uff1a3.4 Redis Servers\uff1a4.0 \u5148\u51b3\u6761\u4ef6\uff1a \u300aLinux Centos7 Redis \u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u914d\u7f6e\u300b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-751","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=751"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/751\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}