码迷,mamicode.com
首页 > 其他好文 > 详细

Zabbix系列之五——监控TCP端口

时间:2018-06-19 22:53:58      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:screens   manual   value   pad   alt   window   moni   default   bottom   

 

监控端口的几个主要Keys:

 

net.tcp.listen[port]

Checks if this port is in LISTEN state. 0 - it is not, 1 - it is in LISTEN state.

监控TCP端口是否监听

net.tcp.port[<ip>,port]

Check, if it is possible to make TCP connection to the port number. 0 - cannot connect, 

1 - can connect. IP address is optional. If ip is missing, 127.0.0.1 is used. 

Example: net.tcp.port[,80]

检查TCP端口是否可以正常连接。

net.tcp.service[service,<ip>,<port>]

Check if service is available. 0 - service is down, 1 - service is running. 

If ip is missing 127.0.0.1 is used. If port number is missing, default service port is used. 

Example: net.tcp.service[ftp,,45].

检查服务是否可用,FTP服务可直接使用FTP模板

net.tcp.service.perf[service,<ip>,<port>]

Check performance of service "service". 0 - service is down, sec - number of seconds spent on connection to the service. 

If ip is missing 127.0.0.1 is used. If port number is missing, default service port is used.

监控服务(端口)连接性能

net.udp.listen[port]

Checks if this port is in LISTEN state. 0 - it is not, 1 - it is in LISTEN state.

监控UDP端口是否监听(不支持windows

 

说明:Zabbix自带单独服务检测模板,如Template App FTP Service,就是使用的ket.tcp.service[ftp]这个KEY来监控的。

 

模板如下,可根据需求修改端口及触发器名称:

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>3.4</version>
    <date>2018-06-19T06:10:48Z</date>
    <groups>
        <group>
            <name>Tcp Port</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template Tcp Port 4234</template>
            <name>Template Tcp Port 4234</name>
            <description/>
            <groups>
                <group>
                    <name>Tcp Port</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Tcp Port Monitor</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>tcp port 4234 is listen</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>net.tcp.listen[4234]</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>
                        <application>
                            <name>Tcp Port Monitor</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>tcp port 4234 is connection</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>net.tcp.port[,4234]</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>
                        <application>
                            <name>Tcp Port Monitor</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>tcp port 4234 performance</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>net.tcp.service.perf[http,,4234]</key>
                    <delay>30s</delay>
                    <history>90d</history>
                    <trends>365d</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>Tcp Port Monitor</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
                <item>
                    <name>tcp port 4234 is running</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>net.tcp.service[http,,4234]</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>
                        <application>
                            <name>Tcp Port Monitor</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                    <preprocessing/>
                    <jmx_endpoint/>
                    <master_item/>
                </item>
            </items>
            <discovery_rules/>
            <httptests/>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
    <triggers>
        <trigger>
            <expression>{Template Tcp Port 4234:net.tcp.listen[4234].last()}=0</expression>
            <recovery_mode>0</recovery_mode>
            <recovery_expression/>
            <name>tcp port 4234(Paypre) is down</name>
            <correlation_mode>0</correlation_mode>
            <correlation_tag/>
            <url/>
            <status>0</status>
            <priority>5</priority>
            <description/>
            <type>0</type>
            <manual_close>0</manual_close>
            <dependencies/>
            <tags/>
        </trigger>
    </triggers>
    <graphs>
        <graph>
            <name>tcp port 4234</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 Tcp Port 4234</host>
                        <key>net.tcp.port[,4234]</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 Tcp Port 4234</host>
                        <key>net.tcp.listen[4234]</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 Tcp Port 4234</host>
                        <key>net.tcp.service[http,,4234]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <drawtype>0</drawtype>
                    <color>A54F10</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template Tcp Port 4234</host>
                        <key>net.tcp.service.perf[http,,4234]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
    </graphs>
</zabbix_export>

 导入模板:

【配置】——【模板】——【导入】

 技术分享图片

进入模板添加主机:

技术分享图片

设置被监控主机:

技术分享图片

查看效果:

技术分享图片

 

Zabbix系列之五——监控TCP端口

标签:screens   manual   value   pad   alt   window   moni   default   bottom   

原文地址:https://www.cnblogs.com/Dev0ps/p/9198653.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!