目录

一、apache监控

二、nginx监控

三、mysql监控

四、redis监控

五、tcp监控


一、apache监控

基于第三方模板利用httpd自带的status页面进行监控
1、开启http-status功能

[root@zabbix6 conf.d]# ls /etc/httpd/modules/ | grep status
 mod_status.so

2、配置status允许访问的地址,实际环境勿全部允许

[root@zabbix6 ~]# vi /etc/httpd/conf.d/status.conf 
 ExtendedStatus On
 <location /server-status>
     SetHandler server-status
     Order Allow,Deny
     Allow from all
 </location>[root@zabbix6 conf.d]# service httpd restart

3、下载部署zapache模块

[root@zabbix6 ~]# git clone https:///lorf/zapache.git 
 [root@zabbix6 ~]# cp -r zapache/zapache /etc/zabbix/libexec/
 [root@zabbix6 ~]# cp zapache/userparameter_zapache.conf.sample /etc/zabbix/zabbix_agentd.d/userparameter_zapache.conf
 [root@agent1 zapache]# chmod 755  /etc/zabbix/libexec/*
 [root@agent1 zapache]# vi  /etc/zabbix/zabbix_agentd.d/userparameter_zapache.conf
 修改为UserParameter=zapache[*],/etc/zabbix/libexec/zapache \$1

4、zabbix页面载入模板
配置——模板——导入——选择下载好的模板文件zapache-template.xml
配置——主机——链接相应的模板Template App Apache Web Server zapache

5、压力测试(如果需要快速出图的话)

[root@server ~]# echo 65535 >  /proc/sys/net/core/somaxconn 
 [root@server ~]# ulimit -HSn 65535 
 [root@server ~]# ab -c 1000 -n 1000000 http://192.168.10.41/index.html

6、设置个聚合图形方便监测

zabbix ssh 监控项 zabbix监控apache_apache

二、nginx监控

1、部署Nginx,并开启status模块

[root@agent1 nginx-1.15.7]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
 yum -y install gcc gcc-c++ autoconf automake make
 yum -y install pcre-devel
 yum install -y zlib-devel
 [root@agent1 nginx-1.15.7]# make
 [root@agent1 nginx-1.15.7]# make install

2、开启status功能
nginx.conf文件添加server标签下面

location /status  {
         stub_status on;
         access_log off;
         #allow 127.0.0.1;允许哪个ip可以访问
         }

3、启动Nginx

[root@agent1 ~]# /usr/local/nginx/sbin/nginx
 如果启动失败,端口占用,更换端口尝试,注意selinux和端口开通#测试
 [root@agent1 ~]# curl http://192.168.198.41:8080/status 
 Active connections: 3 
 server accepts handled requests
  4 4 3 
 Reading: 0 Writing: 1 Waiting: 2

active connections – 活跃的连接数量
server accepts handled requests — 总共处理了N个连接 , 成功创建N次握手, 总共处理了N个请求
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.

 

4、配置znginx

下载znginx
git clone https:///BaiShuming/znginx
Znginx 是一款基于zabbix对Nginx监控的一个模板
Znginx 需要Nginx ngx_http_stub_status_module支持
Znginx 对Nginx服务状态进行监控、并通过触发器报警
Znginx 对连接状态进行监控,并设置图表
Znginx 提供了zabbix监控插件文件

sudo mkdir /etc/zabbix/libexec/
sudo cp znginx/znginx /etc/zabbix/libexec/
sudo cp znginx/userparameter_znginx.conf.sample /etc/zabbix/zabbix_agentd.d/userparameter_znginx.conf
https:///BaiShuming/znginx

zabbix server web
配置---模板---导入
zbx_export_templates.xml

三、mysql监控

 

1、环境搭建

[root@agent1 libexec]# yum install mysql mysql-server -y
 [root@agent1 ~]# service mysqld restart
 [root@agent1 ~]# mysqladmin -u root -h 127.0.0.1 status
 Uptime: 60  Threads: 1  Questions: 4  Slow queries: 0  Opens: 15  Flush tables: 1  Open tables: 8  Queries per second avg: 0.66

2、利用三方percona

运行环境php php-mysql下载
yum -y install mariadb-server php php-mysql 

下载三方mysql-zabbix监控包

wget https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring -plugins-1.1.8/binary/redhat/6/x86_64/percona-zabbix-templates-1.1.8-1.noarch.rpm
 [root@agent1 ~]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm 
 warning: percona-zabbix-templates-1.1.8-1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
 Preparing...                ########################################### [100%]
    1:percona-zabbix-template########################################### [100%]

3、列出脚本文件和配置文件的路径

