Zabbix监控TCP status

时间:2021-11-12 22:45:59

监控原理

ss -ant | awk 'NR>1 {++s[$1]} END {for(k in s) print k,s[k]}'

LAST-ACK 5
ESTAB 348
FIN-WAIT-1 11
CLOSING 1
FIN-WAIT-2 41
TIME-WAIT 2447
LISTEN 8

状态值的解释

ESTABLISHED:  The socket has an established connection.

SYN_SENT:  The socket is actively attempting to establish a connection.

SYN_RECV:  A connection request has been received from the network.

FIN_WAIT1:  The socket is closed, and the connection is shutting down.

FIN_WAIT2:  Connection is closed, and the socket is waiting for a shutdown from the remote end.

TIME_WAIT:  The socket is waiting after close to handle packets still in the network.

CLOSED:  The socket is not being used.

CLOSE_WAIT:  The remote end has shut down, waiting for the socket to close.

LAST_ACK:  The remote end has shut down, and the socket is closed. Waiting for acknowledgement.

LISTEN:  The  socket  is listening for incoming connections.

CLOSING:  Both sockets are shut down but we still don’t have all our data sent.

监控脚本

#!/bin/bash
# // pdd
# 未出现的状态值取0 status() {
ss -ant | awk 'NR>1 {++s[$1]} END {for(k in s) print k,s[k]}'
} case $ in
LISTEN)
listen=`status | grep "$1" | awk '{print $2}'`
[ -z "$listen" ] && echo || echo "$listen"
;;
SYN-SENT)
syn_sent=`status | grep "$1" | awk '{print $2}'`
[ -z "$syn_sent" ] && echo || echo "$syn_sent"
;;
SYN-RCVD)
syn_rcvd=`status | grep "$1" | awk '{print $2}'`
[ -z "$syn_rcvd" ] && echo || echo "$syn_rcvd"
;;
ESTAB)
estab=`status | grep "$1" | awk '{print $2}'`
[ -z "$estab" ] && echo || echo "$estab"
;;
FIN-WAIT-)
fin_wait_1=`status | grep "$1" | awk '{print $2}'`
[ -z "$fin_wait_1" ] && echo || echo "$fin_wait_1"
;;
CLOSE-WAIT)
close_wait=`status | grep "$1" | awk '{print $2}'`
[ -z "$close_wait" ] && echo || echo "$close_wait"
;;
FIN-WAIT-)
fin_wait_2=`status | grep "$1" | awk '{print $2}'`
[ -z "$fin_wait_2" ] && echo || echo "$fin_wait_2"
;;
LAST-ACK)
last_ack=`status | grep "$1" | awk '{print $2}'`
[ -z "$last_ack" ] && echo || echo "$last_ack"
;;
TIME-WAIT)
time_wait=`status | grep "$1" | awk '{print $2}'`
[ -z "$time_wait" ] && echo || echo "$time_wait"
;;
CLOSED)
closed=`status | grep "$1" | awk '{print $2}'`
[ -z "$closed" ] && echo || echo "$closed"
;;
*)
echo "Usage: LISTEN SYN-SENT SYN-RCVD ESTAB FIN-WAIT-1 CLOSE-WAIT FIN-WAIT-2 LAST-ACK TIME-WAIT CLOSED"
;;
esac

添加配置文件

userparameter_tcp.conf  # 需要reload zabbix_agentd

# TCP
UserParameter=tcp.status[*],/usr/local/zabbix/scripts/tcp-status.sh $

添加监控模板

Zabbix监控TCP status

