zoukankan      html  css  js  c++  java
  • Zabbix监控Tomcat,Redis

     一 Tomcat监控

    1.1.1 Tomcat 端配置 JMX

        编辑catalina.sh文件,配置如下:

    CATALINA_OPTS="$CATALINA_OPTS
    -Dcom.sun.management.jmxremote                      # 启用远程监控JMX
    -Dcom.sun.management.jmxremote.port=12345           # 默认启动的JMX端口号,要和zabbix添加主机的端口一致
    -Dcom.sun.management.jmxremote.authenticate=false   # 不使用用户名密码认证
    -Dcom.sun.management.jmxremote.ssl=false            # 不适用ssl认证
    -Djava.rmi.server.hostname=172.16.0.20"             # tomcat主机地址
    

        重启Tomcat

    /usr/local/tomcat/bin/shutdown.sh 
    /usr/local/tomcat/bin/startup.sh 
    ~]# ss -lnt
    State      Recv-Q Send-Q                                        Local Address:Port                                                       Peer Address:Port              
    LISTEN     0      50                                                       :::12345                                                                :::*                  
                             

    1.1.2 编译zabbix server,加入对java支持

        默认情况下,zabbix server 是没有加入java支持,所以要让zabbix监控tomcat,就需要开启zabbix监控java的专用服务zabbix-java-gateway.

    yum install -y  java  java-devel  zabbix-java-gateway
    

      编辑zabbix-java-gateway配置文件

    ~]# grep ^[a-Z] /etc/zabbix/zabbix_java_gateway.conf 
    LISTEN_IP="0.0.0.0"                                          # 监听地址
    LISTEN_PORT=10052                                         # 监听端口
    PID_FILE="/var/run/zabbix/zabbix_java.pid"        # pid文件
    START_POLLERS=20                                           # 启动多少线程轮训java,要和java应用保持一定短息 
    TIMEOUT=30                                                      # 超时时间                                                  
    

      配置zabbix server调用java gateway

    ~]# grep ^[a-Z] /etc/zabbix/zabbix_server.conf 
    JavaGateway=172.16.0.88                  # 指定java gateway的地址            
    JavaGatewayPort=10052                     # 指定java gateway的服务器监听端口,如果是默认端口可不写
    StartJavaPollers=20                             # 轮训
    Timeout=30              # 超时时间
    

    1.1.3 图形化配置

        导入模板

      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <zabbix_export>
      3     <version>3.0</version>
      4     <date>2018-06-26T13:09:54Z</date>
      5     <groups>
      6         <group>
      7             <name>Templates</name>
      8         </group>
      9     </groups>
     10     <templates>
     11         <template>
     12             <template>Tomcat JMX</template>
     13             <name>Tomcat JMX</name>
     14             <description/>
     15             <groups>
     16                 <group>
     17                     <name>Templates</name>
     18                 </group>
     19             </groups>
     20             <applications>
     21                 <application>
     22                     <name>class</name>
     23                 </application>
     24                 <application>
     25                     <name>HeapStatistics</name>
     26                 </application>
     27                 <application>
     28                     <name>Sessions</name>
     29                 </application>
     30                 <application>
     31                     <name>ThreadStatistics</name>
     32                 </application>
     33                 <application>
     34                     <name>Tomcat</name>
     35                 </application>
     36             </applications>
     37             <items>
     38                 <item>
     39                     <name>Sessions-当前活动会话数</name>
     40                     <type>16</type>
     41                     <snmp_community/>
     42                     <multiplier>0</multiplier>
     43                     <snmp_oid/>
     44                     <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,activeSessions]</key>
     45                     <delay>30</delay>
     46                     <history>90</history>
     47                     <trends>365</trends>
     48                     <status>0</status>
     49                     <value_type>3</value_type>
     50                     <allowed_hosts/>
     51                     <units/>
     52                     <delta>0</delta>
     53                     <snmpv3_contextname/>
     54                     <snmpv3_securityname/>
     55                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     56                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     57                     <snmpv3_authpassphrase/>
     58                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     59                     <snmpv3_privpassphrase/>
     60                     <formula>1</formula>
     61                     <delay_flex/>
     62                     <params/>
     63                     <ipmi_sensor/>
     64                     <data_type>0</data_type>
     65                     <authtype>0</authtype>
     66                     <username/>
     67                     <password/>
     68                     <publickey/>
     69                     <privatekey/>
     70                     <port/>
     71                     <description/>
     72                     <inventory_link>0</inventory_link>
     73                     <applications>
     74                         <application>
     75                             <name>Sessions</name>
     76                         </application>
     77                     </applications>
     78                     <valuemap/>
     79                     <logtimefmt/>
     80                 </item>
     81                 <item>
     82                     <name>Sessions-The maximum number of active Sessions allowed, or -1 for no limit</name>
     83                     <type>16</type>
     84                     <snmp_community/>
     85                     <multiplier>0</multiplier>
     86                     <snmp_oid/>
     87                     <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,maxActiveSessions]</key>
     88                     <delay>30</delay>
     89                     <history>90</history>
     90                     <trends>365</trends>
     91                     <status>0</status>
     92                     <value_type>0</value_type>
     93                     <allowed_hosts/>
     94                     <units/>
     95                     <delta>0</delta>
     96                     <snmpv3_contextname/>
     97                     <snmpv3_securityname/>
     98                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     99                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    100                     <snmpv3_authpassphrase/>
    101                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    102                     <snmpv3_privpassphrase/>
    103                     <formula>1</formula>
    104                     <delay_flex/>
    105                     <params/>
    106                     <ipmi_sensor/>
    107                     <data_type>0</data_type>
    108                     <authtype>0</authtype>
    109                     <username/>
    110                     <password/>
    111                     <publickey/>
    112                     <privatekey/>
    113                     <port/>
    114                     <description/>
    115                     <inventory_link>0</inventory_link>
    116                     <applications>
    117                         <application>
    118                             <name>Sessions</name>
    119                         </application>
    120                     </applications>
    121                     <valuemap/>
    122                     <logtimefmt/>
    123                 </item>
    124                 <item>
    125                     <name>Sessions-最大活动会话数</name>
    126                     <type>16</type>
    127                     <snmp_community/>
    128                     <multiplier>0</multiplier>
    129                     <snmp_oid/>
    130                     <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,maxActive]</key>
    131                     <delay>30</delay>
    132                     <history>90</history>
    133                     <trends>365</trends>
    134                     <status>0</status>
    135                     <value_type>3</value_type>
    136                     <allowed_hosts/>
    137                     <units/>
    138                     <delta>0</delta>
    139                     <snmpv3_contextname/>
    140                     <snmpv3_securityname/>
    141                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    142                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    143                     <snmpv3_authpassphrase/>
    144                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    145                     <snmpv3_privpassphrase/>
    146                     <formula>1</formula>
    147                     <delay_flex/>
    148                     <params/>
    149                     <ipmi_sensor/>
    150                     <data_type>0</data_type>
    151                     <authtype>0</authtype>
    152                     <username/>
    153                     <password/>
    154                     <publickey/>
    155                     <privatekey/>
    156                     <port/>
    157                     <description/>
    158                     <inventory_link>0</inventory_link>
    159                     <applications>
    160                         <application>
    161                             <name>Sessions</name>
    162                         </application>
    163                     </applications>
    164                     <valuemap/>
    165                     <logtimefmt/>
    166                 </item>
    167                 <item>
    168                     <name>Sessions-Number of sessions we rejected due to maxActive beeing reached</name>
    169                     <type>16</type>
    170                     <snmp_community/>
    171                     <multiplier>0</multiplier>
    172                     <snmp_oid/>
    173                     <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,rejectedSessions]</key>
    174                     <delay>30</delay>
    175                     <history>90</history>
    176                     <trends>365</trends>
    177                     <status>0</status>
    178                     <value_type>3</value_type>
    179                     <allowed_hosts/>
    180                     <units/>
    181                     <delta>0</delta>
    182                     <snmpv3_contextname/>
    183                     <snmpv3_securityname/>
    184                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    185                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    186                     <snmpv3_authpassphrase/>
    187                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    188                     <snmpv3_privpassphrase/>
    189                     <formula>1</formula>
    190                     <delay_flex/>
    191                     <params/>
    192                     <ipmi_sensor/>
    193                     <data_type>0</data_type>
    194                     <authtype>0</authtype>
    195                     <username/>
    196                     <password/>
    197                     <publickey/>
    198                     <privatekey/>
    199                     <port/>
    200                     <description/>
    201                     <inventory_link>0</inventory_link>
    202                     <applications>
    203                         <application>
    204                             <name>Sessions</name>
    205                         </application>
    206                     </applications>
    207                     <valuemap/>
    208                     <logtimefmt/>
    209                 </item>
    210                 <item>
    211                     <name>Sessions-会话数</name>
    212                     <type>16</type>
    213                     <snmp_community/>
    214                     <multiplier>0</multiplier>
    215                     <snmp_oid/>
    216                     <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,sessionCounter]</key>
    217                     <delay>30</delay>
    218                     <history>90</history>
    219                     <trends>365</trends>
    220                     <status>0</status>
    221                     <value_type>3</value_type>
    222                     <allowed_hosts/>
    223                     <units/>
    224                     <delta>0</delta>
    225                     <snmpv3_contextname/>
    226                     <snmpv3_securityname/>
    227                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    228                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    229                     <snmpv3_authpassphrase/>
    230                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    231                     <snmpv3_privpassphrase/>
    232                     <formula>1</formula>
    233                     <delay_flex/>
    234                     <params/>
    235                     <ipmi_sensor/>
    236                     <data_type>0</data_type>
    237                     <authtype>0</authtype>
    238                     <username/>
    239                     <password/>
    240                     <publickey/>
    241                     <privatekey/>
    242                     <port/>
    243                     <description/>
    244                     <inventory_link>0</inventory_link>
    245                     <applications>
    246                         <application>
    247                             <name>Sessions</name>
    248                         </application>
    249                     </applications>
    250                     <valuemap/>
    251                     <logtimefmt/>
    252                 </item>
    253                 <item>
    254                     <name>http-8080 gzip compression</name>
    255                     <type>16</type>
    256                     <snmp_community/>
    257                     <multiplier>0</multiplier>
    258                     <snmp_oid/>
    259                     <key>jmx[&quot;Catalina:type=ProtocolHandler,port=8080&quot;,compression]</key>
    260                     <delay>30</delay>
    261                     <history>90</history>
    262                     <trends>0</trends>
    263                     <status>0</status>
    264                     <value_type>1</value_type>
    265                     <allowed_hosts/>
    266                     <units/>
    267                     <delta>0</delta>
    268                     <snmpv3_contextname/>
    269                     <snmpv3_securityname/>
    270                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    271                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    272                     <snmpv3_authpassphrase/>
    273                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    274                     <snmpv3_privpassphrase/>
    275                     <formula>1</formula>
    276                     <delay_flex/>
    277                     <params/>
    278                     <ipmi_sensor/>
    279                     <data_type>0</data_type>
    280                     <authtype>0</authtype>
    281                     <username/>
    282                     <password/>
    283                     <publickey/>
    284                     <privatekey/>
    285                     <port/>
    286                     <description/>
    287                     <inventory_link>0</inventory_link>
    288                     <applications/>
    289                     <valuemap/>
    290                     <logtimefmt/>
    291                 </item>
    292                 <item>
    293                     <name>Tomcat version</name>
    294                     <type>16</type>
    295                     <snmp_community/>
    296                     <multiplier>0</multiplier>
    297                     <snmp_oid/>
    298                     <key>jmx[&quot;Catalina:type=Server&quot;,serverInfo]</key>
    299                     <delay>30</delay>
    300                     <history>90</history>
    301                     <trends>0</trends>
    302                     <status>0</status>
    303                     <value_type>1</value_type>
    304                     <allowed_hosts/>
    305                     <units/>
    306                     <delta>0</delta>
    307                     <snmpv3_contextname/>
    308                     <snmpv3_securityname/>
    309                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    310                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    311                     <snmpv3_authpassphrase/>
    312                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    313                     <snmpv3_privpassphrase/>
    314                     <formula>1</formula>
    315                     <delay_flex/>
    316                     <params/>
    317                     <ipmi_sensor/>
    318                     <data_type>0</data_type>
    319                     <authtype>0</authtype>
    320                     <username/>
    321                     <password/>
    322                     <publickey/>
    323                     <privatekey/>
    324                     <port/>
    325                     <description/>
    326                     <inventory_link>0</inventory_link>
    327                     <applications>
    328                         <application>
    329                             <name>Tomcat</name>
    330                         </application>
    331                     </applications>
    332                     <valuemap/>
    333                     <logtimefmt/>
    334                 </item>
    335                 <item>
    336                     <name>类-已加载</name>
    337                     <type>16</type>
    338                     <snmp_community/>
    339                     <multiplier>0</multiplier>
    340                     <snmp_oid/>
    341                     <key>jmx[&quot;java.lang:type=ClassLoading&quot;,&quot;LoadedClassCount&quot;]</key>
    342                     <delay>30</delay>
    343                     <history>90</history>
    344                     <trends>365</trends>
    345                     <status>0</status>
    346                     <value_type>3</value_type>
    347                     <allowed_hosts/>
    348                     <units/>
    349                     <delta>0</delta>
    350                     <snmpv3_contextname/>
    351                     <snmpv3_securityname/>
    352                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    353                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    354                     <snmpv3_authpassphrase/>
    355                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    356                     <snmpv3_privpassphrase/>
    357                     <formula>1</formula>
    358                     <delay_flex/>
    359                     <params/>
    360                     <ipmi_sensor/>
    361                     <data_type>0</data_type>
    362                     <authtype>0</authtype>
    363                     <username/>
    364                     <password/>
    365                     <publickey/>
    366                     <privatekey/>
    367                     <port/>
    368                     <description/>
    369                     <inventory_link>0</inventory_link>
    370                     <applications>
    371                         <application>
    372                             <name>class</name>
    373                         </application>
    374                     </applications>
    375                     <valuemap/>
    376                     <logtimefmt/>
    377                 </item>
    378                 <item>
    379                     <name>类-总计</name>
    380                     <type>16</type>
    381                     <snmp_community/>
    382                     <multiplier>0</multiplier>
    383                     <snmp_oid/>
    384                     <key>jmx[&quot;java.lang:type=ClassLoading&quot;,&quot;TotalLoadedClassCount&quot;]</key>
    385                     <delay>30</delay>
    386                     <history>90</history>
    387                     <trends>365</trends>
    388                     <status>0</status>
    389                     <value_type>3</value_type>
    390                     <allowed_hosts/>
    391                     <units/>
    392                     <delta>0</delta>
    393                     <snmpv3_contextname/>
    394                     <snmpv3_securityname/>
    395                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    396                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    397                     <snmpv3_authpassphrase/>
    398                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    399                     <snmpv3_privpassphrase/>
    400                     <formula>1</formula>
    401                     <delay_flex/>
    402                     <params/>
    403                     <ipmi_sensor/>
    404                     <data_type>0</data_type>
    405                     <authtype>0</authtype>
    406                     <username/>
    407                     <password/>
    408                     <publickey/>
    409                     <privatekey/>
    410                     <port/>
    411                     <description/>
    412                     <inventory_link>0</inventory_link>
    413                     <applications>
    414                         <application>
    415                             <name>class</name>
    416                         </application>
    417                     </applications>
    418                     <valuemap/>
    419                     <logtimefmt/>
    420                 </item>
    421                 <item>
    422                     <name>类-已卸载</name>
    423                     <type>16</type>
    424                     <snmp_community/>
    425                     <multiplier>0</multiplier>
    426                     <snmp_oid/>
    427                     <key>jmx[&quot;java.lang:type=ClassLoading&quot;,&quot;UnloadedClassCount&quot;]</key>
    428                     <delay>30</delay>
    429                     <history>90</history>
    430                     <trends>365</trends>
    431                     <status>0</status>
    432                     <value_type>3</value_type>
    433                     <allowed_hosts/>
    434                     <units/>
    435                     <delta>0</delta>
    436                     <snmpv3_contextname/>
    437                     <snmpv3_securityname/>
    438                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    439                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    440                     <snmpv3_authpassphrase/>
    441                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    442                     <snmpv3_privpassphrase/>
    443                     <formula>1</formula>
    444                     <delay_flex/>
    445                     <params/>
    446                     <ipmi_sensor/>
    447                     <data_type>0</data_type>
    448                     <authtype>0</authtype>
    449                     <username/>
    450                     <password/>
    451                     <publickey/>
    452                     <privatekey/>
    453                     <port/>
    454                     <description/>
    455                     <inventory_link>0</inventory_link>
    456                     <applications>
    457                         <application>
    458                             <name>class</name>
    459                         </application>
    460                     </applications>
    461                     <valuemap/>
    462                     <logtimefmt/>
    463                 </item>
    464                 <item>
    465                     <name>堆内存已提交</name>
    466                     <type>16</type>
    467                     <snmp_community/>
    468                     <multiplier>0</multiplier>
    469                     <snmp_oid/>
    470                     <key>jmx[&quot;java.lang:type=Memory&quot;,&quot;HeapMemoryUsage.committed&quot;]</key>
    471                     <delay>30</delay>
    472                     <history>90</history>
    473                     <trends>365</trends>
    474                     <status>0</status>
    475                     <value_type>3</value_type>
    476                     <allowed_hosts/>
    477                     <units/>
    478                     <delta>0</delta>
    479                     <snmpv3_contextname/>
    480                     <snmpv3_securityname/>
    481                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    482                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    483                     <snmpv3_authpassphrase/>
    484                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    485                     <snmpv3_privpassphrase/>
    486                     <formula>1</formula>
    487                     <delay_flex/>
    488                     <params/>
    489                     <ipmi_sensor/>
    490                     <data_type>0</data_type>
    491                     <authtype>0</authtype>
    492                     <username/>
    493                     <password/>
    494                     <publickey/>
    495                     <privatekey/>
    496                     <port/>
    497                     <description/>
    498                     <inventory_link>0</inventory_link>
    499                     <applications>
    500                         <application>
    501                             <name>HeapStatistics</name>
    502                         </application>
    503                     </applications>
    504                     <valuemap/>
    505                     <logtimefmt/>
    506                 </item>
    507                 <item>
    508                     <name>堆内存最大</name>
    509                     <type>16</type>
    510                     <snmp_community/>
    511                     <multiplier>0</multiplier>
    512                     <snmp_oid/>
    513                     <key>jmx[&quot;java.lang:type=Memory&quot;,&quot;HeapMemoryUsage.max&quot;]</key>
    514                     <delay>30</delay>
    515                     <history>90</history>
    516                     <trends>365</trends>
    517                     <status>0</status>
    518                     <value_type>3</value_type>
    519                     <allowed_hosts/>
    520                     <units/>
    521                     <delta>0</delta>
    522                     <snmpv3_contextname/>
    523                     <snmpv3_securityname/>
    524                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    525                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    526                     <snmpv3_authpassphrase/>
    527                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    528                     <snmpv3_privpassphrase/>
    529                     <formula>1</formula>
    530                     <delay_flex/>
    531                     <params/>
    532                     <ipmi_sensor/>
    533                     <data_type>0</data_type>
    534                     <authtype>0</authtype>
    535                     <username/>
    536                     <password/>
    537                     <publickey/>
    538                     <privatekey/>
    539                     <port/>
    540                     <description/>
    541                     <inventory_link>0</inventory_link>
    542                     <applications>
    543                         <application>
    544                             <name>HeapStatistics</name>
    545                         </application>
    546                     </applications>
    547                     <valuemap/>
    548                     <logtimefmt/>
    549                 </item>
    550                 <item>
    551                     <name>堆内存已使用</name>
    552                     <type>16</type>
    553                     <snmp_community/>
    554                     <multiplier>0</multiplier>
    555                     <snmp_oid/>
    556                     <key>jmx[&quot;java.lang:type=Memory&quot;,&quot;HeapMemoryUsage.used&quot;]</key>
    557                     <delay>30</delay>
    558                     <history>90</history>
    559                     <trends>365</trends>
    560                     <status>0</status>
    561                     <value_type>3</value_type>
    562                     <allowed_hosts/>
    563                     <units/>
    564                     <delta>0</delta>
    565                     <snmpv3_contextname/>
    566                     <snmpv3_securityname/>
    567                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    568                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    569                     <snmpv3_authpassphrase/>
    570                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    571                     <snmpv3_privpassphrase/>
    572                     <formula>1</formula>
    573                     <delay_flex/>
    574                     <params/>
    575                     <ipmi_sensor/>
    576                     <data_type>0</data_type>
    577                     <authtype>0</authtype>
    578                     <username/>
    579                     <password/>
    580                     <publickey/>
    581                     <privatekey/>
    582                     <port/>
    583                     <description/>
    584                     <inventory_link>0</inventory_link>
    585                     <applications>
    586                         <application>
    587                             <name>HeapStatistics</name>
    588                         </application>
    589                     </applications>
    590                     <valuemap/>
    591                     <logtimefmt/>
    592                 </item>
    593                 <item>
    594                     <name>http-8080线程峰值</name>
    595                     <type>16</type>
    596                     <snmp_community/>
    597                     <multiplier>0</multiplier>
    598                     <snmp_oid/>
    599                     <key>jmx[&quot;java.lang:type=Threading&quot;,&quot;PeakThreadCount&quot;]</key>
    600                     <delay>30</delay>
    601                     <history>90</history>
    602                     <trends>365</trends>
    603                     <status>0</status>
    604                     <value_type>3</value_type>
    605                     <allowed_hosts/>
    606                     <units/>
    607                     <delta>0</delta>
    608                     <snmpv3_contextname/>
    609                     <snmpv3_securityname/>
    610                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    611                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    612                     <snmpv3_authpassphrase/>
    613                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    614                     <snmpv3_privpassphrase/>
    615                     <formula>1</formula>
    616                     <delay_flex/>
    617                     <params/>
    618                     <ipmi_sensor/>
    619                     <data_type>0</data_type>
    620                     <authtype>0</authtype>
    621                     <username/>
    622                     <password/>
    623                     <publickey/>
    624                     <privatekey/>
    625                     <port/>
    626                     <description/>
    627                     <inventory_link>0</inventory_link>
    628                     <applications>
    629                         <application>
    630                             <name>ThreadStatistics</name>
    631                         </application>
    632                     </applications>
    633                     <valuemap/>
    634                     <logtimefmt/>
    635                 </item>
    636                 <item>
    637                     <name>http-8080活动线程</name>
    638                     <type>16</type>
    639                     <snmp_community/>
    640                     <multiplier>0</multiplier>
    641                     <snmp_oid/>
    642                     <key>jmx[&quot;java.lang:type=Threading&quot;,&quot;ThreadCount&quot;]</key>
    643                     <delay>30</delay>
    644                     <history>90</history>
    645                     <trends>365</trends>
    646                     <status>0</status>
    647                     <value_type>3</value_type>
    648                     <allowed_hosts/>
    649                     <units/>
    650                     <delta>0</delta>
    651                     <snmpv3_contextname/>
    652                     <snmpv3_securityname/>
    653                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    654                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    655                     <snmpv3_authpassphrase/>
    656                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    657                     <snmpv3_privpassphrase/>
    658                     <formula>1</formula>
    659                     <delay_flex/>
    660                     <params/>
    661                     <ipmi_sensor/>
    662                     <data_type>0</data_type>
    663                     <authtype>0</authtype>
    664                     <username/>
    665                     <password/>
    666                     <publickey/>
    667                     <privatekey/>
    668                     <port/>
    669                     <description/>
    670                     <inventory_link>0</inventory_link>
    671                     <applications>
    672                         <application>
    673                             <name>ThreadStatistics</name>
    674                         </application>
    675                     </applications>
    676                     <valuemap/>
    677                     <logtimefmt/>
    678                 </item>
    679                 <item>
    680                     <name>http-8080线程总计</name>
    681                     <type>16</type>
    682                     <snmp_community/>
    683                     <multiplier>0</multiplier>
    684                     <snmp_oid/>
    685                     <key>jmx[&quot;java.lang:type=Threading&quot;,&quot;TotalStartedThreadCount&quot;]</key>
    686                     <delay>30</delay>
    687                     <history>90</history>
    688                     <trends>365</trends>
    689                     <status>0</status>
    690                     <value_type>3</value_type>
    691                     <allowed_hosts/>
    692                     <units/>
    693                     <delta>0</delta>
    694                     <snmpv3_contextname/>
    695                     <snmpv3_securityname/>
    696                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
    697                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
    698                     <snmpv3_authpassphrase/>
    699                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
    700                     <snmpv3_privpassphrase/>
    701                     <formula>1</formula>
    702                     <delay_flex/>
    703                     <params/>
    704                     <ipmi_sensor/>
    705                     <data_type>0</data_type>
    706                     <authtype>0</authtype>
    707                     <username/>
    708                     <password/>
    709                     <publickey/>
    710                     <privatekey/>
    711                     <port/>
    712                     <description/>
    713                     <inventory_link>0</inventory_link>
    714                     <applications>
    715                         <application>
    716                             <name>ThreadStatistics</name>
    717                         </application>
    718                     </applications>
    719                     <valuemap/>
    720                     <logtimefmt/>
    721                 </item>
    722             </items>
    723             <discovery_rules/>
    724             <macros/>
    725             <templates/>
    726             <screens/>
    727         </template>
    728     </templates>
    729     <graphs>
    730         <graph>
    731             <name>会话状态</name>
    732             <width>900</width>
    733             <height>200</height>
    734             <yaxismin>0.0000</yaxismin>
    735             <yaxismax>100.0000</yaxismax>
    736             <show_work_period>1</show_work_period>
    737             <show_triggers>1</show_triggers>
    738             <type>0</type>
    739             <show_legend>1</show_legend>
    740             <show_3d>0</show_3d>
    741             <percent_left>0.0000</percent_left>
    742             <percent_right>0.0000</percent_right>
    743             <ymin_type_1>0</ymin_type_1>
    744             <ymax_type_1>0</ymax_type_1>
    745             <ymin_item_1>0</ymin_item_1>
    746             <ymax_item_1>0</ymax_item_1>
    747             <graph_items>
    748                 <graph_item>
    749                     <sortorder>0</sortorder>
    750                     <drawtype>0</drawtype>
    751                     <color>C80000</color>
    752                     <yaxisside>0</yaxisside>
    753                     <calc_fnc>2</calc_fnc>
    754                     <type>0</type>
    755                     <item>
    756                         <host>Tomcat JMX</host>
    757                         <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,maxActive]</key>
    758                     </item>
    759                 </graph_item>
    760                 <graph_item>
    761                     <sortorder>1</sortorder>
    762                     <drawtype>0</drawtype>
    763                     <color>00C800</color>
    764                     <yaxisside>0</yaxisside>
    765                     <calc_fnc>2</calc_fnc>
    766                     <type>0</type>
    767                     <item>
    768                         <host>Tomcat JMX</host>
    769                         <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,activeSessions]</key>
    770                     </item>
    771                 </graph_item>
    772                 <graph_item>
    773                     <sortorder>2</sortorder>
    774                     <drawtype>0</drawtype>
    775                     <color>0000C8</color>
    776                     <yaxisside>0</yaxisside>
    777                     <calc_fnc>2</calc_fnc>
    778                     <type>0</type>
    779                     <item>
    780                         <host>Tomcat JMX</host>
    781                         <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,sessionCounter]</key>
    782                     </item>
    783                 </graph_item>
    784                 <graph_item>
    785                     <sortorder>3</sortorder>
    786                     <drawtype>0</drawtype>
    787                     <color>C800C8</color>
    788                     <yaxisside>0</yaxisside>
    789                     <calc_fnc>2</calc_fnc>
    790                     <type>0</type>
    791                     <item>
    792                         <host>Tomcat JMX</host>
    793                         <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,rejectedSessions]</key>
    794                     </item>
    795                 </graph_item>
    796                 <graph_item>
    797                     <sortorder>4</sortorder>
    798                     <drawtype>0</drawtype>
    799                     <color>00C8C8</color>
    800                     <yaxisside>0</yaxisside>
    801                     <calc_fnc>2</calc_fnc>
    802                     <type>0</type>
    803                     <item>
    804                         <host>Tomcat JMX</host>
    805                         <key>jmx[&quot;Catalina:type=Manager,context=/,host=localhost&quot;,maxActiveSessions]</key>
    806                     </item>
    807                 </graph_item>
    808             </graph_items>
    809         </graph>
    810         <graph>
    811             <name>堆内存状态</name>
    812             <width>900</width>
    813             <height>200</height>
    814             <yaxismin>0.0000</yaxismin>
    815             <yaxismax>100.0000</yaxismax>
    816             <show_work_period>1</show_work_period>
    817             <show_triggers>1</show_triggers>
    818             <type>0</type>
    819             <show_legend>1</show_legend>
    820             <show_3d>0</show_3d>
    821             <percent_left>0.0000</percent_left>
    822             <percent_right>0.0000</percent_right>
    823             <ymin_type_1>0</ymin_type_1>
    824             <ymax_type_1>0</ymax_type_1>
    825             <ymin_item_1>0</ymin_item_1>
    826             <ymax_item_1>0</ymax_item_1>
    827             <graph_items>
    828                 <graph_item>
    829                     <sortorder>0</sortorder>
    830                     <drawtype>0</drawtype>
    831                     <color>C80000</color>
    832                     <yaxisside>0</yaxisside>
    833                     <calc_fnc>2</calc_fnc>
    834                     <type>0</type>
    835                     <item>
    836                         <host>Tomcat JMX</host>
    837                         <key>jmx[&quot;java.lang:type=Memory&quot;,&quot;HeapMemoryUsage.used&quot;]</key>
    838                     </item>
    839                 </graph_item>
    840                 <graph_item>
    841                     <sortorder>1</sortorder>
    842                     <drawtype>0</drawtype>
    843                     <color>00C800</color>
    844                     <yaxisside>0</yaxisside>
    845                     <calc_fnc>2</calc_fnc>
    846                     <type>0</type>
    847                     <item>
    848                         <host>Tomcat JMX</host>
    849                         <key>jmx[&quot;java.lang:type=Memory&quot;,&quot;HeapMemoryUsage.committed&quot;]</key>
    850                     </item>
    851                 </graph_item>
    852                 <graph_item>
    853                     <sortorder>2</sortorder>
    854                     <drawtype>0</drawtype>
    855                     <color>0000C8</color>
    856                     <yaxisside>0</yaxisside>
    857                     <calc_fnc>2</calc_fnc>
    858                     <type>0</type>
    859                     <item>
    860                         <host>Tomcat JMX</host>
    861                         <key>jmx[&quot;java.lang:type=Memory&quot;,&quot;HeapMemoryUsage.max&quot;]</key>
    862                     </item>
    863                 </graph_item>
    864             </graph_items>
    865         </graph>
    866         <graph>
    867             <name>类状态</name>
    868             <width>900</width>
    869             <height>200</height>
    870             <yaxismin>0.0000</yaxismin>
    871             <yaxismax>100.0000</yaxismax>
    872             <show_work_period>1</show_work_period>
    873             <show_triggers>1</show_triggers>
    874             <type>0</type>
    875             <show_legend>1</show_legend>
    876             <show_3d>0</show_3d>
    877             <percent_left>0.0000</percent_left>
    878             <percent_right>0.0000</percent_right>
    879             <ymin_type_1>0</ymin_type_1>
    880             <ymax_type_1>0</ymax_type_1>
    881             <ymin_item_1>0</ymin_item_1>
    882             <ymax_item_1>0</ymax_item_1>
    883             <graph_items>
    884                 <graph_item>
    885                     <sortorder>0</sortorder>
    886                     <drawtype>0</drawtype>
    887                     <color>C80000</color>
    888                     <yaxisside>0</yaxisside>
    889                     <calc_fnc>2</calc_fnc>
    890                     <type>0</type>
    891                     <item>
    892                         <host>Tomcat JMX</host>
    893                         <key>jmx[&quot;java.lang:type=ClassLoading&quot;,&quot;LoadedClassCount&quot;]</key>
    894                     </item>
    895                 </graph_item>
    896                 <graph_item>
    897                     <sortorder>1</sortorder>
    898                     <drawtype>0</drawtype>
    899                     <color>00C800</color>
    900                     <yaxisside>0</yaxisside>
    901                     <calc_fnc>2</calc_fnc>
    902                     <type>0</type>
    903                     <item>
    904                         <host>Tomcat JMX</host>
    905                         <key>jmx[&quot;java.lang:type=ClassLoading&quot;,&quot;UnloadedClassCount&quot;]</key>
    906                     </item>
    907                 </graph_item>
    908                 <graph_item>
    909                     <sortorder>2</sortorder>
    910                     <drawtype>0</drawtype>
    911                     <color>0000C8</color>
    912                     <yaxisside>0</yaxisside>
    913                     <calc_fnc>2</calc_fnc>
    914                     <type>0</type>
    915                     <item>
    916                         <host>Tomcat JMX</host>
    917                         <key>jmx[&quot;java.lang:type=ClassLoading&quot;,&quot;TotalLoadedClassCount&quot;]</key>
    918                     </item>
    919                 </graph_item>
    920             </graph_items>
    921         </graph>
    922         <graph>
    923             <name>线程状态</name>
    924             <width>900</width>
    925             <height>200</height>
    926             <yaxismin>0.0000</yaxismin>
    927             <yaxismax>100.0000</yaxismax>
    928             <show_work_period>1</show_work_period>
    929             <show_triggers>1</show_triggers>
    930             <type>0</type>
    931             <show_legend>1</show_legend>
    932             <show_3d>0</show_3d>
    933             <percent_left>0.0000</percent_left>
    934             <percent_right>0.0000</percent_right>
    935             <ymin_type_1>0</ymin_type_1>
    936             <ymax_type_1>0</ymax_type_1>
    937             <ymin_item_1>0</ymin_item_1>
    938             <ymax_item_1>0</ymax_item_1>
    939             <graph_items>
    940                 <graph_item>
    941                     <sortorder>0</sortorder>
    942                     <drawtype>0</drawtype>
    943                     <color>C80000</color>
    944                     <yaxisside>0</yaxisside>
    945                     <calc_fnc>2</calc_fnc>
    946                     <type>0</type>
    947                     <item>
    948                         <host>Tomcat JMX</host>
    949                         <key>jmx[&quot;java.lang:type=Threading&quot;,&quot;ThreadCount&quot;]</key>
    950                     </item>
    951                 </graph_item>
    952                 <graph_item>
    953                     <sortorder>1</sortorder>
    954                     <drawtype>0</drawtype>
    955                     <color>00C800</color>
    956                     <yaxisside>0</yaxisside>
    957                     <calc_fnc>2</calc_fnc>
    958                     <type>0</type>
    959                     <item>
    960                         <host>Tomcat JMX</host>
    961                         <key>jmx[&quot;java.lang:type=Threading&quot;,&quot;PeakThreadCount&quot;]</key>
    962                     </item>
    963                 </graph_item>
    964                 <graph_item>
    965                     <sortorder>2</sortorder>
    966                     <drawtype>0</drawtype>
    967                     <color>0000C8</color>
    968                     <yaxisside>0</yaxisside>
    969                     <calc_fnc>2</calc_fnc>
    970                     <type>0</type>
    971                     <item>
    972                         <host>Tomcat JMX</host>
    973                         <key>jmx[&quot;java.lang:type=Threading&quot;,&quot;TotalStartedThreadCount&quot;]</key>
    974                     </item>
    975                 </graph_item>
    976             </graph_items>
    977         </graph>
    978     </graphs>
    979 </zabbix_export>
    View Code

        图形化添加:

     

    1.1.4 效果展示

     二 监控Redis

     2.1.1 简介

        Redis有自带的redis-cli客户端,通过redis的info命令可以查询redis的运行状态,那么zabbix对redis的监控就是客户端,redis-cli登陆redis,然后根据info命令去获取状态数据的,

    2.1.2 redis中info的命令的使用

        要获得redis的当前情况,可以通过redis-cli工具登陆到redis命令行,然后通过info命令查看

        redis-cli命令格式:

    redis-cli -h [hostnam] -p [port] -a [password] info [参数]
    

     可选参数:

    server: Redis服务器相关的通用信息
    clients: 客户端连接的相关信息
    memory: 内存消耗相关的信息
    persistence: RDB(Redis DataBase) 和 AOF (Append-Only File)的相关信息
    stats: 通过统计数据
    replication: 主从复制相关信息
    cpu: CPU消耗的统计数据
    commandstats: redis命令的统计数据
    cluster: Redis集群的相关信息
    keyspace: 数据库相关的统计数据
    all: 返回所有服务器信息
    default: 值返回默认的信息集合

    2.1.3 参数详细说明:

        Server

    #redis-cli -h 127.0.0.1 -p 6379 info server
    # Server
    redis_version:4.0.1                                  
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:6cc565d4f2a4a6cb
    redis_mode:standalone
    os:Linux 2.6.32-696.1.1.el6.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    atomicvar_api:sync-builtin
    gcc_version:4.4.7
    process_id:5955
    run_id:d408e7fc06ccb368ff5cb9883311131639ba78b4
    tcp_port:6379
    uptime_in_seconds:6137350
    uptime_in_days:71
    hz:10
    lru_clock:7062882
    executable:/usr/local/redis/./redis-server
    config_file:
    
    # 说明
    redis_version: Redis服务器版本号
    redis_git_sha1: Git SHA1
    redis_git_dirty: Git dirtyflag
    os: Redis服务器的宿主机操作系统
    arch_bits: 架构(32/64)
    multiplexing_api: Redis所使用的事件处理机制
    gcc_version: 编译Redis时所使用的Gcc版本
    process_id: 服务器进程的Pid
    run_id: Redis服务器的随机标识符,(用于Sentinel和集群)
    tcp_port: TCP/IP监听端口
    uptime_in_seconds: 自Redis服务器启动以来,经过的秒数
    uptime_in_days: 自Redis服务器启动以来,经过的天数
    lru_clock: 以分钟为单位进行自增的始终,用于LRU管理
    

      查询内存信息

    # redis-cli -h 127.0.0.1 -p 6379 info memory
    # Memory
    used_memory:597014232
    used_memory_human:569.36M
    used_memory_rss:641613824
    used_memory_rss_human:611.89M
    used_memory_peak:608983824
    used_memory_peak_human:580.77M
    used_memory_peak_perc:98.03%
    used_memory_overhead:1509006
    used_memory_startup:765984
    used_memory_dataset:595505226
    used_memory_dataset_perc:99.88%
    total_system_memory:4018581504
    total_system_memory_human:3.74G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    mem_fragmentation_ratio:1.07
    mem_allocator:jemalloc-4.0.3
    active_defrag_running:0
    lazyfree_pending_objects:0
    
    # 说明
    used_memory: 由Redis分配器分配的内存总量,以字节(byte)为单位
    used_memory_human: 以人类可读的格式返回Redis分配的内存总数
    used_memory_rss: 从操作系统角度,返回Redis已分配的内存总数量(俗称常驻集大小).这个值和top,ps等命令的输出一致
    used_memory_peak: Redis的内存消耗峰值(以字节为单位)
    used_memory_peak_human: 以人类可读的格式返回Redis的内存消耗峰值
    used_memory_lua: lua引擎所使用的内存大小(以字节为单位)
    mem_fragmentation_ratio: used_memory_rss和used_memory之间的比率
    mem_allocator: 在编译时指定的,Redis所使用的内存分配器,可以是libc,jemalloc或者tomalloc

      查看客户端连接信息

    # redis-cli -h 127.0.0.1 -p 6379 info clients
    # Clients
    connected_clients:37
    client_longest_output_list:0
    client_biggest_input_buf:0
    blocked_clients:0
    
    # 说明
    connected_clients: 已连接客户端的数量(不包括通过从属服务器连接的客户端)
    client_longest_output_list: 当前连接的客户端当中,最长的输出列表
    client_biggest_input_buf: 当前连接的客户端中,最大输入缓存
    blocked_clients: 正在等待阻塞命令(BLPOP,BRPOP,BRPOPLPUSH)的客户端数量
    

      查看CPU使用情况:

    # redis-cli -h 127.0.0.1 -p 6379 info cpu
    # CPU
    used_cpu_sys:8585.28
    used_cpu_user:7876.75
    used_cpu_sys_children:2415.57
    used_cpu_user_children:18470.18
    
    # 说明
    used_cpu_sys: Redis 服务器耗费的系统CPU
    used_cpu_user: Redis 服务器耗费的用户CPU
    used_cpu_sys_children: 后台进程消耗的系统CPU
    used_cpu_user_children: 后台进程耗费的用户CPU
    

      查询一般统计信息:

    # /usr/local/redis/redis-cli -h 127.0.0.1 -p 6379 info stats
    # Stats
    total_connections_received:2237
    total_commands_processed:349644510
    instantaneous_ops_per_sec:22
    total_net_input_bytes:238485917420
    total_net_output_bytes:56383049698
    instantaneous_input_kbps:0.50
    instantaneous_output_kbps:0.98
    rejected_connections:0
    sync_full:0
    sync_partial_ok:0
    sync_partial_err:0
    expired_keys:0
    evicted_keys:0
    keyspace_hits:52382
    keyspace_misses:413948
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:22767
    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
    
    
    # 说明
    total_connections_received: 服务器已接受的链接请求数量
    total_commands_processed: 服务器已执行的命令数量
    instantaneous_ops_per_sec: 服务器每秒钟执行的命令数量
    rejected_connections: 因为最大客户端数量限制而被拒绝的链接请求数量
    expired_keys: 因为过期而被自动删除的数据库键数量
    evicted_keys: 因为最大内存容量限制而被驱逐(evict) 的键数量
    keyspace_hits: 查找数据库键成功的次数
    keyspace_misses: 查找数据库键失败的次数
    pubsub_channels: 目前被订阅的频道数量
    pubsub_patterns: 目前被订阅的模式数量
    latest_fork_usec: 最近一次 fork() 操作耗费的毫秒数
    

      查询Redis主从复制信息:

    # /usr/local/redis/redis-cli -h 127.0.0.1 -p 6379 info Replication
    # Replication
    role:master
    connected_slaves:0
    master_replid: 0
    master_replid2:0
    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
    
    # 说明
    role:  如果当前服务器没有在复制任何其他服务器,那么这个域的值就是master;否则的话,这个域的值就是slave. 注意,在创建复制链的时候,一个从服务器也可能是另外一个服务器的主服务器.
    connected_slaves: 已连接的Redis从机的数量
    master_replid:  全局的复制偏移量
    master_replid2: 用于存在该节点上一次连接主实例的实例master_replid
    master_repl_offset: 可以得到当前master记录的复制偏移量。
    second_repl_offset: 备份日志的
    repl_backlog_active: 表示backlog的达标,backlog是一个缓冲区,在slave端失连时存放要同步到slave的数据,因此当一个slave要重连时,经常是不需要完全同步,执行局部同步就可以,backlog设置的越大,slave可以失连的事件就越长.
    repl_backlog_size: 表示该buffer的大小(默认1024*1024,即1Mb)。该buffer是作为一个环形缓存区使用的,当有数据超过buffer的大小以后就会重新从buffer的头部开始写入
    repl_backlog_first_byte_offset: 备份日志缓冲区中的首个字节的复制偏移量.
    repl_backlog_histlen: 备份日志的实际数据长度.
    
    如果当前服务器是一个从服务器的话,那么这个部分还会加上一下内容
    master_host: 主服务器的 IP 地址
    master_prt: 主服务器的 TCP 监听端口
    master_link_status: 复制链接当前的状态, up表示链接正常, down表示链接断开
    master_last_io_seconds_ago: 距离最近一次与主服务器进行通信已经过去了多少秒
    master_sync_in_progress: 一个标志值,记录了主服务器是否正在与这个从服务器进行同步.
    
    # 如果同步操作正在进行,那么这个部分还会加上一下内容,
    master_sync_left_bytes: 距离同步完成还缺少多少字节数据,
    master_sync_last_io_seconds_ago: 距离最近一次因为SYNC操作而进行I/O已经过去了多少秒.
    
    # 如果主从服务器之间的链接处于断线状态,那么这个部分还会加上一下内容.
    master_link_down_since_seconds: 主从服务器连接断开了多少秒.
    

    2.1.4 编写Shell脚本并验证

    #!/bin/bash
    REDISCLI="/usr/bin/redis-cli"
    HOST="127.0.0.1"
    PORT=6379
    PASS="123456"
    
    if [[ $# == 1 ]];then
        case $1 in
            version)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info server | grep -w "redis_version" | awk -F':' '{print $2}'`
                echo $result
            ;;
            uptime)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info server | grep -w "uptime_in_seconds" | awk -F':' '{print $2}'`
                echo $result
            ;;
            connected_clients)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info clients | grep -w "connected_clients" | awk -F':' '{print $2}'`
                echo $result
            ;;
            blocked_clients)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info clients | grep -w "blocked_clients" | awk -F':' '{print $2}'`
                echo $result
            ;;
            used_memory)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info memory | grep -w "used_memory" | awk -F':' '{print $2}'`
                echo $result
            ;;
            used_memory_rss)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info memory | grep -w "used_memory_rss" | awk -F':' '{print $2}'`
                echo $result
            ;;
            used_memory_peak)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info memory | grep -w "used_memory_peak" | awk -F':' '{print $2}'`
                echo $result
            ;;
            used_memory_lua)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info memory | grep -w "used_memory_lua" | awk -F':' '{print $2}'`
                echo $result
            ;;
            used_cpu_sys)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info cpu | grep -w "used_cpu_sys" | awk -F':' '{print $2}'`
                echo $result
            ;;
            used_cpu_user)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info cpu | grep -w "used_cpu_user" | awk -F':' '{print $2}'`
                echo $result
            ;;
            used_cpu_sys_children)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info cpu | grep -w "used_cpu_sys_children" | awk -F':' '{print $2}'`
                echo $result
            ;;
            used_cpu_user_children)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info cpu | grep -w "used_cpu_user_children" | awk -F':' '{print $2}'`
                echo $result
            ;;
            rdb_last_bgsave_status)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info Persistence | grep -w "rdb_last_bgsave_status" | awk -F':' '{print $2}' | grep -c ok`
                echo $result
            ;;
            aof_last_bgrewrite_status)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info Persistence | grep -w "aof_last_bgrewrite_status" | awk -F':' '{print $2}' | grep -c ok`
                echo $result
            ;;
            aof_last_write_status)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info Persistence | grep -w "aof_last_write_status" | awk -F':' '{print $2}' | grep -c ok`
                echo $result
            ;;
            *)
                echo -e "33[33mUsage: $0 {connected_clients|blocked_clients|used_memory|used_memory_rss|used_memory_peak|used_memory_lua|used_cpu_sys|used_cpu_user|used_cpu_sys_children|used_cpu_user_children|rdb_last_bgsave_status|aof_last_bgrewrite_status|aof_last_write_status}33[0m"
            ;;
        esac
    elif [[ $# == 2 ]];then
        case $2 in
            keys)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info | grep -w "$1" | grep -w "keys" | awk -F'=|,' '{print $2}'`
                echo $result
            ;;
            expires)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info | grep -w "$1" | grep -w "keys" | awk -F'=|,' '{print $4}'`
                echo $result
            ;;
            avg_ttl)
                result=`$REDISCLI -h $HOST -a $PASS -p $PORT info | grep -w "$1" | grep -w "avg_ttl" | awk -F'=|,' '{print $6}'`
                echo $result
            ;;
            *)
                echo -e "33[33mUsage: $0 {db0 keys|db0 expires|db0 avg_ttl}33[0m" 
            ;;
        esac
    fi
    

      验证:

    # 验证脚本
    # pwd
    /etc/zabbix/zabbix_agentd.d
    # chmod 755 redis_status 
    # chmod +x redis_status 
    # ./redis_status used_memory
    590056848
    
    # 在/etc/zabbix/zabbix_agentd.d目录下创建redis_status.conf文件
    UserParameter=Redis.Info[*],/etc/zabbix/zabbix_agentd.d/redis_status $1 $2
    UserParameter=Redis.Status,/usr/local/redis/redis-cli -h 127.0.0.1 -p 6379 ping | grep -c PONG
    
    # 重启zabbix-agentd服务
    service zabbix-agent restart
    
    # zabbix-server 验证测试
    # zabbix_get -s 47.92.105.38 -k Redis.Info["used_memory"]
    590061088
    

    2.1.5 创建模板并验证结果

        模板包含19监控项,5图形,1触发器,5应用集

       模板内容:

    <?xml version="1.0" encoding="UTF-8"?>
    <zabbix_export>
        <version>2.0</version>
        <date>2018-08-07T10:04:35Z</date>
        <groups>
            <group>
                <name>Template DB Redis</name>
            </group>
            <group>
                <name>Templates</name>
            </group>
        </groups>
        <templates>
            <template>
                <template>Template DB Redis</template>
                <name>Template DB Redis</name>
                <groups>
                    <group>
                        <name>Template DB Redis</name>
                    </group>
                    <group>
                        <name>Templates</name>
                    </group>
                </groups>
                <applications>
                    <application>
                        <name>Redis Clients</name>
                    </application>
                    <application>
                        <name>Redis CPU</name>
                    </application>
                    <application>
                        <name>Redis DbKey</name>
                    </application>
                    <application>
                        <name>Redis Memory</name>
                    </application>
                    <application>
                        <name>Redis WriteStatus</name>
                    </application>
                </applications>
                <items>
                    <item>
                        <name>Redis.Info[aof_last_bgrewrite_status]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[aof_last_bgrewrite_status]</key>
                        <delay>30</delay>
                        <history>90</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 WriteStatus</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[aof_last_write_status]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[aof_last_write_status]</key>
                        <delay>30</delay>
                        <history>90</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 WriteStatus</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[blocked_clients]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[blocked_clients]</key>
                        <delay>30</delay>
                        <history>90</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 Clients</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[connected_clients]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[connected_clients]</key>
                        <delay>30</delay>
                        <history>90</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 Clients</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[db0,avg_ttl]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[db0,avg_ttl]</key>
                        <delay>30</delay>
                        <history>90</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 DbKey</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[db0,expires]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[db0,expires]</key>
                        <delay>30</delay>
                        <history>90</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 DbKey</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[db0,keys]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[db0,keys]</key>
                        <delay>30</delay>
                        <history>90</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 DbKey</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[rdb_last_bgsave_status]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[rdb_last_bgsave_status]</key>
                        <delay>30</delay>
                        <history>90</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 WriteStatus</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[uptime]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[uptime]</key>
                        <delay>30</delay>
                        <history>90</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/>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[used_cpu_sys]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[used_cpu_sys]</key>
                        <delay>30</delay>
                        <history>90</history>
                        <trends>365</trends>
                        <status>0</status>
                        <value_type>0</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 CPU</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[used_cpu_sys_children]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[used_cpu_sys_children]</key>
                        <delay>30</delay>
                        <history>90</history>
                        <trends>365</trends>
                        <status>0</status>
                        <value_type>0</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 CPU</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[used_cpu_user]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[used_cpu_user]</key>
                        <delay>30</delay>
                        <history>90</history>
                        <trends>365</trends>
                        <status>0</status>
                        <value_type>0</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 CPU</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[used_cpu_user_children]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[used_cpu_user_children]</key>
                        <delay>30</delay>
                        <history>90</history>
                        <trends>365</trends>
                        <status>0</status>
                        <value_type>0</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 CPU</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[used_memory]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[used_memory]</key>
                        <delay>30</delay>
                        <history>90</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 Memory</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[used_memory_lua]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[used_memory_lua]</key>
                        <delay>30</delay>
                        <history>90</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 Memory</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[used_memory_peak]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[used_memory_peak]</key>
                        <delay>30</delay>
                        <history>90</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 Memory</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[used_memory_rss]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[used_memory_rss]</key>
                        <delay>30</delay>
                        <history>90</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 Memory</name>
                            </application>
                        </applications>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis.Info[version]</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Info[version]</key>
                        <delay>30</delay>
                        <history>90</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/>
                        <valuemap/>
                    </item>
                    <item>
                        <name>Redis Status</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>Redis.Status</key>
                        <delay>30</delay>
                        <history>90</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/>
                        <valuemap/>
                    </item>
                </items>
                <discovery_rules/>
                <macros/>
                <templates/>
                <screens/>
            </template>
        </templates>
        <triggers>
            <trigger>
                <expression>{Template DB Redis:Redis.Status.last(0)}=0</expression>
                <name>Redis is down</name>
                <url/>
                <status>0</status>
                <priority>5</priority>
                <description/>
                <type>0</type>
                <dependencies/>
            </trigger>
        </triggers>
        <graphs>
            <graph>
                <name>Redis Client</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>Template DB Redis</host>
                            <key>Redis.Info[blocked_clients]</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>Template DB Redis</host>
                            <key>Redis.Info[connected_clients]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
            <graph>
                <name>Redis CPU</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>2</drawtype>
                        <color>C80000</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[used_cpu_sys]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>1</sortorder>
                        <drawtype>2</drawtype>
                        <color>00C800</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[used_cpu_user]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>2</sortorder>
                        <drawtype>2</drawtype>
                        <color>0000C8</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[used_cpu_sys_children]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>3</sortorder>
                        <drawtype>2</drawtype>
                        <color>C800C8</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[used_cpu_user_children]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
            <graph>
                <name>Redis DbKeys</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>2</drawtype>
                        <color>C80000</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[db0,avg_ttl]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>1</sortorder>
                        <drawtype>2</drawtype>
                        <color>00C800</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[db0,expires]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>2</sortorder>
                        <drawtype>2</drawtype>
                        <color>0000C8</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[db0,keys]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
            <graph>
                <name>Redis Memory</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>2</drawtype>
                        <color>C80000</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[used_memory]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>1</sortorder>
                        <drawtype>2</drawtype>
                        <color>00C800</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[used_memory_lua]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>2</sortorder>
                        <drawtype>2</drawtype>
                        <color>0000C8</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[used_memory_peak]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>3</sortorder>
                        <drawtype>2</drawtype>
                        <color>C800C8</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[used_memory_rss]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
            <graph>
                <name>Redis WriteStatus</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>2</drawtype>
                        <color>C80000</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[aof_last_bgrewrite_status]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>1</sortorder>
                        <drawtype>2</drawtype>
                        <color>0000C8</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[rdb_last_bgsave_status]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>2</sortorder>
                        <drawtype>2</drawtype>
                        <color>00C800</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Redis</host>
                            <key>Redis.Info[aof_last_write_status]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
        </graphs>
    </zabbix_export>
    

      # 图形使用

       

  • 相关阅读:
    java代码--Date类获取当前时间-格式化输出
    Eclipse快速生成do while if 等方法
    java不同包中protected修饰的属性和方法调用方法
    java中如果删除导入的jar包,工程出现叹号解决方案
    Best Reward HDU 3613(回文子串Manacher)
    Teacher YYF
    Period II
    How many
    String Problem
    Corporate Identity
  • 原文地址:https://www.cnblogs.com/yanshicheng/p/10360105.html
Copyright © 2011-2022 走看看