Scripts are installed to /var/lib/zabbix/percona/scripts
 Templates are installed to /var/lib/zabbix/percona/templates

4、修改mysql用户密码信息

[root@agent1 scripts]# vi /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php

5、测试脚本有结果说明正常

[root@agent1 scripts]# sh get_mysql_stats_wrapper.sh iz
 8

6、相应脚本和键值对配置文件放入相应位置

[root@agent1 templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
 [root@agent1 scripts]# cp /var/lib/zabbix/percona/scripts/* /etc/zabbix/libexec/
 [root@agent1 templates]# chown zabbix.zabbix /tmp/localhost-mysql_cacti_stats.txt

7、zabbix界面上传模板文件-主机关联-图形展示

如果percona官网下载的zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8模板上传报错
可能是不兼容zabbix3.0的原因,可以在我的下载里面下载兼容版本,叫zbx_export_templates.xml。

四、redis监控

 

建议使用centos7进行实验,centos6因python版本会导致问题,目前我在坑中。。
1、安装redis
Redis是一个key-value存储系统,它支持丰富的数据类型,Redis以内存作为数据存储介质,所以读写数据的效率极高
Redis跟memcache不同的是,储存在Redis中的数据是持久化的,断电或重启后,数据也不会丢失。因为Redis的存储分为内存存储、磁盘存储和log文件三部分,重启后,Redis可以从磁盘重新将数据加载到内存中,这些可以通过配置文件对其进行配置。
Redis支持主从模式,可以配置集群,这样更利于支撑起大型的项目。

#源码安装
 [root@agent1 redis-5.0.2]# wget http://download.redis.io/releases/redis-5.0.2.tar.gz
 [root@agent1 redis-5.0.2]# tar zxvf redis-5.0.2.tar.gz 
 [root@agent1 redis-5.0.2]# make PREFIX=/usr/local/redis && make install
 如遇到错误如下,删除redis文件夹重新解压编译
 cd src && make all
 make[1]: Entering directory `/root/redis-5.0.2/src'
     LINK redis-server
 cc: ../deps/jemalloc/lib/libjemalloc.a:没有那个文件或目录
 make[1]: *** [redis-server] 错误 1
 make[1]: Leaving directory `/root/redis-5.0.2/src'
 make: *** [all] 错误 2#配置redis
 [root@agent1 ~]# mkdir /usr/local/redis/etc  
 [root@agent1 ~]# cp redis-5.0.2/redis.conf /usr/local/redis/etc/
 [root@agent1 ~]# vi /usr/local/redis/etc/redis.conf
 bind 0.0.0.0   允许所有地址访问
 daemonize yes  后台#启动加载配置文件
 [root@agent1 etc]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf #测试。可以自定义shell利用info获取相关信息
 [root@agent1 etc]# ln -s /usr/local/redis/bin/* /usr/local/bin/
 [root@agent1 etc]# redis-cli -h 127.0.0.1 -p 6379 info

2、被检测机安装配置三方模板

#模板系统要求,需要python和redis-py环境
 centos6自带python,pip为python安装命令,先安装pip,再安装redis-py环境
 [root@agent1 ~]# python -s   
 Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) 
 [root@agent1 ~]# yum install -y epel-release
 [root@agent1 ~]# yum install -y python-pip
 [root@agent1 ~]# pip install redis#三方脚本相关配置改为自己服务器对应的IP和地址
 [root@agent1 zbx_redis_template]# vi zbx_redis_stats.py 
 zabbix_host = '192.168.198.130'       # Zabbix Server IP
 def send_to_zabbix(metrics, zabbix_host='192.168.198.130', zabbix_port=10051):
 [root@agent1 zbx_redis_template]# vi zbx_redis.conf
 UserParameter=redis.discovery,/etc/zabbix/libexec/zbx_redis_stats.py localhost list_key_space_db
 UserParameter=redis[*],/etc/zabbix/libexec/zbx_redis_stats.py $1 $2 $3#将脚本文件和键值对配置文件放到自身对应目录
 [root@agent1 zbx_redis_template]# cp  zbx_redis_stats.py /etc/zabbix/libexec/
 [root@agent1 zbx_redis_template]# chmod 755 /etc/zabbix/libexec/
 [root@agent1 zbx_redis_template]# cp zbx_redis.conf /etc/zabbix/zabbix_agentd.d/#配置完成,重启服务
 [root@agent1 zbx_redis_template]# ps -ef | grep redis
 root      16892      1  0 06:06 ?        00:00:02 /usr/local/redis/bin/redis-server 0.0.0.0:6379                   
 root      18269  17441  0 06:43 pts/0    00:00:00 grep redis
 [root@agent1 zbx_redis_template]# /etc/init.d/zabbix-agent restart
 Shutting down Zabbix agent: [确定]
 Starting Zabbix agent: [确定]


