These are pretty much questions from a newbie. (I have looked at the other related questions and answers, but none seemed to be exactly answering my own original questions.)
I need to remotely retrieve, parse, and report in a Java program the CPU and memory usage of a Linux machine. These should be done in two separate commands instead of one to decouple them to make it easier if one command needs to be changed in the future.
So my questions are:
- What is the best command to use to retrieve the total CPU usage of a machine for this purpose?
- What is the best command to use to retrieve the total memory usage of a machine for this purpose?
By best, I mean the output of the commands are:
- Standard (independent/should be the same across the Linux flavours -- not mandatory, but would be good. target OS though is RHEL 5)
- Can easily be parsed (not cluttered with other information I am not interested in).