zabbix监控mysql数据库信息脚本

---恢复内容开始---

在/usr/local/zabbix/etc/zabbix_agentd.conf增加

# 获取mysql性能指标
UserParameter=mysql.status[*],/usr/local/zabbix/bin/check_mysql.sh $1

/usr/local/zabbix/bin/check_mysql.sh脚本内容为

#!/bin/bash
# -------------------------------------------------------------------------------
# FileName:    check_mysql.sh

MYSQL_CONN="/usr/bin/mysqladmin"

# 参数是否正确
if [ $# -ne "1" ];then
    echo "arg error!"
fi

# 获取数据
case $1 in
    Uptime)
        result=`${MYSQL_CONN} status|cut -f2 -d":"|cut -f1 -d"T"`
        echo $result
        ;;
    Com_update)
        result=`${MYSQL_CONN} extended-status |grep -w "Com_update"|cut -d"|" -f3`
        echo $result
        ;;
    Slow_queries)
        result=`${MYSQL_CONN} status |cut -f5 -d":"|cut -f1 -d"O"`
        echo $result
        ;;
    Com_select)
        result=`${MYSQL_CONN} extended-status |grep -w "Com_select"|cut -d"|" -f3`
        echo $result
                ;;
    Com_rollback)
        result=`${MYSQL_CONN} extended-status |grep -w "Com_rollback"|cut -d"|" -f3`
                echo $result
                ;;
    Questions)
        result=`${MYSQL_CONN} status|cut -f4 -d":"|cut -f1 -d"S"`
                echo $result
                ;;
    Com_insert)
        result=`${MYSQL_CONN} extended-status |grep -w "Com_insert"|cut -d"|" -f3`
                echo $result
                ;;
    Com_delete)
        result=`${MYSQL_CONN} extended-status |grep -w "Com_delete"|cut -d"|" -f3`
                echo $result
                ;;
    Com_commit)
        result=`${MYSQL_CONN} extended-status |grep -w "Com_commit"|cut -d"|" -f3`
                echo $result
                ;;
    Bytes_sent)
        result=`${MYSQL_CONN} extended-status |grep -w "Bytes_sent" |cut -d"|" -f3`
                echo $result
                ;;
    Bytes_received)
        result=`${MYSQL_CONN} extended-status |grep -w "Bytes_received" |cut -d"|" -f3`
                echo $result
                ;;
    Com_begin)
        result=`${MYSQL_CONN} extended-status |grep -w "Com_begin"|cut -d"|" -f3`
                echo $result
                ;;
    Slave)
#        result=`${MYSQL_CONN} extended-status |grep -w "Com_begin"|cut -d"|" -f3`
#                echo $result
        array=(`/usr/bin/mysql -e "show slave status\G"|grep "Running" |awk '{print $2}'`)
        if [ "${array[0]}" == "Yes" ] && [ "${array[1]}" == "Yes" ]
              then
                 echo 0
              else
                 echo 1
        fi

                ;;

        *)
        echo "Usage:$0(Uptime|Com_update|Slow_queries|Com_select|Com_rollback|Questions|Com_insert|Com_delete|Com_commit|Bytes_sent|Bytes_received|Com_begin|Slave)"
        ;;
esac

zabbix模版内容:

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>3.4</version>
    <date>2018-06-07T06:25:56Z</date>
    <groups>
        <group>
            <name>Templates</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template App MySQL</template>
            <name>Template App MySQL</name>
            <description/>
            <groups>
                <group>
                    <name>Templates</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>MySQL</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>MySQL status</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.ping</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.ping, which is defined in userparameter_mysql.conf.&#13;
&#13;
0 - MySQL server is down&#13;
1 - MySQL server is up</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>Service state</name>
                    </valuemap>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL bytes received per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Bytes_received]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>Bps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>The number of bytes received from all clients. &#13;
