Can I monitor Linux socket buffer fullness? is it sufficiently "real-time"?

https://stackoverflow.com/questions/12048116/can-i-monitor-linux-socket-buffer-fullness

 

I work in support for a tech company. I'm trying to troubleshoot an instance of one of our applications out in the field, and need to monitor TCP socket buffer fullness.

I know that if I had access to the source code, I could use ioctl and SIOCOUTQ to query the socket buffer's fullness at any point in time.

But I don't.

So my question is, is there a way to view the fullness of a socket buffer from outside the application?

Google led me to /proc/net/tcp, but I'm not 100% sure that the tx_queue column is what I'm looking for. Is it?

If so, is it sufficiently "real-time" that I can write a perl script to constantly poll it to get a view of socket buffer utilization?

 

 

 

Answer

 

Proc is as good as real time yes, when you get contents of a file under /proc it's actually building the output in the kernel rather than reading from a file or anything like that

As Jon said won't be able to read the buffer contents however if you just want to know whether you're approaching your queue limit then tx_queue is the right place to look. (or maybe rx_queue of course depending where the latency is occuring)

Now I have no idea what app you're looking at, or what it does, however there's some interesting reading under the title of bufferbloat about how it might actually be better to reduce your queuelength and let tcp handle the rate changes more responsively which might be a better solution rather than monitoring the queue (and restarting the app or?)

 

posted @   张同光  阅读(70)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
历史上的今天:
2020-12-28 05---二叉树---20195106023---王亚威.c
2020-12-28 05---二叉树---20195106043---方传祥.c
2020-12-28 05---二叉树---20195106006---陈辉.c
2020-12-28 05---二叉树---20195106064---陈昕.c
2020-12-28 05---二叉树---20195106100---李遂勋.c
点击右上角即可分享
微信分享提示