zoukankan      html  css  js  c++  java
  • 状态监测 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
  • 相关阅读:
    通过Navicat导入SQLServer的MDF文件和LDF文件
    ubantu系统出现登录界面死循环处理办法
    ubantu系统修改权限失败,导致只能客人会话登录解决办法
    redis基础
    ubantu安装MySQL,并未出现设置root密码的提示--》少年,请不要乱改密码!
    ngx_http_access_module模块说明
    一些常用的ngx_http_core_module介绍
    八、location匹配规则
    七、nginx的虚拟主机配置
    六、nginx的配置文件说明
  • 原文地址:https://www.cnblogs.com/plefan/p/13679958.html
Copyright © 2011-2022 走看看