监控原理

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的更多相关文章

  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. (16)Cocos2d-x 多分辨率适配完全解析

    Overview 从Cocos2d-x 2.0.4开始,Cocos2d-x提出了自己的多分辨率支持方案,废弃了之前的retina相关设置接口,提出了design resolution概念. 3.0中有 ...

  2. Android中解析XML格式数据的方法

    XML介绍:Extensible Markup Language,即可扩展标记语言 一.概述 Android中解析XML格式数据大致有三种方法: SAX DOM PULL 二.详解 2.1 SAX S ...

  3. 使用 shell 脚本对 Linux 系统和进程资源进行监控

    Shell 简介 Shell 语言对于接触 LINUX 的人来说都比较熟悉,它是系统的用户界面,提供了用户与内核进行交互操作的一种接口.它接收用户输入的命令并把它送入内核去执行.实际上 Shell 是 ...

  4. .net core 2.2 & Mongodb

    .net core 2.2 API项目中使用Mongodb 简单的CRUD封装 创建FoodPlan.Core 项目 创建IEntityBase.cs 接口约束 创建Single.cs 实体 IEnt ...

  5. 能否通过六面照片构建3D模型?比如人脸,全身的多角度照片,生成3D模型。?

    https://www.zhihu.com/question/36412840 9023 ​添加评论 ​分享 ​邀请回答​举报 ​ 收起 已关注写回答   9 个回答 默认排序​ 叛逆者 计算机图形学 ...

  6. HDU1087

    /*记忆化dfs+dp,因为每次最多走k步,所以上下左右的方向有所扩展, dp[i][j]存的是从dp[i][j]出发能吃的最大个数*/ #include<stdio.h> #includ ...

  7. Python笔记 #14# Pandas: Selection

    10 Minutes to pandas import pandas as pd import numpy as np import matplotlib.pyplot as plt dates = ...

  8. Python 3 并发编程多进程之进程池与回调函数

    Python 3 进程池与回调函数 一.进程池 在利用Python进行系统管理的时候,特别是同时操作多个文件目录,或者远程控制多台主机,并行操作可以节约大量的时间.多进程是实现并发的手段之一,需要注意 ...

  9. 微信小程序:页面配置 page.json

    微信小程序:页面配置 page.json 一.页面配置 page.json 如果整个小程序的风格是蓝色调,那么可以在 app.json 里边声明顶部颜色是蓝色即可. 实际情况可能不是这样,可能你小程序 ...

  10. 20145204《Java程序设计》第5周学习总结

    20145204<Java程序设计>第5周学习总结 教材学习内容总结 语法与继承构架 我们之前接触到的C通常都是将程序流程和错误处理混在一起,在编写程序的时候必须考虑可能出现的错误并提前做 ...