windows服务器
配置
监控redis主要是使用redis的命令redis-cli.exe
来监控。
新建一个Redis_Status.vbs脚本
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = getCommandOutput("E:\vortex\redis\redis-latest(3.0.501)\redis-cli.exe -h 127.0.0.1 -p "+objArgs(0)+" -a 123456 info")
Arg = objArgs(1)
str2 = Split(str1,vbCrLf)
For i = LBound(str2) to UBound(str2)
str3 = Split(str2(i),":")
If Trim(str3(0)) = Arg Then
WScript.Echo TRIM(str3(1))
Exit For
End If
next
Function getCommandOutput(theCommand)
Dim objShell, objCmdExec
Set objShell = CreateObject("WScript.Shell")
Set objCmdExec = objshell.exec(thecommand)
getCommandOutput = objCmdExec.StdOut.ReadAll
end Function
打开 zabbix_agentd.win.conf
文件,去除这行的注释
Include=c:\zabbix\zabbix_agentd.conf.d\*.conf
并且新建这个目录,在其下新建redis.conf,内容如下:
UserParameter=redis_stats[*],cscript /nologo C:\zabbix\conf\Redis_Status.vbs $1 $2
导入模板
模板zbx_redis_templates.xml的内容如下:
<zabbix_export>
<version>3.0version>
<date>2017-03-24T08:58:19Zdate>
<groups>
<group>
<name>Templatesname>
group>
groups>
<templates>
<template>
<template>Templates Redis_6379template>
<name>Templates Redis_6379name>
<description/>
<groups>
<group>
<name>Templatesname>
group>
groups>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<items>
<item>
<name>port status_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>net.tcp.listen[6379]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Blocked clients_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,blocked_clients]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Connected clients_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,connected_clients]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Connected slave_6380name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,connected_slave]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Evicted_keys_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,evicted_keys]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Expired keys_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,expired_keys]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Last save time_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,last_save_time]key>
<delay>60delay>
<history>3history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units>unixtimeunits>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Role_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,role]key>
<delay>60delay>
<history>3history>
<trends>0trends>
<status>0status>
<value_type>1value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Request rate_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,total_commands_processed]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>1delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Connection rate_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,total_connections_received]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>1delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Uptime in seconds_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,uptime_in_seconds]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units>uptimeunits>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Used memory_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,used_memory:]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
application>
applications>
<valuemap/>
<logtimefmt/>
item>
<item>
<name>Used_memory_rss_6379name>
<type>0type>
<snmp_community/>
<multiplier>0multiplier>
<snmp_oid/>
<key>redis_stats[6379,used_memory_rss]key>
<delay>60delay>
<history>7history>
<trends>365trends>
<status>0status>
<value_type>3value_type>
<allowed_hosts/>
<units/>
<delta>0delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0snmpv3_securitylevel>
<snmpv3_authprotocol>0snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0data_type>
<authtype>0authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0inventory_link>
<applications>
<application>
<name>Redis_6379name>
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")}=3expression>
<name>Redis port 6379 is not runningname>
<url/>
<status>0status>
<priority>4priority>
<description/>
<type>0type>
<dependencies/>
trigger>
triggers>
<graphs>
<graph>
<name>Redis key_6379name>
<width>900width>
<height>200height>
<yaxismin>0.0000yaxismin>
<yaxismax>100.0000yaxismax>
<show_work_period>1show_work_period>
<show_triggers>1show_triggers>
<type>0type>
<show_legend>1show_legend>
<show_3d>0show_3d>
<percent_left>0.0000percent_left>
<percent_right>0.0000percent_right>
<ymin_type_1>0ymin_type_1>
<ymax_type_1>0ymax_type_1>
<ymin_item_1>0ymin_item_1>
<ymax_item_1>0ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0sortorder>
<drawtype>0drawtype>
<color>C80000color>
<yaxisside>0yaxisside>
<calc_fnc>2calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,evicted_keys]key>
item>
graph_item>
<graph_item>
<sortorder>1sortorder>
<drawtype>0drawtype>
<color>00C800color>
<yaxisside>0yaxisside>
<calc_fnc>2calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,expired_keys]key>
item>
graph_item>
graph_items>
graph>
<graph>
<name>Redis Last_save_time_6379name>
<width>900width>
<height>200height>
<yaxismin>0.0000yaxismin>
<yaxismax>100.0000yaxismax>
<show_work_period>1show_work_period>
<show_triggers>1show_triggers>
<type>0type>
<show_legend>1show_legend>
<show_3d>0show_3d>
<percent_left>0.0000percent_left>
<percent_right>0.0000percent_right>
<ymin_type_1>0ymin_type_1>
<ymax_type_1>0ymax_type_1>
<ymin_item_1>0ymin_item_1>
<ymax_item_1>0ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0sortorder>
<drawtype>0drawtype>
<color>C80000color>
<yaxisside>0yaxisside>
<calc_fnc>2calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,last_save_time]key>
item>
graph_item>
graph_items>
graph>
<graph>
<name>Redis Port Connections_6379name>
<width>900width>
<height>200height>
<yaxismin>0.0000yaxismin>
<yaxismax>100.0000yaxismax>
<show_work_period>1show_work_period>
<show_triggers>0show_triggers>
<type>0type>
<show_legend>1show_legend>
<show_3d>0show_3d>
<percent_left>0.0000percent_left>
<percent_right>0.0000percent_right>
<ymin_type_1>0ymin_type_1>
<ymax_type_1>0ymax_type_1>
<ymin_item_1>0ymin_item_1>
<ymax_item_1>0ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0sortorder>
<drawtype>0drawtype>
<color>EE0000color>
<yaxisside>0yaxisside>
<calc_fnc>4calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,blocked_clients]key>
item>
graph_item>
<graph_item>
<sortorder>1sortorder>
<drawtype>0drawtype>
<color>BBBB00color>
<yaxisside>0yaxisside>
<calc_fnc>4calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,total_connections_received]key>
item>
graph_item>
<graph_item>
<sortorder>2sortorder>
<drawtype>0drawtype>
<color>CC00CCcolor>
<yaxisside>0yaxisside>
<calc_fnc>4calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,total_commands_processed]key>
item>
graph_item>
<graph_item>
<sortorder>3sortorder>
<drawtype>0drawtype>
<color>00CCCCcolor>
<yaxisside>0yaxisside>
<calc_fnc>4calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,connected_slave]key>
item>
graph_item>
<graph_item>
<sortorder>4sortorder>
<drawtype>0drawtype>
<color>009900color>
<yaxisside>0yaxisside>
<calc_fnc>4calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,connected_clients]key>
item>
graph_item>
graph_items>
graph>
<graph>
<name>Redis Port status_6379name>
<width>900width>
<height>200height>
<yaxismin>0.0000yaxismin>
<yaxismax>100.0000yaxismax>
<show_work_period>1show_work_period>
<show_triggers>1show_triggers>
<type>0type>
<show_legend>1show_legend>
<show_3d>0show_3d>
<percent_left>0.0000percent_left>
<percent_right>0.0000percent_right>
<ymin_type_1>0ymin_type_1>
<ymax_type_1>0ymax_type_1>
<ymin_item_1>0ymin_item_1>
<ymax_item_1>0ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0sortorder>
<drawtype>0drawtype>
<color>C80000color>
<yaxisside>0yaxisside>
<calc_fnc>2calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>net.tcp.listen[6379]key>
item>
graph_item>
graph_items>
graph>
<graph>
<name>Redis Uptime_in_seconds_6379name>
<width>900width>
<height>200height>
<yaxismin>0.0000yaxismin>
<yaxismax>100.0000yaxismax>
<show_work_period>1show_work_period>
<show_triggers>1show_triggers>
<type>0type>
<show_legend>1show_legend>
<show_3d>0show_3d>
<percent_left>0.0000percent_left>
<percent_right>0.0000percent_right>
<ymin_type_1>0ymin_type_1>
<ymax_type_1>0ymax_type_1>
<ymin_item_1>0ymin_item_1>
<ymax_item_1>0ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0sortorder>
<drawtype>0drawtype>
<color>C80000color>
<yaxisside>0yaxisside>
<calc_fnc>2calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,uptime_in_seconds]key>
item>
graph_item>
graph_items>
graph>
<graph>
<name>Redis Used memory_6379name>
<width>900width>
<height>200height>
<yaxismin>0.0000yaxismin>
<yaxismax>100.0000yaxismax>
<show_work_period>1show_work_period>
<show_triggers>1show_triggers>
<type>0type>
<show_legend>1show_legend>
<show_3d>0show_3d>
<percent_left>0.0000percent_left>
<percent_right>0.0000percent_right>
<ymin_type_1>0ymin_type_1>
<ymax_type_1>0ymax_type_1>
<ymin_item_1>0ymin_item_1>
<ymax_item_1>0ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0sortorder>
<drawtype>0drawtype>
<color>C80000color>
<yaxisside>0yaxisside>
<calc_fnc>2calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,used_memory:]key>
item>
graph_item>
<graph_item>
<sortorder>1sortorder>
<drawtype>0drawtype>
<color>00C8C8color>
<yaxisside>0yaxisside>
<calc_fnc>2calc_fnc>
<type>0type>
<item>
<host>Templates Redis_6379host>
<key>redis_stats[6379,used_memory_rss]key>
item>
graph_item>
graph_items>
graph>
graphs>
zabbix_export>