0

https://i.stack.imgur.com/aEhxo.png> I want to show the usage of disk space for last one hour on graph, for

that I am creating a API but I want SAR command to execute the listed output of disk usage ,I have found the command but it is showing the live details of disk usage I have included the image ,I want details of last one hour usage, please help or if you have any doubt ask me.image In this Image the usage which is showing is live usage

Cideinit
  • 3
  • 4

1 Answers1

0

Create a new directory i.e. /var/log/sardiskusage

Then create a crontab entry:

0 * * * *    /usr/bin/sar -F 1 3600 > "/var/log/sardiskusage/$(/usr/bin/date +%s).log" 

This will run sar -F every second for 3600 seconds (one hour), outputting the output to a new file in /var/log/sardiskusage that gets created by the cronjob entry every hour. You can then reference the file required based on timestamp.

Raman Sailopal
  • 12,320
  • 2
  • 11
  • 18