Zabbix监控TCP status的更多相关文章

  1. Zabbix监控nginx-rtmp status(json版)

    与前面的文章 zabbix监控nginx-rtmp status(html版)区别只在于取值的页面不一样 http://127.0.0.1:81/control/get/all_streams sta ...

  2. zabbix监控tcp状态

    Tcp的连接状态对于我们web服务器来说是至关重要的,从TCP的连接状态中可以看出网络的连接情况,服务器的压力情况,对服务器的并发有很好的直观反映:尤其是并发量ESTAB:或者是syn_recv值,假 ...

  3. zabbix监控tcp连接数的脚本!!

    #!/bin/bash #this script is used to get tcp and udp connetion status #tcp status metric=$ tmp_file=/ ...

  4. zabbix监控tcp连接并发数

    第一步,想在zabbix的web监控tcp连接数,那么要看zabbix-server的版本和zabbix-agent版本是否一致,不然TCP-status图没有数据 也会报错.下图就是版本不符合报错的 ...

  5. ZABBIX监控TCP连接状态

    一.获取监控数据 # /bin/netstat -an|awk '/^tcp/{++S[$NF]}END{for(a in S) print a,S[a]}' LISTEN ESTABLISHED T ...

  6. zabbix 监控TCP状态连接数

    1.zabbix客户端,监控TCP状态脚本,并保存到的定路径.(/usr/local/zabbix-agent/shells) # cat zabbix_linux_plugin.sh #!/bin/ ...

  7. Zabbix监控redis status

    概述 zabbix采用Trapper方式监控redis status 原理 redis-cli info命令得到redis服务器的统计信息,脚本对信息分两部分处理: (1)# Keyspace部分为Z ...

  8. Zabbix监控php-fpm status

    开启php-fpm status php-fpm.conf pm.status_path = /statusx45 nginx.conf location ~ /(statusx45)$ { incl ...

  9. Zabbix监控nginx status

    nginx开启status ./configure --with-http_stub_status_module nginx.conflocation /statusx35 { stub_status ...

随机推荐

  1. python遍历删除列表的方法

    for item in list(somelist): somelist.remove(item)

  2. 【Tree 3】树形结构数据加载的思考

    前面两篇文章,分别介绍了使用递归和非递归算法加载树形结构数据的方式,本篇文章,则是自己闲下来的时候,进行的一点小思考. 一.什么地方会用到树形结构 刚开始一看到这种结构的时候,最先是想到了家谱.家谱就 ...

  3. 【HTTP劫持和DNS劫持】腾讯的实际业务分析

        简单介绍一下HTTP劫持和DNS劫持的概念,也就是运营商通过某些方式篡改了用户正常访问的网页,插入广告或者其他一些杂七杂八的东西.       首先对运营商的劫持行为做一些分析,他们的目的无非 ...

  4. jQuery 一些小技巧

    1. 返回顶部按钮 可以利用 animate 和 scrollTop 来实现返回顶部的动画,而不需要使用其他插件. // Back to top                             ...

  5. Android APP安全评估工具 Drozer - 使用介绍

    一.列出drozer当前可用的所有模块dz> list dz> list app.activity.forintent Find activities that can handle th ...

  6. 用Python作GIS之二:STARS开发环境配置

    STARS的一般使用可以通过REGAL网页快速学习http://regionalanalysislab.org/?n=STARS再次不做详细介绍这里关注的主题是对STARS源代码分析即为使用Pytho ...

  7. cf459A Pashmak and Garden

    A. Pashmak and Garden time limit per test 1 second memory limit per test 256 megabytes input standar ...

  8. VS2012生成绿色版程序的方法

    方法就是在工程属性里设置: 配置属性-〉常规-〉项目默认值-〉MFC的使用-〉在静态库中使用MFC,见下图 之后重新编译即可.

  9. windows composer 安装,使用新手入门

    一.前期准备: 1.下载安装包,https://getcomposer.org/download/ 2.在php.ini文档中打开extension=php_openssl.dll 3.下载php_s ...

  10. 使用ScrapySharp快速从网页中采集数据

    ScrapySharp是一个帮助我们快速实现网页数据采集的库,它主要提供了如下两个功能 从Url获取Html数据 提供CSS选择器的方式解析Html节点 安装: ScrapySharp可以直接从Nug ...