I am developing a video streaming app in node.js. As it might consume a lot of network bandwidth, I want to find out how can I in node.js track the bandwidth usage of the application as well as a whole the system itself?
Example of desired output:
This App: 100 kb Rx 18 mb Tx
Total: 200 kb Rx 20 mb Tx
Embrace yourself, as it is not going to be any easy.
Only nodejs module which supposedly tracks network traffic I found is network-debugger. I have little faith you will find an answer to your question in that project though.
Network monitoring is usually highly OS specific:
Yes, you are right, it is not a nodejs library, but as you guessed there is not one. Partially this might be because sys admins always preferred console based one-thing tools to monitor their servers, as a result there is a very little demand to implement network monitoring library in node.
To achieve the desired:
There is an interesting article in great detail on how to code a system monitor in node.js using existing console based tools, might be of a great help. you might have to choose one of those console based tools, learn how to launch it in pipe-friendly mode (so that the output can be piped to a file or a stream right into your node.js server)
Alternatively, you could reinvent the wheel and make your own network monitoring tool in node.js, but I fear it will end up being half JavaScript, half OS specific code in C or Objective-C.
Also note that you need adminsitrative rights (sudo or admin user on windows) to monitor the network. Meaning you might have to run node.js with elevated rights. That is an extra risk to keep in mind.