zoukankan      html  css  js  c++  java
  • (十)zabbix监控TCP状态

    1)agent端配置

    • agent端脚本获取监控项
    #vim /etc/zabbix/zabbix_agentd.d/tcp_status.sh
    #bin/bash 
    [ $# -ne 1 ] && echo "Usage:CLOSE-WAIT|CLOSED|CLOSING|ESTAB|FIN-WAIT-1|FIN-WAIT-2|LAST-ACK|LISTEN|SYN-RECV SYN-SENT|TIME-WAIT" && exit 1
    tcp_status_fun(){
        TCP_STAT=$1
        ss -ant | awk 'NR>1 {++s[$1]} END {for(k in s) print k,s[k]}' > /tmp/ss.txt
        TCP_STAT_VALUE=$(grep "$TCP_STAT" /tmp/ss.txt | cut -d ' ' -f2)
        if [ -z "$TCP_STAT_VALUE" ];then
            TCP_STAT_VALUE=0
        fi
        echo $TCP_STAT_VALUE
    }
    tcp_status_fun $1;
    •   修改脚本权限
    #chmod +x /etc/zabbix/zabbix_agentd.d/tcp_status.sh
    • 修改agent配置文件
    #vim /etc/zabbix/zabbix_agentd.d/tcp_status.conf
    UserParameter=tcp_status[*],/bin/bash /etc/zabbix/zabbix_agentd.d/tcp_status.sh "$1"
    • agentd重启服务
    systemctl restart zabbix-agent

    注意:/tmp/ss.txt文件的属主是zabbix

    (2)server端配置

    思路:定义tcp_status模板--->定义应用集nginx_status--->定义监控项---->定义图形--->定义触发器---->添加主机或主机关联这个模板

    • zabbix-server端zabbix_get测试获取
    # zabbix_get -s 192.168.1.32 -p10050 -k tcp_status[ESTAB]
    2
    • 键值
    tcp_status[ESTAB]
    tcp_status[CLOSE-WAIT]
    tcp_status[CLOSED]
    tcp_status[CLOSING]
    tcp_status[FIN-WAIT-1]
    tcp_status[FIN-WAIT-2]
    tcp_status[LAST-ACK]
    tcp_status[LISTEN]
    tcp_status[SYN-RECV]
    tcp_status[SYN-SENT]
    tcp_status[TIME-WAIT]
    • 定义监控项:只写一个,其它的就是键值不同
    • 定义图形
    • 验证
  • 相关阅读:
    xcode 快捷键大全、XCode常用快捷键图文介绍
    在ASP.NET Core 2.0 web项目中使用EntityFrameworkCore
    AspNetCore2身份验证
    @addTagHelper的使用
    Asp.net Mvc身份验证
    webAPi OData的使用
    Chrome及Chrome内核浏览器改变开发者工具字体大小
    银行卡号校验
    django静态文件
    django 简单路由配置
  • 原文地址:https://www.cnblogs.com/shaonli/p/12089877.html
Copyright © 2011-2022 走看看