Netstat works fine except when I redirect output to a file in NFS.
netstat -c > /nfs/mount/file
netstat > /nfs/mount/file
netstat -c > /tmp/file
Symptoms: empty file, no error messages.
This is using bash on Ubuntu 10.10
Longer version: I'm working on a project that requires we gather iostat and netstat statistics from all the nodes on a small cluster (~32 nodes) during test execution. We've written scripts to spin up iostat and netstat instances with the appropriate flags on each node, with each process writing to a file in a directory stored on an NFS share (each file name incorporates the host name it was written from).
The iostat scripts are working fine but we're seeing an issue with the netstat script.
For some reason, if I start a netstat process with the -c flag, indicating continuous output every one second, and pipe that to a file in the NFS directory, an empty file is created and no output is ever written to it.
If I do the same thing on the server that is providing the NFS storage, writing to the same directory (with the exception that it's local storage in this case) then every thing works out just fine. Also, if I write to a local file system on the host having issues (like /tmp/foo.txt) then everything is also fine.
Also worth noting, if I just run 'netstat', without the -c flag, and pipe that to a file stored on NFS, that works also.
So, there seems to be something a little hinky with netstat's continuous output flag that interacts with NFS in a manner that differs from other tools continuous outputs (like iostat's "-t 10" flag).
All hosts in this setup are running ubuntu 10.10.