I am logging on to a node which I know has near 100% cpu usage (20 single process jobs using nearly 100% cpu each). When I use
top interactively, the first iteration, it gives me about 20%
ni and the next iteration and all after it correctly gives 95+%
ni usage. I am wanting to pipe the output of
top -bn1 > outfile, but the first iteration of
top -bn1 (the only iteration) gives the incorrect CPU usage. If I use
top -bn2, then the second iteration gives the correct usage, but that is too much output.
How can I get
top -bn1 to correctly give me the CPU usage? I am writing this script for usage statistics, so if necessary, I can go back and run an analysis on the processes independently to generate my own CPU usage, but it would be nice if
top would give me the correct usage right off the bat.
mpdstat -P ALL gives me the same, incorrect, initial usage statistics. It would be nice to get that figured out as well too. I can use
mpstat -P ALL 1 1, but this gives the output twice.