&#13;
It requires user parameter mysql.status[*], which is defined in &#13;
userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL bytes sent per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Bytes_sent]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>Bps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>The number of bytes sent to all clients.&#13;
&#13;
It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL begin operations per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Com_begin]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>qps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL commit operations per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Com_commit]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>qps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL delete operations per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Com_delete]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>qps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL insert operations per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Com_insert]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>qps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL rollback operations per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Com_rollback]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>qps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL select operations per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Com_select]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>qps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL update operations per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Com_update]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>qps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL queries per second</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Questions]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>qps</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing>
                        <step>
                            <type>10</type>
                            <params/>
                        </step>
                    </preprocessing>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL slow queries</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Slow_queries]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL uptime</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.status[Uptime]</key>
                    <delay>1m</delay>
                    <history>1w</history>
                    <trends>365d</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>uptime</units>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.status[*], which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>MySQL version</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>mysql.version</key>
                    <delay>1h</delay>
                    <history>1w</history>
                    <trends>0</trends>
                    <status>0</status>
                    <value_type>1</value_type>
                    <allowed_hosts/>
                    <units/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>It requires user parameter mysql.version, which is defined in userparameter_mysql.conf.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>MySQL</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
            </items>
            <discovery_rules/>
            <httptests/>
            <macros/>
            <templates/>
            <screens>
                <screen>
                    <name>MySQL performance</name>
                    <hsize>2</hsize>
                    <vsize>1</vsize>
                    <screen_items>
                        <screen_item>
                            <resourcetype>0</resourcetype>
                            <width>500</width>
                            <height>200</height>
                            <x>0</x>
                            <y>0</y>
                            <colspan>1</colspan>
                            <rowspan>1</rowspan>
                            <elements>0</elements>
                            <valign>1</valign>
                            <halign>0</halign>
                            <style>0</style>
                            <url/>
                            <dynamic>0</dynamic>
                            <sort_triggers>0</sort_triggers>
                            <resource>
                                <name>MySQL operations</name>
                                <host>Template App MySQL</host>
                            </resource>
                            <max_columns>3</max_columns>
                            <application/>
                        </screen_item>
                        <screen_item>
                            <resourcetype>0</resourcetype>
                            <width>500</width>
                            <height>270</height>
                            <x>1</x>
                            <y>0</y>
                            <colspan>1</colspan>
                            <rowspan>1</rowspan>
                            <elements>0</elements>
                            <valign>1</valign>
                            <halign>0</halign>
                            <style>0</style>
                            <url/>
                            <dynamic>0</dynamic>
                            <sort_triggers>0</sort_triggers>
                            <resource>
                                <name>MySQL bandwidth</name>
                                <host>Template App MySQL</host>
                            </resource>
                            <max_columns>3</max_columns>
                            <application/>
                        </screen_item>
                    </screen_items>
                </screen>
            </screens>
        </template>
    </templates>
    <triggers>
        <trigger>
            <expression>{Template App MySQL:mysql.ping.last(0)}=0</expression>
            <recovery_mode>0</recovery_mode>
            <recovery_expression/>
            <name>MySQL is down</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/>
            <tags/>
        </trigger>
    </triggers>
    <graphs>
        <graph>
            <name>MySQL bandwidth</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>5</drawtype>
                    <color>00AA00</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Bytes_received]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>5</drawtype>
                    <color>3333FF</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Bytes_sent]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>MySQL operations</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>C8C800</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Com_begin]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>0</drawtype>
                    <color>006400</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Com_commit]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <drawtype>0</drawtype>
                    <color>C80000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Com_delete]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <drawtype>0</drawtype>
                    <color>0000EE</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Com_insert]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <drawtype>0</drawtype>
                    <color>640000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Com_rollback]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>5</sortorder>
                    <drawtype>0</drawtype>
                    <color>00C800</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Com_select]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>6</sortorder>
                    <drawtype>0</drawtype>
                    <color>C800C8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template App MySQL</host>
                        <key>mysql.status[Com_update]</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>
View Code

猜你喜欢

转载自www.cnblogs.com/ddif/p/9151027.html