• 状态监测 tcp_status加入到zabbix


    1、编写监控脚本,上传客户端服务器/etc/zabbix/scripts/tcp_conn_status.sh ,注意脚本需要+x权限。
    2、在客户端上的conf 文件中加配置段
    vim /etc/zabbix/zabbix_agentd.d/userparameter_tcp_conn.conf
    UserParameter=tcp.status[*],/etc/zabbix/scripts/tcp_conn_status.sh $1
    3、客户端重启zabbix-agent.service
    4、服务器端 测试zabbix_get -s 客户端ip -k tcp.status[established] 检查是否能连通
    5、创建模板,名字为template tcp connetction status 隶属于templates 群组
    6、创建当前模板下的监控项目 ,[closed listen synrecv synsent established timewait closing closewait lastack finwait1 finwait2] 键值tcp.status[listen] 定义应用集
    7、设计模板图形 名称TCP STATUS ,然后添加入监控项 (上面11条)
    8、主机 链接此模板。

    图形乱码文件,找到zabbix 站点程序目录include/defines.inc.php 查看下realpath 字体文件目录,使用windows 的字体去替换这个目录内的文件。

    #!/bin/bash
    #状态[closed listen synrecv synsent established timewait closing closewait lastack finwait1 finwait2]
    #set -x
    me=$1
    tmpfile=/tmp/tcp_status.txt
    
    /bin/netstat -an|awk '/^tcp/{++a[$NF]}END{for(i in a) print i,a[i]}' >$tmpfile
    ######closed#####
    case $me in
        closed)
        status=$(awk '/CLOSED/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    
    #####listen#####
        listen)
        status=$(awk '/LISTEN/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
            
    #####synrecv#####
        synrecv)
        status=$(awk '/SYNRECE/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    
    #####synsent#####
        synsent)
        status=$(awk '/SYNSENT/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    
    
    #####established#####
        established)
        status=$(awk '/ESTABLISHED/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    #####timewait#####
        timewait)
        status=$(awk '/TIME_WAIT/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    #####closing#####
        closing)
        status=$(awk '/CLOSING/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    #####closewait####
        closewait)
        status=$(awk '/CLOSEWAIT/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    #####lastack#####
        lastack)
        status=$(awk '/LASTACK/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    #####finwait1####
        finwait1)
        status=$(awk '/FINWAIT1/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
    #####finwait2####
        finwait2)
        status=$(awk '/FINWAIT2/{print $2}' $tmpfile)
        if [ "$status" == "" ];then
            echo 0
        else
            echo $status
        fi
        ;;
    
        *)
        echo "ex:closed|listen|synrecv|synsent|established|timewait|closing|closewait|lastack|finwait1|finwait2 "
    
    esac
  • 相关阅读:
    wu
    Win10编译cuda版OpenCV
    Windows编译OpenCV可能下载失败的文件
    20220419Servlet和HTTP请求协议
    20220418Tomcat
    比 Navicat 还要好用、功能更强大的工具!
    Java 8的18个常用日期处理
    Oracle 执行存储过程五种方法(带参数& 不带参数)
    帆软设置浏览内容宽度为屏幕宽度
    帆软参数为空查询全部
  • 原文地址:https://www.cnblogs.com/plefan/p/13679958.html
Copyright © 2020-2023  润新知