使用zabbix监控redis
redis有自带的redis-cli客户端,redis-cli加参数info可以得到redis的状态值,利用这个可以对zabbix增加redis监控,步骤如下:
agent端配置文件
在agent端的zabbix.conf下添加如下代码:
UserParameter=redis_stats[*], /usr/local/bin/redis-cli -h 127.0.0.1 -p $1 info| grep $2| cut -d : -f2 |
web端导入xml文件
然后将redis模板导入,默认redis端口为6379。
<? xml version = "1.0" encoding = "UTF-8" ?> < zabbix_export > < version >2.0</ version > < date >2014-11-30T05:29:03Z</ date > < groups > < group > < name >Templates</ name > </ group > </ groups > < templates > < template > < template >Templates Redis_6379</ template > < name >Templates Redis_6379</ name > < groups > < group > < name >Templates</ name > </ group > </ groups > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < items > < item > < name >Blocked clients_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,blocked_clients]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Connected clients_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,connected_clients]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Connected slave_6380</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,connected_slave]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Connection rate_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,total_connections_received]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >1</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Evicted_keys_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,evicted_keys]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Expired keys_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,expired_keys]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Last save time_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,last_save_time]</ key > < delay >60</ delay > < history >3</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units >unixtime</ units > < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >port status_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >net.tcp.listen[6379]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Request rate_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,total_commands_processed]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >1</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Role_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,role]</ key > < delay >60</ delay > < history >3</ history > < trends >365</ trends > < status >0</ status > < value_type >1</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Uptime in seconds_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,uptime_in_seconds]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units >uptime</ units > < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Used memory_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,used_memory:]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > < item > < name >Used_memory_rss_6379</ name > < type >0</ type > < snmp_community /> < multiplier >0</ multiplier > < snmp_oid /> < key >redis_stats[6379,used_memory_rss]</ key > < delay >60</ delay > < history >7</ history > < trends >365</ trends > < status >0</ status > < value_type >3</ value_type > < allowed_hosts /> < units /> < delta >0</ delta > < snmpv3_contextname /> < snmpv3_securityname /> < snmpv3_securitylevel >0</ snmpv3_securitylevel > < snmpv3_authprotocol >0</ snmpv3_authprotocol > < snmpv3_authpassphrase /> < snmpv3_privprotocol >0</ snmpv3_privprotocol > < snmpv3_privpassphrase /> < formula >1</ formula > < delay_flex /> < params /> < ipmi_sensor /> < data_type >0</ data_type > < authtype >0</ authtype > < username /> < password /> < publickey /> < privatekey /> < port /> < description /> < inventory_link >0</ inventory_link > < applications > < application > < name >Redis_6379</ name > </ application > </ applications > < valuemap /> < logtimefmt /> </ item > </ items > < discovery_rules /> < macros /> < templates /> < screens /> </ template > </ templates > < triggers > < trigger > < expression >{Templates Redis_6379:net.tcp.listen[6379].count(#3,0,"eq")}=3</ expression > < name >Redis port 6379 is not running</ name > < url /> < status >0</ status > < priority >4</ priority > < description /> < type >0</ type > < dependencies /> </ trigger > </ triggers > < graphs > < graph > < name >Redis key_6379</ name > < width >900</ width > < height >200</ height > < yaxismin >0.0000</ yaxismin > < yaxismax >100.0000</ yaxismax > < show_work_period >1</ show_work_period > < show_triggers >1</ show_triggers > < type >0</ type > < show_legend >1</ show_legend > < show_3d >0</ show_3d > < percent_left >0.0000</ percent_left > < percent_right >0.0000</ percent_right > < ymin_type_1 >0</ ymin_type_1 > < ymax_type_1 >0</ ymax_type_1 > < ymin_item_1 >0</ ymin_item_1 > < ymax_item_1 >0</ ymax_item_1 > < graph_items > < graph_item > < sortorder >0</ sortorder > < drawtype >0</ drawtype > < color >C80000</ color > < yaxisside >0</ yaxisside > < calc_fnc >2</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,evicted_keys]</ key > </ item > </ graph_item > < graph_item > < sortorder >1</ sortorder > < drawtype >0</ drawtype > < color >00C800</ color > < yaxisside >0</ yaxisside > < calc_fnc >2</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,expired_keys]</ key > </ item > </ graph_item > </ graph_items > </ graph > < graph > < name >Redis Last_save_time_6379</ name > < width >900</ width > < height >200</ height > < yaxismin >0.0000</ yaxismin > < yaxismax >100.0000</ yaxismax > < show_work_period >1</ show_work_period > < show_triggers >1</ show_triggers > < type >0</ type > < show_legend >1</ show_legend > < show_3d >0</ show_3d > < percent_left >0.0000</ percent_left > < percent_right >0.0000</ percent_right > < ymin_type_1 >0</ ymin_type_1 > < ymax_type_1 >0</ ymax_type_1 > < ymin_item_1 >0</ ymin_item_1 > < ymax_item_1 >0</ ymax_item_1 > < graph_items > < graph_item > < sortorder >0</ sortorder > < drawtype >0</ drawtype > < color >C80000</ color > < yaxisside >0</ yaxisside > < calc_fnc >2</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,last_save_time]</ key > </ item > </ graph_item > </ graph_items > </ graph > < graph > < name >Redis Port Connections_6379</ name > < width >900</ width > < height >200</ height > < yaxismin >0.0000</ yaxismin > < yaxismax >100.0000</ yaxismax > < show_work_period >1</ show_work_period > < show_triggers >0</ show_triggers > < type >0</ type > < show_legend >1</ show_legend > < show_3d >0</ show_3d > < percent_left >0.0000</ percent_left > < percent_right >0.0000</ percent_right > < ymin_type_1 >0</ ymin_type_1 > < ymax_type_1 >0</ ymax_type_1 > < ymin_item_1 >0</ ymin_item_1 > < ymax_item_1 >0</ ymax_item_1 > < graph_items > < graph_item > < sortorder >0</ sortorder > < drawtype >0</ drawtype > < color >EE0000</ color > < yaxisside >0</ yaxisside > < calc_fnc >4</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,blocked_clients]</ key > </ item > </ graph_item > < graph_item > < sortorder >1</ sortorder > < drawtype >0</ drawtype > < color >BBBB00</ color > < yaxisside >0</ yaxisside > < calc_fnc >4</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,total_connections_received]</ key > </ item > </ graph_item > < graph_item > < sortorder >2</ sortorder > < drawtype >0</ drawtype > < color >CC00CC</ color > < yaxisside >0</ yaxisside > < calc_fnc >4</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,total_commands_processed]</ key > </ item > </ graph_item > < graph_item > < sortorder >3</ sortorder > < drawtype >0</ drawtype > < color >00CCCC</ color > < yaxisside >0</ yaxisside > < calc_fnc >4</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,connected_slave]</ key > </ item > </ graph_item > < graph_item > < sortorder >4</ sortorder > < drawtype >0</ drawtype > < color >009900</ color > < yaxisside >0</ yaxisside > < calc_fnc >4</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,connected_clients]</ key > </ item > </ graph_item > </ graph_items > </ graph > < graph > < name >Redis Port status_6379</ name > < width >900</ width > < height >200</ height > < yaxismin >0.0000</ yaxismin > < yaxismax >100.0000</ yaxismax > < show_work_period >1</ show_work_period > < show_triggers >1</ show_triggers > < type >0</ type > < show_legend >1</ show_legend > < show_3d >0</ show_3d > < percent_left >0.0000</ percent_left > < percent_right >0.0000</ percent_right > < ymin_type_1 >0</ ymin_type_1 > < ymax_type_1 >0</ ymax_type_1 > < ymin_item_1 >0</ ymin_item_1 > < ymax_item_1 >0</ ymax_item_1 > < graph_items > < graph_item > < sortorder >0</ sortorder > < drawtype >0</ drawtype > < color >C80000</ color > < yaxisside >0</ yaxisside > < calc_fnc >2</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >net.tcp.listen[6379]</ key > </ item > </ graph_item > </ graph_items > </ graph > < graph > < name >Redis Uptime_in_seconds_6379</ name > < width >900</ width > < height >200</ height > < yaxismin >0.0000</ yaxismin > < yaxismax >100.0000</ yaxismax > < show_work_period >1</ show_work_period > < show_triggers >1</ show_triggers > < type >0</ type > < show_legend >1</ show_legend > < show_3d >0</ show_3d > < percent_left >0.0000</ percent_left > < percent_right >0.0000</ percent_right > < ymin_type_1 >0</ ymin_type_1 > < ymax_type_1 >0</ ymax_type_1 > < ymin_item_1 >0</ ymin_item_1 > < ymax_item_1 >0</ ymax_item_1 > < graph_items > < graph_item > < sortorder >0</ sortorder > < drawtype >0</ drawtype > < color >C80000</ color > < yaxisside >0</ yaxisside > < calc_fnc >2</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,uptime_in_seconds]</ key > </ item > </ graph_item > </ graph_items > </ graph > < graph > < name >Redis Used memory_6379</ name > < width >900</ width > < height >200</ height > < yaxismin >0.0000</ yaxismin > < yaxismax >100.0000</ yaxismax > < show_work_period >1</ show_work_period > < show_triggers >1</ show_triggers > < type >0</ type > < show_legend >1</ show_legend > < show_3d >0</ show_3d > < percent_left >0.0000</ percent_left > < percent_right >0.0000</ percent_right > < ymin_type_1 >0</ ymin_type_1 > < ymax_type_1 >0</ ymax_type_1 > < ymin_item_1 >0</ ymin_item_1 > < ymax_item_1 >0</ ymax_item_1 > < graph_items > < graph_item > < sortorder >0</ sortorder > < drawtype >0</ drawtype > < color >C80000</ color > < yaxisside >0</ yaxisside > < calc_fnc >2</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,used_memory:]</ key > </ item > </ graph_item > < graph_item > < sortorder >1</ sortorder > < drawtype >0</ drawtype > < color >00C8C8</ color > < yaxisside >0</ yaxisside > < calc_fnc >2</ calc_fnc > < type >0</ type > < item > < host >Templates Redis_6379</ host > < key >redis_stats[6379,used_memory_rss]</ key > </ item > </ graph_item > </ graph_items > </ graph > </ graphs > </ zabbix_export > |