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 @ 2021-12-28 19:14  张同光  阅读(65)  评论(0编辑  收藏  举报