zoukankan      html  css  js  c++  java
  • ubuntu 16.04 + zabbix 3.4 + postgresql shell

    os: ubuntu 16.04
    zabbix: 3.4

    ip 规划
    192.168.56.101 node1 pgsql 9.6 master
    192.168.56.102 node2 pgsql 9.6 slave
    192.168.56.103 node3 zabbix proxy
    192.168.56.104 node4 zabbix server

    本篇blog介绍在 node1、node2 节点上使用 shell脚本 监控 postgresql的具体过程。
    使用 shell 脚本监控,就是比较灵活一点。

    创建 shell_postgresql96.conf

    # egrep ^[A-Z] /etc/zabbix/zabbix_agentd.conf
    PidFile=/var/run/zabbix/zabbix_agentd.pid
    LogFile=/var/log/zabbix/zabbix_agentd.log
    LogFileSize=0
    Server=192.168.56.103
    ServerActive=192.168.56.103
    Hostname=node2
    AllowRoot=1
    Include=/etc/zabbix/zabbix_agentd.d/*.conf
    LoadModulePath=/usr/lib/zabbix/modules
    LoadModule=libzbxpgsql.so
    
    # vi /etc/zabbix/zabbix_agentd.d/shell_postgresql96.conf
    
    #postgresql 
    UserParameter=shell_postgresql96[*],/etc/zabbix/shell_postgresql96.sh $1 $2
    

    创建 shell_postgresql96.sh

    # cd /etc/zabbix
    # vi shell_postgresql96.sh
    
    #!/bin/bash
    # -------------------------------------------------------------------------------
    # Filename:    shell_postgresql96.sh
    # Revision:    1.0
    # Date:        2018/09/06
    # Description: zabbix 3.4 monitor postgresql-9.6 additional measure
    # Notes:       
    # -------------------------------------------------------------------------------
    #
    #
    # 2018/09/06    peiyongbin    initialization this shell script
    
    PGSQLHOST=localhost
    PGSQLPORT=5432
    PGSQLDATABASE=postgres
    PGSQLUSER=zabbix
    
    sql=""
    case $1 in
         'db_size')
         if [[ $2 == "" ]];then
            sql="select sum(pg_database_size(datid)) as db_size from pg_stat_database"
         else
            sql="select pg_database_size(datid) as db_size from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_cache_hit_ratio')
         if [[ $2 == "" ]];then
            sql="select cast(sum(blks_hit)/(sum(blks_read)+sum(blks_hit)+0.000001)*100.0 as numeric(5,2)) as cache_hit from pg_stat_database"
         else 
            sql="select cast(blks_hit/(blks_read+blks_hit+0.000001)*100.0 as numeric(5,2)) as cache_hit from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_commit_count')
         if [[ $2 == "" ]];then
            sql="select sum(xact_commit) as db_commit_count from pg_stat_database"
         else 
            sql="select xact_commit as db_commit_count from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_rollback_count')
         if [[ $2 == "" ]];then
            sql="select sum(xact_rollback) as db_rollback_count from pg_stat_database"
         else 
            sql="select xact_rollback as db_rollback_count from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_commit_ratio')
         if [[ $2 == "" ]];then
            sql="select cast(sum(xact_commit)/(sum(xact_rollback)+sum(xact_commit)+0.000001)*100.0 as numeric(5,2)) as db_commit_ratio from pg_stat_database"
         else 
            sql="select cast(xact_commit/(xact_rollback+xact_commit+0.000001)*100.0 as numeric(5,2)) as db_commit_ratio from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_rollback_ratio')
         if [[ $2 == "" ]];then
            sql="select cast(sum(xact_rollback)/(sum(xact_rollback)+sum(xact_commit)+0.000001)*100.0 as numeric(5,2)) as db_rollback_ratio from pg_stat_database"
         else 
            sql="select cast(xact_rollback/(xact_rollback+xact_commit+0.000001)*100.0 as numeric(5,2)) as db_rollback_ratio from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_max_connection')
         sql="select current_setting('max_connections')::int8"
         ;;
    
         'db_current_connection')
         if [[ $2 == "" ]];then
            sql="select sum(numbackends) from pg_stat_database "
         else 
            sql="select numbackends from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_current_connection_ratio')
         sql="select cast(sum(numbackends)/cast(current_setting('max_connections') as int8)*100.0 as numeric(5,2)) as conn_ratio from pg_stat_database "
         ;;
    
         'db_current_connection_idle')
         if [[ $2 == "" ]];then
            sql="select count(1) from pg_stat_activity where state = 'idle'"
         else 
            sql="select count(1) from pg_stat_activity where state = 'idle' and datname = '$2'"
         fi
         ;;
    
         'db_current_connection_active')
         if [[ $2 == "" ]];then
            sql="select count(1) from pg_stat_activity where state = 'active' "
         else 
            sql="select count(1) from pg_stat_activity where state = 'active' and datname = '$2'"
         fi
         ;;
    
         'db_current_connection_intrans')
         if [[ $2 == "" ]];then
            sql="select count(1) from pg_stat_activity where state in ( 'idle in transaction','idle in transaction (aborted)' )"
         else 
            sql="select count(1) from pg_stat_activity where state in ( 'idle in transaction','idle in transaction (aborted)' ) and datname = '$2'"
         fi
         ;;
    
         'db_current_connection_waiting')
         if [[ $2 == "" ]];then
            sql="select count(1) from pg_stat_activity where wait_event like '%Lock%' "
         else 
            sql="select count(1) from pg_stat_activity where wait_event like '%Lock%' and datname = '$2'"
         fi
         ;;
    
         'db_current_connection_longtrans')
         if [[ $2 == "" ]];then
            sql="select count(1) as longtrans from pg_stat_activity where state <> 'idle' and extract(epoch FROM (clock_timestamp() - xact_start )) > 300 "
         else 
            sql="select count(1) as longtrans from pg_stat_activity where state <> 'idle' and extract(epoch FROM (clock_timestamp() - xact_start )) > 300 and datname = '$2'"
         fi
         ;;
    
         'db_current_connection_transtimemax')
         if [[ $2 == "" ]];then
            sql="select max(extract(epoch FROM (clock_timestamp() - xact_start ))) as longtrans from pg_stat_activity where state <> 'idle' "
         else 
            sql="select max(extract(epoch FROM (clock_timestamp() - xact_start ))) as longtrans from pg_stat_activity where state <> 'idle' and datname = '$2'"
         fi
         ;;
    
         'db_checkpoint_count')
         sql="select sum(checkpoints_timed + checkpoints_req) AS checkpoint_count from pg_stat_bgwriter where state <> 'idle'"
         ;;
    
         'db_stream_replica_count')
         sql="select count(1) as stream_count  from pg_stat_replication"
         ;;
    
         'db_stream_replica_delaymin')
         sql="select coalesce(min(pg_xlog_location_diff(sent_location, replay_location)),0) as stream_delaymin  from pg_stat_replication"
         ;;
    
         'db_stream_replica_delaymax')
         sql="select coalesce(max(pg_xlog_location_diff(sent_location, replay_location)),0) as stream_delaymax  from pg_stat_replication"
         ;;
    
         'db_tup_returned')
         if [[ $2 == "" ]];then
            sql="select sum(tup_returned) from pg_stat_database "
         else 
            sql="select tup_returned from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_tup_fetched')
         if [[ $2 == "" ]];then
            sql="select sum(tup_fetched) from pg_stat_database "
         else 
            sql="select tup_fetched from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_tup_inserted')
         if [[ $2 == "" ]];then
            sql="select sum(tup_inserted) from pg_stat_database "
         else 
            sql="select tup_inserted from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_tup_updated')
         if [[ $2 == "" ]];then
            sql="select sum(tup_updated) from pg_stat_database "
         else 
            sql="select tup_updated from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_tup_deleted')
         if [[ $2 == "" ]];then
            sql="select sum(tup_deleted) from pg_stat_database "
         else 
            sql="select tup_deleted from pg_stat_database where datname = '$2'"
         fi
         ;;
    
         'db_version')
         sql="select setting from pg_settings where name='server_version'"
         ;;
    esac
    
    su - postgres -c "psql -h $PGSQLHOST -U $PGSQLUSER -p $PGSQLPORT $PGSQLDATABASE -Atqc "$sql""
    
    
    

    导入监控模版

    zabbix web 页面操作

    Configuration -> Templates -> Import

    可以看到模版 Template_Shell_PostgreSQL96.xml

    需要注意的是模版文件的 value_type 需要和 Shell_postgresql96.conf 对应之类型一致,否则会报错。
    value_type integer
    0 - 浮点数
    1 - 字符
    2 - 日志
    3 - 数字(无正负)
    4 - 文本

    主机配置模板

    zabbix web 页面操作

    Configuration -> Hosts

    点击某台机器,进去选择 Templates,
    点击Select,选中 Template DB Shell PostgreSQL96 ,点击页下面的 Select
    点击 Add
    点击 Update

    这个 shell 脚本是对 postgresql 监控的补充。

    参考:
    https://www.zabbix.com/documentation/3.4/zh/manual/config/items/userparameters
    https://www.zabbix.com/documentation/3.4/zh/manual/config/items/userparameters/extending_agent

    https://www.zabbix.com/documentation/3.4/zh/manual/xml_export_import/templates?s[]=value&s[]=type

    Template_Shell_PostgreSQL96.xml 的具体内容,内容有点偏长

    <?xml version="1.0" encoding="UTF-8"?>
    <zabbix_export>
        <version>3.4</version>
        <date>2018-09-06T17:30:31Z</date>
        <groups>
            <group>
                <name>Templates/Databases</name>
            </group>
        </groups>
        <templates>
            <template>
                <template>Template DB Shell PostgreSQL96</template>
                <name>Template DB Shell PostgreSQL96</name>
                <description/>
                <groups>
                    <group>
                        <name>Templates/Databases</name>
                    </group>
                </groups>
                <applications>
                    <application>
                        <name>Shell PostgreSQL96 Backend Connections</name>
                    </application>
                    <application>
                        <name>Shell PostgreSQL96 Stream Replication</name>
                    </application>
                </applications>
                <items>
                    <item>
                        <name>Shell PostgreSQL Status</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>net.tcp.listen[5432]</key>
                        <delay>30s</delay>
                        <history>90d</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/>
                        <inventory_link>0</inventory_link>
                        <applications/>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Max Connection</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_max_connection]</key>
                        <delay>60s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Current Connection</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_current_connection]</key>
                        <delay>60s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Current Connection Ratio</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_current_connection_ratio]</key>
                        <delay>60s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Current Connection Idle</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_current_connection_idle]</key>
                        <delay>30s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Current Connection Active</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_current_connection_active]</key>
                        <delay>30s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Current Connection Intrans</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_current_connection_intrans]</key>
                        <delay>30s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
    
                    <item>
                        <name>Shell PostgreSQL96 Current Connection Waiting</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_current_connection_waiting]</key>
                        <delay>30s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Current Connection LongTrans</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_current_connection_longtrans]</key>
                        <delay>30s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Current Connection TransTimeMax</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_current_connection_transtimemax]</key>
                        <delay>30s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Backend Connections</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Stream Replication count</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_stream_replica_count]</key>
                        <delay>60s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Stream Replication</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Stream Replication DelayMin</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_stream_replica_delaymin]</key>
                        <delay>60s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Stream Replication</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL96 Stream Replication DelayMax</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_stream_replica_delaymax]</key>
                        <delay>60s</delay>
                        <history>90d</history>
                        <trends>0</trends>
                        <status>0</status>
                        <value_type>0</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/>
                        <inventory_link>0</inventory_link>
                        <applications>
                            <application>
                                <name>Shell PostgreSQL96 Stream Replication</name>
                            </application>
                        </applications>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                    <item>
                        <name>Shell PostgreSQL Version</name>
                        <type>0</type>
                        <snmp_community/>
                        <snmp_oid/>
                        <key>shell_postgresql96[db_version]</key>
                        <delay>60s</delay>
                        <history>90d</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/>
                        <inventory_link>0</inventory_link>
                        <applications/>
                        <valuemap/>
                        <logtimefmt/>
                        <preprocessing/>
                        <jmx_endpoint/>
                        <master_item/>
                    </item>
                </items>
                <discovery_rules/>
                <httptests/>
                <macros/>
                <templates/>
                <screens/>
            </template>
        </templates>
        <triggers>
            <trigger>
                <expression>{Template DB Shell PostgreSQL96:net.tcp.listen[5432].last()}=0</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>PostgreSQL is down</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 DB Shell PostgreSQL96:shell_postgresql96[db_current_connection_ratio].last()}>0.8</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>PostgreSQL Current Connection Too Many</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 DB Shell PostgreSQL96:shell_postgresql96[db_current_connection_intrans].last()}>10</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>PostgreSQL Current Connection Intrans Too Many</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 DB Shell PostgreSQL96:shell_postgresql96[db_current_connection_longtrans].last()}>5</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>PostgreSQL Current Connection Longtrans Too Many</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 DB Shell PostgreSQL96:shell_postgresql96[db_stream_replica_count].last()}=0</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>PostgreSQL Stream Replication is Offline</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 DB Shell PostgreSQL96:shell_postgresql96[db_stream_replica_delaymin].last()}>10240000</expression>
                <recovery_mode>0</recovery_mode>
                <recovery_expression/>
                <name>PostgreSQL Stream Replication Delay Too Long</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>
        </triggers>
        <graphs>
            <graph>
                <name>Shell PostgreSQL96 Connection</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 DB Shell PostgreSQL96</host>
                            <key>shell_postgresql96[db_max_connection]</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 DB Shell PostgreSQL96</host>
                            <key>shell_postgresql96[db_current_connection]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
            <graph>
                <name>Shell PostgreSQL96 Current Connection</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>00C800</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Shell PostgreSQL96</host>
                            <key>shell_postgresql96[db_current_connection_active]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>1</sortorder>
                        <drawtype>0</drawtype>
                        <color>C80000</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Shell PostgreSQL96</host>
                            <key>shell_postgresql96[db_current_connection_intrans]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>2</sortorder>
                        <drawtype>0</drawtype>
                        <color>0000C8</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Shell PostgreSQL96</host>
                            <key>shell_postgresql96[db_current_connection_waiting]</key>
                        </item>
                    </graph_item>
                    <graph_item>
                        <sortorder>3</sortorder>
                        <drawtype>0</drawtype>
                        <color>C800C8</color>
                        <yaxisside>0</yaxisside>
                        <calc_fnc>2</calc_fnc>
                        <type>0</type>
                        <item>
                            <host>Template DB Shell PostgreSQL96</host>
                            <key>shell_postgresql96[db_current_connection_longtrans]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
            <graph>
                <name>Shell PostgreSQL96 Stream Replication</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 DB Shell PostgreSQL96</host>
                            <key>shell_postgresql96[db_stream_replica_delaymin]</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 DB Shell PostgreSQL96</host>
                            <key>shell_postgresql96[db_stream_replica_delaymax]</key>
                        </item>
                    </graph_item>
                </graph_items>
            </graph>
        </graphs>
    </zabbix_export>
  • 相关阅读:
    php中如何实现在线网友
    用php与mysql的电子贺卡代码
    基于PHP MySQL的聊天室设计
    xml php动态载入与分页
    模拟OICQ的实现思路和核心程序
    FC4下安装plog快速指南(plog版本:1.01)
    一个简单的php在线端口扫描器
    UVA 10604 Chemical Reaction(六维dp数组)
    HDU 1503 Advanced Fruits
    hust 1607 Triangles(经典好题)
  • 原文地址:https://www.cnblogs.com/ctypyb2002/p/9792882.html
Copyright © 2011-2022 走看看