-
-
Save rockysays/eed59b933d9b307bca9e to your computer and use it in GitHub Desktop.
TCP Connections Stats for Zabbix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| /sbin/ss -ant | awk "{if (NR>1) {state[\$1]++}} END {host = \"-\"; \ | |
| for (i in state) {s=i; \ | |
| sub (/ESTAB/, \"establ\", s); sub (/LISTEN/, \"listen\", s); sub (/SYN-SENT/, \"synsent\", s); \ | |
| sub (/SYN-RECV/, \"synrecv\", s); sub (/FIN-WAIT-1/, \"finw1\", s); sub (/FIN-WAIT-2/, \"finw2\", s); \ | |
| sub (/CLOSE-WAIT/, \"closew\", s); sub (/TIME-WAIT/, \"timew\", s); print host, \"tcp.\"s, state[i]}}" \ | |
| | /usr/bin/zabbix_sender -vv -c /etc/zabbix/zabbix_agentd.conf -i - 2>&1 | |
| echo "1" | |
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <zabbix_export version="1.0" date="11.09.10" time="15.14"> | |
| <hosts> | |
| <host name="Template_UnixTcp"> | |
| <proxy_hostid>0</proxy_hostid> | |
| <useip>1</useip> | |
| <dns></dns> | |
| <ip>127.0.0.1</ip> | |
| <port>10050</port> | |
| <status>3</status> | |
| <useipmi>0</useipmi> | |
| <ipmi_ip>127.0.0.1</ipmi_ip> | |
| <ipmi_port>623</ipmi_port> | |
| <ipmi_authtype>0</ipmi_authtype> | |
| <ipmi_privilege>2</ipmi_privilege> | |
| <ipmi_username></ipmi_username> | |
| <ipmi_password></ipmi_password> | |
| <groups> | |
| <group>Linux servers</group> | |
| </groups> | |
| <triggers> | |
| <trigger> | |
| <description>ESTABLISHED</description> | |
| <type>0</type> | |
| <expression>{Template_UnixTcp:tcp.establ.last(0)}>200</expression> | |
| <url></url> | |
| <status>0</status> | |
| <priority>3</priority> | |
| <comments></comments> | |
| </trigger> | |
| <trigger> | |
| <description>TIME_WAIT</description> | |
| <type>0</type> | |
| <expression>{Template_UnixTcp:tcp.timew.last(0)}>300</expression> | |
| <url></url> | |
| <status>0</status> | |
| <priority>3</priority> | |
| <comments></comments> | |
| </trigger> | |
| </triggers> | |
| <items> | |
| <item type="0" key="tcp.all" value_type="3"> | |
| <description>Controller</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| <item type="2" key="tcp.closew" value_type="3"> | |
| <description>CLOSE_WAIT</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| <item type="2" key="tcp.establ" value_type="3"> | |
| <description>ESTABLISHED</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| <item type="2" key="tcp.finw1" value_type="3"> | |
| <description>FIN_WAIT1</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| <item type="2" key="tcp.finw2" value_type="3"> | |
| <description>FIN_WAIT2</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| <item type="2" key="tcp.listen" value_type="3"> | |
| <description>LISTEN</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| <item type="2" key="tcp.synrecv" value_type="3"> | |
| <description>SYN_RECV</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| <item type="2" key="tcp.synsent" value_type="3"> | |
| <description>SYN_SENT</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| <item type="2" key="tcp.timew" value_type="3"> | |
| <description>TIME_WAIT</description> | |
| <ipmi_sensor></ipmi_sensor> | |
| <delay>60</delay> | |
| <history>90</history> | |
| <trends>365</trends> | |
| <status>0</status> | |
| <data_type>0</data_type> | |
| <units></units> | |
| <multiplier>0</multiplier> | |
| <delta>0</delta> | |
| <formula>0</formula> | |
| <lastlogsize>0</lastlogsize> | |
| <logtimefmt></logtimefmt> | |
| <delay_flex></delay_flex> | |
| <authtype>0</authtype> | |
| <username></username> | |
| <password></password> | |
| <publickey></publickey> | |
| <privatekey></privatekey> | |
| <params></params> | |
| <trapper_hosts></trapper_hosts> | |
| <snmp_community></snmp_community> | |
| <snmp_oid></snmp_oid> | |
| <snmp_port>161</snmp_port> | |
| <snmpv3_securityname></snmpv3_securityname> | |
| <snmpv3_securitylevel>0</snmpv3_securitylevel> | |
| <snmpv3_authpassphrase></snmpv3_authpassphrase> | |
| <snmpv3_privpassphrase></snmpv3_privpassphrase> | |
| <applications> | |
| <application>TCP</application> | |
| </applications> | |
| </item> | |
| </items> | |
| <templates/> | |
| <graphs> | |
| <graph name="TCP Connections" width="900" height="200"> | |
| <ymin_type>0</ymin_type> | |
| <ymax_type>0</ymax_type> | |
| <ymin_item_key></ymin_item_key> | |
| <ymax_item_key></ymax_item_key> | |
| <show_work_period>1</show_work_period> | |
| <show_triggers>1</show_triggers> | |
| <graphtype>1</graphtype> | |
| <yaxismin>0.0000</yaxismin> | |
| <yaxismax>100.0000</yaxismax> | |
| <show_legend>0</show_legend> | |
| <show_3d>0</show_3d> | |
| <percent_left>0.0000</percent_left> | |
| <percent_right>0.0000</percent_right> | |
| <graph_elements> | |
| <graph_element item="Template_UnixTcp:tcp.timew"> | |
| <drawtype>1</drawtype> | |
| <sortorder>0</sortorder> | |
| <color>3333FF</color> | |
| <yaxisside>0</yaxisside> | |
| <calc_fnc>2</calc_fnc> | |
| <type>0</type> | |
| <periods_cnt>5</periods_cnt> | |
| </graph_element> | |
| <graph_element item="Template_UnixTcp:tcp.listen"> | |
| <drawtype>1</drawtype> | |
| <sortorder>1</sortorder> | |
| <color>FFFF66</color> | |
| <yaxisside>0</yaxisside> | |
| <calc_fnc>2</calc_fnc> | |
| <type>0</type> | |
| <periods_cnt>5</periods_cnt> | |
| </graph_element> | |
| <graph_element item="Template_UnixTcp:tcp.finw2"> | |
| <drawtype>1</drawtype> | |
| <sortorder>1</sortorder> | |
| <color>CCCCCC</color> | |
| <yaxisside>0</yaxisside> | |
| <calc_fnc>2</calc_fnc> | |
| <type>0</type> | |
| <periods_cnt>5</periods_cnt> | |
| </graph_element> | |
| <graph_element item="Template_UnixTcp:tcp.finw1"> | |
| <drawtype>1</drawtype> | |
| <sortorder>2</sortorder> | |
| <color>DDDDDD</color> | |
| <yaxisside>0</yaxisside> | |
| <calc_fnc>2</calc_fnc> | |
| <type>0</type> | |
| <periods_cnt>5</periods_cnt> | |
| </graph_element> | |
| <graph_element item="Template_UnixTcp:tcp.closew"> | |
| <drawtype>1</drawtype> | |
| <sortorder>3</sortorder> | |
| <color>9999FF</color> | |
| <yaxisside>0</yaxisside> | |
| <calc_fnc>2</calc_fnc> | |
| <type>0</type> | |
| <periods_cnt>5</periods_cnt> | |
| </graph_element> | |
| <graph_element item="Template_UnixTcp:tcp.synsent"> | |
| <drawtype>1</drawtype> | |
| <sortorder>4</sortorder> | |
| <color>BBBB00</color> | |
| <yaxisside>0</yaxisside> | |
| <calc_fnc>2</calc_fnc> | |
| <type>0</type> | |
| <periods_cnt>5</periods_cnt> | |
| </graph_element> | |
| <graph_element item="Template_UnixTcp:tcp.synrecv"> | |
| <drawtype>1</drawtype> | |
| <sortorder>5</sortorder> | |
| <color>DDDD00</color> | |
| <yaxisside>0</yaxisside> | |
| <calc_fnc>2</calc_fnc> | |
| <type>0</type> | |
| <periods_cnt>5</periods_cnt> | |
| </graph_element> | |
| <graph_element item="Template_UnixTcp:tcp.establ"> | |
| <drawtype>1</drawtype> | |
| <sortorder>6</sortorder> | |
| <color>009900</color> | |
| <yaxisside>0</yaxisside> | |
| <calc_fnc>2</calc_fnc> | |
| <type>0</type> | |
| <periods_cnt>5</periods_cnt> | |
| </graph_element> | |
| </graph_elements> | |
| </graph> | |
| </graphs> | |
| <macros/> | |
| </host> | |
| </hosts> | |
| <dependencies/> | |
| </zabbix_export> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #add to /etc/zabbix/zabbix_agentd.conf | |
| UserParameter=tcp.all, /usr/local/share/zabbix/externalscripts/tcpstats.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment