zabbix 监控ssdb

默北 zabbix1 25,4064字数 17691阅读58分58秒阅读模式

zabbix 的啥基础知识啥的,请看由本站大牛凉白开先生写的zabbix教程。这里说说如何监控ssdb。SSDB 是一个 C/C++ 语言开发的高性能 NoSQL 数据库, 支持 KV, list, map(hash), zset(sorted set) 等数据结构, 用来替代或者与 Redis 配合存储十亿级别列表的数据。

  1. 导入ssdb模板
    这个是我自己创建的。不合适的地方自行修改。文章源自运维生存时间-https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/
    <?xml version="1.0" encoding="UTF-8"?>
    <zabbix_export>
        <version>3.2</version>
        <date>2017-07-05T06:50:33Z</date>
        <groups>
            <group>
                <name>Templates</name>
            </group>
        </groups>
        <templates>
            <template>
                <template>Template App SSDB</template>
                <name>Template App SSDB</name>
                <description>ssdb</description>
                <groups>
                    <group>
                        <name>Templates</name>
                    </group>
                </groups>
                <applications>
                    <application>
                        <name>ssdb</name>
                    </application>
                </applications>
                <items>
                    <item>
                        <name>ssdb server is running</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>net.tcp.listen[{$SSDB.PORT}]</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>ssdb</name>
                            </application>
                        </applications>
                        <valuemap>
                            <name>Service state</name>
                        </valuemap>
                        <logtimefmt/>
                    </item>
                    <item>
                        <name>ssdb $1</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>ssdb[available]</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>ssdb</name>
                            </application>
                        </applications>
                        <valuemap>
                            <name>Service state</name>
                        </valuemap>
                        <logtimefmt/>
                    </item>
                    <item>
                        <name>ssdb $1 max_seq</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>ssdb[binlogs]</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>The maximum binlog number in the current queue</description>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>ssdb</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                    </item>
                    <item>
                        <name>ssdb $1</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>ssdb[dbsize]</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>ssdb</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                    </item>
                    <item>
                        <name>ssdb links</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>ssdb[links]</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>ssdb</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                    </item>
                    <item>
                        <name>ssdb $1 $2</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>ssdb[replication.client,last_seq]</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>ssdb</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                    </item>
                    <item>
                        <name>ssdb $1 $2</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>ssdb[replication.client,status]</key>
                        <delay>30</delay>
                        <history>90</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>4</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>ssdb</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                    </item>
                    <item>
                        <name>ssdb $1</name>
                        <type>0</type>
                        <snmp_community/>
                        <multiplier>0</multiplier>
                        <snmp_oid/>
                        <key>ssdb[total_calls]</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>ssdb</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                    </item>
                </items>
                <discovery_rules>
                    <discovery_rule>
                        <name>SSDB cmd discovery</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>ssdb.cmd.discovery</key>
                        <delay>30</delay>
                        <status>0</status>
                        <allowed_hosts/>
                        <snmpv3_contextname/>
                        <snmpv3_securityname/>
                        <snmpv3_securitylevel>0</snmpv3_securitylevel>
                        <snmpv3_authprotocol>0</snmpv3_authprotocol>
                        <snmpv3_authpassphrase/>
                        <snmpv3_privprotocol>0</snmpv3_privprotocol>
                        <snmpv3_privpassphrase/>
                        <delay_flex/>
                        <params/>
                        <ipmi_sensor/>
                        <authtype>0</authtype>
                        <username/>
                        <password/>
                        <publickey/>
                        <privatekey/>
                        <port/>
                        <filter>
                            <evaltype>0</evaltype>
                            <formula/>
                            <conditions/>
                        </filter>
                        <lifetime>30</lifetime>
                        <description/>
                        <item_prototypes>
                            <item_prototype>
                                <name>ssdb cmd $1 $2</name>
                                <type>0</type>
                                <snmp_community/>
                                <multiplier>0</multiplier>
                                <snmp_oid/>
                                <key>ssdb[{#SSDBCMD},calls]</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>ssdb</name>
                                    </application>
                                </applications>
                                <valuemap/>
                                <logtimefmt/>
                                <application_prototypes>
                                    <application_prototype>
                                        <name>ssdb cmd discovery</name>
                                    </application_prototype>
                                </application_prototypes>
                            </item_prototype>
                            <item_prototype>
                                <name>ssdb cmd $1 $2</name>
                                <type>0</type>
                                <snmp_community/>
                                <multiplier>0</multiplier>
                                <snmp_oid/>
                                <key>ssdb[{#SSDBCMD},time_proc]</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>ssdb</name>
                                    </application>
                                </applications>
                                <valuemap/>
                                <logtimefmt/>
                                <application_prototypes>
                                    <application_prototype>
                                        <name>ssdb cmd discovery</name>
                                    </application_prototype>
                                </application_prototypes>
                            </item_prototype>
                            <item_prototype>
                                <name>ssdb cmd $1 $2</name>
                                <type>0</type>
                                <snmp_community/>
                                <multiplier>0</multiplier>
                                <snmp_oid/>
                                <key>ssdb[{#SSDBCMD},time_wait]</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>ssdb</name>
                                    </application>
                                </applications>
                                <valuemap/>
                                <logtimefmt/>
                                <application_prototypes>
                                    <application_prototype>
                                        <name>ssdb cmd discovery</name>
                                    </application_prototype>
                                </application_prototypes>
                            </item_prototype>
                        </item_prototypes>
                        <trigger_prototypes/>
                        <graph_prototypes>
                            <graph_prototype>
                                <name>ssdb {#SSDBCMD}</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>1A7C11</color>
                                        <yaxisside>0</yaxisside>
                                        <calc_fnc>2</calc_fnc>
                                        <type>0</type>
                                        <item>
                                            <host>Template App SSDB</host>
                                            <key>ssdb[{#SSDBCMD},calls]</key>
                                        </item>
                                    </graph_item>
                                    <graph_item>
                                        <sortorder>1</sortorder>
                                        <drawtype>0</drawtype>
                                        <color>F63100</color>
                                        <yaxisside>0</yaxisside>
                                        <calc_fnc>2</calc_fnc>
                                        <type>0</type>
                                        <item>
                                            <host>Template App SSDB</host>
                                            <key>ssdb[{#SSDBCMD},time_proc]</key>
                                        </item>
                                    </graph_item>
                                    <graph_item>
                                        <sortorder>2</sortorder>
                                        <drawtype>0</drawtype>
                                        <color>2774A4</color>
                                        <yaxisside>0</yaxisside>
                                        <calc_fnc>2</calc_fnc>
                                        <type>0</type>
                                        <item>
                                            <host>Template App SSDB</host>
                                            <key>ssdb[{#SSDBCMD},time_wait]</key>
                                        </item>
                                    </graph_item>
                                </graph_items>
                            </graph_prototype>
                        </graph_prototypes>
                        <host_prototypes/>
                    </discovery_rule>
                </discovery_rules>
                <httptests/>
                <macros>
                    <macro>
                        <macro>{$SSDB.PORT}</macro>
                        <value>8888</value>
                    </macro>
                </macros>
                <templates/>
                <screens/>
            </template>
        </templates>
        <triggers>
            <trigger>
                <expression>{Template App SSDB:net.tcp.listen[{$SSDB.PORT}].last()}=0</expression>
                <recovery_mode>1</recovery_mode>
                <recovery_expression>{Template App SSDB:net.tcp.listen[{$SSDB.PORT}].last()}=1</recovery_expression>
                <name>ssdb is down on {HOST.NAME}</name>
                <correlation_mode>0</correlation_mode>
                <correlation_tag/>
                <url/>
                <status>0</status>
                <priority>4</priority>
                <description/>
                <type>0</type>
                <manual_close>0</manual_close>
                <dependencies/>
                <tags/>
            </trigger>
            <trigger>
                <expression>{Template App SSDB:ssdb[binlogs].last()} - {Template App SSDB:ssdb[replication.client,last_seq].last()} &gt; 3600</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>ssdb replacation is behind on {HOST.NAME}</name>
                <correlation_mode>0</correlation_mode>
                <correlation_tag/>
                <url/>
                <status>0</status>
                <priority>2</priority>
                <description/>
                <type>0</type>
                <manual_close>0</manual_close>
                <dependencies>
                    <dependency>
                        <name>ssdb replacation is failed on {HOST.NAME}</name>
                        <expression>{es1:ssdb[replication.client,status].str(SYNC)}&lt;&gt;1</expression>
                        <recovery_expression/>
                    </dependency>
                </dependencies>
                <tags/>
            </trigger>
            <trigger>
                <expression>{Template App SSDB:ssdb[replication.client,status].str(SYNC)}&lt;&gt;1</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>ssdb replacation is failed on {HOST.NAME}</name>
                <correlation_mode>0</correlation_mode>
                <correlation_tag/>
                <url/>
                <status>0</status>
                <priority>2</priority>
                <description/>
                <type>0</type>
                <manual_close>0</manual_close>
                <dependencies>
                    <dependency>
                        <name>ssdb is down on {HOST.NAME}</name>
                        <expression>{es1:net.tcp.listen[{$SSDB.PORT}].last()}=0</expression>
                        <recovery_expression>{es1:net.tcp.listen[{$SSDB.PORT}].last()}=1</recovery_expression>
                    </dependency>
                </dependencies>
                <tags/>
            </trigger>
            <trigger>
                <expression>{Template App SSDB:ssdb[available].last()}&lt;&gt;1</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>ssdb  service availability on {HOST.NAME}</name>
                <correlation_mode>0</correlation_mode>
                <correlation_tag/>
                <url/>
                <status>0</status>
                <priority>2</priority>
                <description/>
                <type>0</type>
                <manual_close>0</manual_close>
                <dependencies>
                    <dependency>
                        <name>ssdb is down on {HOST.NAME}</name>
                        <expression>{Template App SSDB:net.tcp.listen[{$SSDB.PORT}].last()}=0</expression>
                        <recovery_expression>{Template App SSDB:net.tcp.listen[{$SSDB.PORT}].last()}=1</recovery_expression>
                    </dependency>
                </dependencies>
                <tags/>
            </trigger>
        </triggers>
        <graphs>
            <graph>
                <name>ssdb current connections</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>1A7C11</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template App SSDB</host>
                            <key>ssdb[links]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
            <graph>
                <name>ssdb database size estimate</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>1A7C11</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template App SSDB</host>
                            <key>ssdb[dbsize]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
        </graphs>
        <value_maps>
            <value_map>
                <name>Service state</name>
                <mappings>
                    <mapping>
                        <value>0</value>
                        <newvalue>Down</newvalue>
                    </mapping>
                    <mapping>
                        <value>1</value>
                        <newvalue>Up</newvalue>
                    </mapping>
                </mappings>
            </value_map>
        </value_maps>
    </zabbix_export>

    文件下载:zbx_ssdb_templates.xml

  2. 脚本
    $ cat /etc/zabbix/libexec/ssdb.py 
    #!/bin/env python
    
    import sys,json,socket,re
    from SSDB import SSDB
    
    def get_stats(ip,port):
      ssdb = SSDB(ip, port)
      info = ssdb.request('info',['cmd'])
      result= info.data[1:]
      return result
    
    def discovery_cmd(info):
      d={'data':[]}
      for i in range(0,len(info),2):
        if info[i].find('cmd') != -1: 
          d['data'].append({'{#SSDBCMD}':info[i]})
    
      return json.dumps(d)
    
    def check(ip,port):
      ssdb = SSDB(ip, port)
      try:
        ssdb.request('set', ['zabbix', '123'])
        ssdb.request('get', ['zabbix'])
        return 1
      except:
        return 0
    
    if __name__ == '__main__':
      ip = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
      port = 8888
      stats = get_stats(ip,port)
      res = {}
      for i in range(0,len(stats),2):
        if stats[i] == 'replication':
          stats[i] = stats[i]+'.'+stats[i+1].split()[0]
        res[stats[i]] = stats[i+1]
      
      cmd = sys.argv[1]
      filter = sys.argv[2] if len(sys.argv) > 2 else ''
    
      if cmd  == 'discover':
        print discovery_cmd(stats)
      elif cmd.find('cmd') != -1:
        p = re.compile('(\w+):\s+(\d+)\s+(\w+):\s+(\d+)\s+(\w+):\s+(\d+)')
        m = p.match(res[cmd])
        d=dict(zip(m.group(1,3,5),m.group(2,4,6)))
        #print d[filter]
        print d.get(filter,'not support')
      elif cmd == 'replication.client':
        for i in res['replication.client'].split('\n'):
          if i.split(':')[0].strip() == filter:
            print i.split(':')[1].strip()
      elif cmd == 'binlogs':
        print res['binlogs'].split('\n')[-1].split(':')[-1].strip()
      elif cmd == 'available':
        print check(ip,port)
      else:
        print res.get(cmd,'not support')
  3. userparameter配置
    $ cat /etc/zabbix/zabbix_agentd.d/userparameter_ssdb.conf 
    UserParameter=ssdb.cmd.discovery,/etc/zabbix/libexec/ssdb.py discover
    UserParameter=ssdb[*],/etc/zabbix/libexec/ssdb.py $1 $2

需要使用到ssdb的python客户端,我这里是使用ssdb源码自带的python客户端。文章源自运维生存时间-https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/

item的定义:文章源自运维生存时间-https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/

SSDB文章源自运维生存时间-https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/

triggers定义:文章源自运维生存时间-https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/

SSDB文章源自运维生存时间-https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/

注意:适用于ssdb 主主复制。单实例、主从、多主并未测试过。文章源自运维生存时间-https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/ 文章源自运维生存时间-https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/

weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
默北
  • 本文由 发表于 05/07/2017 15:05:01
  • 转载请务必保留本文链接:https://www.ttlsa.com/zabbix/zabbix-monitor-ssdb/
评论  1  访客  1
    • 态度xiaomi
      态度xiaomi 3

      好多内容

    评论已关闭!