Skip to main content
1 of 2
Marco
  • 458
  • 1
  • 3
  • 14

I think that you're looking for sar. SAR stands for System Activty Report. It's used in unix-like operating systems to report about CPU, memory and IO usage, collected by sysstat.

Then, sysatat can be configured to Monitor individual processes. Link

How often it collects, and how long sar keeps reports is decided on the first setup.

You just want to note that such a data collection is not "free" so I won't keep it on on production servers.

After it is configured it will be easy for you to extract datas from reports in your script by using the sar command, grep and awk.

You didn't specified what OS are you working on, so I encourage you to search how to set up sar/sysstat on your distro.

Marco
  • 458
  • 1
  • 3
  • 14