I'm writing a cross-platform Go application that runs as a daemon. It basically listens for changes on the filesystem and copies/downloads changes to/from a server. The idea is that it should never slow down the machine, queueing tasks until the machine is idle.
To do this, I would like to monitor CPU, RAM, and network usage, but network usage (if possible). I am currently targeting Windows 7+, Mac OS 10+, and Linux 3+.
I'm primarily a Linux programmer, so I'm not familiar with Windows/BSD APIs, but I've already found some good information about BSD, so I think I can figure that out. I'm having trouble tracking down the Windows syscalls (I don't know of a way to get a Windows man page...). I've managed to find these resources (for Windows):
- http://msdn.microsoft.com/en-us/library/ms724400%28VS.85%29.aspx
- http://www.philosophicalgeek.com/2009/01/03/determine-cpu-usage-of-current-process-c-and-c/
- http://msdn.microsoft.com/en-us/library/windows/desktop/aa373083%28v=vs.85%29.aspx
- Is it possible to know the cpu utilization from a script
I would prefer to use a syscall instead of shelling out/wrapping a C++ API. Obviously, I would be interested in any other Go libraries that already do this.
Ultimately, I'm looking for something like this: http://nodejs.org/api/os.html
I'm pretty much looking for syscalls and examples of how to use them.
If I'm headed in the wrong direction, please let me know. I'm not married to the idea of polling the kernel for system information, but that seemed to me the most reliable way to get that information. I'd prefer to run the application as an underprivileged user.