record CPU history
Is there a way to record CPU history, for example in a text file as data form. Like this:
time(s) CPU(%) 0.1 87 0.2 79 0.3 86 . . . . . . would it be possible? |
Hi,
The sar command can do this, to be more exact: A combination of sa1, sa2 and sar. sa1 and sa2 run from crontab, sar can show various system related information (cpu usage being just one). There are different ways to set up this automated reporting (which can be queried by sar) and/or daily summaries, which are human readable. I've set it up as follows (crontab entries): Code:
# ---------------------------------------------------------------------------- # The second line creates a 24 hour report, cron executes this at 23:59. For more details: man sar / man sa1 / man sa2 The info given is a bit more elaborate then you asked. Besides the percentage used by one (or more) CPU, it breaks it down and also shows who used the CPU. Output wil look like this: Code:
15:19:59 CPU %user %nice %system %iowait %idle Hope this helps. PS: You don't mention your distro, it could be that sar isn't installed by default. |
All times are GMT -5. The time now is 05:16 PM. |