Using standard linux (Ubuntu) commands, how do I get the printout of the current cpu usage. I will be capturing that text, so the program cannot loop/refresh. So, 'top' is not an option. 'mpstat' would be good, but it only shows avg since reboot.
I would think that "mpstat" does exactly what you want. Just run something like "mpstat 1 > cpu-usage.log" and it'll capture the CPU usage every second to a file.
I finally got a chance to try this out. Unfortunately it doesn't work as expected. It also gives me the same % as mpstat, which isn't the current cpu usage but average for entire uptime, unless refreshing.
I decided to use this: 'top -b -n 2'
The 2nd iteration is the one with the current cpu usage.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.