3、zabbix界面导入模板配置
发现主机redis监控报错不支持
Received value [Traceback (most recent call last): File "/etc/zabbix/libexec/zbx_redis_stats.py", line 3, in <module> import sys, redis, json, re, struct, time, socket, argparse File "/usr/lib/python2.6/site-packages/redis/__init__.py", line 1, in <module> from redis.client import Redis, StrictRedis File "/usr/lib/python2.6/site-packages/redis/client.py", line 3198 return {decode(encode(k)): v for k, v in iteritems(data)} ^SyntaxError: invalid syntax] is not suitable for value type [Numeric (float)]

需要升级python版本,相关配置https://www.moewah.com/archives/391.html
目前yum使用正常,不出图暂时不知道解决方法,据说centos7默认python3,不会出现这些问题,待定。。日后学习python再回来看看。

五、tcp监控

1、监控脚本

[root@agent1 libexec]# pwd
 /etc/zabbix/libexec
 [root@agent1 libexec]# cat tcp_status.sh 
 #!/bin/bash
 #this script is used to get tcp and udp connetion status
 #tcp status
 metric=$1
 tmp_file=/tmp/tcp_status.txt
 /bin/netstat -an|awk '/^tcp/{++S[$NF]}END{for(a in S) print a,S[a]}' > $tmp_file
  
 case $metric in
    closed)
           output=$(awk '/CLOSED/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
         ;;
    listen)
           output=$(awk '/LISTEN/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
         ;;
    synrecv)
           output=$(awk '/SYN_RECV/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
         ;;
    synsent)
           output=$(awk '/SYN_SENT/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
         ;;
    established)
           output=$(awk '/ESTABLISHED/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
         ;;
    timewait)
           output=$(awk '/TIME_WAIT/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
         ;;
    closing)
           output=$(awk '/CLOSING/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
         ;;
    closewait)
           output=$(awk '/CLOSE_WAIT/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
         ;;
    lastack)
           output=$(awk '/LAST_ACK/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
          ;;
    finwait1)
           output=$(awk '/FIN_WAIT1/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
          ;;
    finwait2)
           output=$(awk '/FIN_WAIT2/{print $2}' $tmp_file)
           if [ "$output" == "" ];then
              echo 0
           else
              echo $output
           fi
          ;;
          *)
           echo -e "\e[033mUsage: sh  $0 [closed|closing|closewait|synrecv|synsent|finwait1|finwait2|listen|established|lastack|timewait]\e[0m"
    
 esac

2、键值对脚本

[root@agent1 zabbix_agentd.d]# pwd
 /etc/zabbix/zabbix_agentd.d
 [root@agent1 zabbix_agentd.d]# cat zabbix_agentd.conf 
 UserParameter=tcp.status[*],/etc/zabbix/libexec/tcp_status.sh $1

3、server机测试

[root@zabbix6 ~]# zabbix_get -s 192.168.198.131  -k tcp.status[listen] 
 6

4、tcp监控模板

