Recently I was talking to a friend who works in the distributed computing space. He is doing research on how messages travel between geographically distributed servers, and his experiments rely on those servers being active and healthy (if they’re not, the experiment may actually run but produce no usable results, wasting my friend’s valuable time!). So I wondered if I could write a little script in Go that could do a simple machine health status report.
My friend had a few requests;
- information about the operating system running on the virtual machine,
- details about the virtual memory (RAM) on that machine so that he knows how much has been used and how much is available,
- disk usage information
- CPU details (e.g. number of cores)
- Go version
While the reporting functionalities were useful to me (since I’m still learning about systems stuff), ideally,
doctor should be converted into a package that exposes a struct called something like
Status, which included all of the above details, as well as a method (e.g.
getMachineStatus) that returns a
Status struct with all the fields populated.
Here are some of the very helpful resources and readings I looked at during the experimentation: