NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
tyit
V2EX  ›  NGINX

nginx、iptables 端口流量统计

  •  
  •   tyit · Jun 2, 2024 via iPhone · 3107 views
    This topic created in 714 days ago, the information mentioned may be changed or developed.
    一台 ec2 跑了一个 nginx 监听了几个端口、一个 iptables 端口转发,偶尔会有流量突发的情况几分钟、想统计 nginx 各个端口的流量、以及 iptables 端口转发的流量。方便好定位、请教这个有啥好办法实现?
    8 replies    2024-06-03 08:36:59 +08:00
    wheat0r
        1
    wheat0r  
       Jun 2, 2024
    tcpdump
    tool2dx
        2
    tool2dx  
       Jun 2, 2024
    /t/1039264

    光统计流量可以用 iptables 自定义的 chain ,但是如果你想定位问题,推荐 pcap ,如果你会写程序过滤 tcp/ip 包,还是挺容易的。
    ETiV
        3
    ETiV  
       Jun 2, 2024 via iPhone   ❤️ 1
    采集端口上的流量,telegraf 有这个功能,需要配合 iptables 给端口写一段 comment 注释(和一些权限配置)

    https://github.com/influxdata/telegraf/tree/master/plugins/inputs/iptables
    tyit
        4
    tyit  
    OP
       Jun 2, 2024
    ec2 是 aws 的、外网的流量不好监控,每次流量突发到 800M 、ec2 在 aws 上面配置了规则会自动重启,这时候在去排查是哪个端口的流量查不到定位不了问题,所以想着统计下方便好定位是哪里过来的流量导致的。
    tyit
        5
    tyit  
    OP
       Jun 2, 2024
    @ETiV 谢谢,我看了一下,这个也能实现,具体我还是在看看
    tyit
        6
    tyit  
    OP
       Jun 2, 2024
    @tool2dx 惭愧、我乃小小菜鸡,想写也写不出来
    ETiV
        7
    ETiV  
       Jun 2, 2024 via iPhone
    菜就多练啊 错了就改呗 三番五次总能改好
    Lax
        8
    Lax  
       Jun 3, 2024
    nginx 配置的什么规则?日志里统计一下也能看出来吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1568 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 16:24 · PVG 00:24 · LAX 09:24 · JFK 12:24
    ♥ Do have faith in what you're doing.