cat Template_TCP_Stats.xml
 <?xml version="1.0" encoding="UTF-8"?>
 <zabbix_export>
     <version>2.0</version>
     <date>2014-12-04T09:41:57Z</date>
     <groups>
         <group>
             <name>Templates</name>
         </group>
     </groups>
     <templates>
         <template>
             <template>Template TCP Connection Status</template>
             <name>Template TCP Connection Status</name>
             <groups>
                 <group>
                     <name>Templates</name>
                 </group>
             </groups>
             <applications>
                 <application>
                     <name>TCP Status</name>
                 </application>
             </applications>
             <items>
                 <item>
                     <name>CLOSED</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[closed]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>CLOSE_WAIT</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[closewait]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>CLOSING</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[closing]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>ESTABLISHED</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[established]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>FIN_WAIT1</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[finwait1]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>FIN_WAIT2</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[finwait2]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>LAST_ACK</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[lastack]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>LISTEN</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[listen]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>SYN_RECV</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[synrecv]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>SYN_SENT</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[synsent]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
                 <item>
                     <name>TIME_WAIT</name>
                     <type>0</type>
                     <snmp_community/>
                     <multiplier>0</multiplier>
                     <snmp_oid/>
                     <key>tcp.status[timewait]</key>
                     <delay>60</delay>
                     <history>90</history>
                     <trends>365</trends>
                     <status>0</status>
                     <value_type>3</value_type>
                     <allowed_hosts/>
                     <units/>
                     <delta>0</delta>
                     <snmpv3_contextname/>
                     <snmpv3_securityname/>
                     <snmpv3_securitylevel>0</snmpv3_securitylevel>
                     <snmpv3_authprotocol>0</snmpv3_authprotocol>
                     <snmpv3_authpassphrase/>
                     <snmpv3_privprotocol>0</snmpv3_privprotocol>
                     <snmpv3_privpassphrase/>
                     <formula>1</formula>
                     <delay_flex/>
                     <params/>
                     <ipmi_sensor/>
                     <data_type>0</data_type>
                     <authtype>0</authtype>
                     <username/>
                     <password/>
                     <publickey/>
                     <privatekey/>
                     <port/>
                     <description/>
                     <inventory_link>0</inventory_link>
                     <applications>
                         <application>
                             <name>TCP Status</name>
                         </application>
                     </applications>
                     <valuemap/>
                 </item>
             </items>
             <discovery_rules/>
             <macros/>
             <templates/>
             <screens/>
         </template>
     </templates>
     <triggers>
         <trigger>
             <expression>{Template TCP Connection Status:tcp.status[timewait].last()}>10000</expression>
             <name>There are too many TCP TIME_WAIT status</name>
             <url/>
             <status>0</status>
             <priority>4</priority>
             <description/>
             <type>0</type>
             <dependencies/>
         </trigger>
     </triggers>
     <graphs>
         <graph>
             <name>TCP Status</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>C80000</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[closed]</key>
                     </item>
                 </graph_item>
                 <graph_item>
                     <sortorder>1</sortorder>
                     <drawtype>0</drawtype>
                     <color>00C800</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[closewait]</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 TCP Connection Status</host>
                         <key>tcp.status[closing]</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 TCP Connection Status</host>
                         <key>tcp.status[established]</key>
                     </item>
                 </graph_item>
                 <graph_item>
                     <sortorder>4</sortorder>
                     <drawtype>0</drawtype>
                     <color>00C8C8</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[finwait1]</key>
                     </item>
                 </graph_item>
                 <graph_item>
                     <sortorder>5</sortorder>
                     <drawtype>0</drawtype>
                     <color>C8C800</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[finwait2]</key>
                     </item>
                 </graph_item>
                 <graph_item>
                     <sortorder>6</sortorder>
                     <drawtype>0</drawtype>
                     <color>C8C8C8</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[lastack]</key>
                     </item>
                 </graph_item>
                 <graph_item>
                     <sortorder>7</sortorder>
                     <drawtype>0</drawtype>
                     <color>960000</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[listen]</key>
                     </item>
                 </graph_item>
                 <graph_item>
                     <sortorder>8</sortorder>
                     <drawtype>0</drawtype>
                     <color>009600</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[synrecv]</key>
                     </item>
                 </graph_item>
                 <graph_item>
                     <sortorder>9</sortorder>
                     <drawtype>0</drawtype>
                     <color>000096</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[synsent]</key>
                     </item>
                 </graph_item>
                 <graph_item>
                     <sortorder>10</sortorder>
                     <drawtype>0</drawtype>
                     <color>960096</color>
                     <yaxisside>0</yaxisside>
                     <calc_fnc>2</calc_fnc>
                     <type>0</type>
                     <item>
                         <host>Template TCP Connection Status</host>
                         <key>tcp.status[timewait]</key>
                     </item>
                 </graph_item>
             </graph_items>
         </graph>
     </graphs>
 </zabbix_export>

5、zabbix前台相关设置

常规操作-导入-链接-出图成功
LISTEN:等待从任何远端TCP 和端口的连接请求。 
SYN_SENT:发送完一个连接请求后等待一个匹配的连接请求。 
SYN_RECEIVED:发送连接请求并且接收到匹配的连接请求以后等待连接请求确认。 
ESTABLISHED:表示一个打开的连接,接收到的数据可以被投递给用户。连接的数据传输阶段的正常状态。 
FIN_WAIT_1:等待远端TCP 的连接终止请求,或者等待之前发送的连接终止请求的确认。 
FIN_WAIT_2:等待远端TCP 的连接终止请求。 
CLOSE_WAIT:等待本地用户的连接终止请求。 
CLOSING:等待远端TCP 的连接终止请求确认。
LAST_ACK:等待先前发送给远端TCP 的连接终止请求的确认(包括它字节的连接终止请求的确认) 
TIME_WAIT:等待足够的时间过去以确保远端TCP 接收到它的连接终止请求的确认。 
TIME_WAIT 两个存在的理由: 
1.可靠的实现tcp全双工连接的终止; 
2.允许老的重复分节在网络中消逝。 
CLOSED:不在连接状态(这是为方便描述假想的状态,实际不存在)