Cideinit
Cideinit

Reputation: 3

Using SAR command to monitor free disk space data

https://i.sstatic.net/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

Upvotes: 0

Views: 1324

Answers (2)

Z McCrocklin
Z McCrocklin

Reputation: 71

2 years later, but sar has an option for historical data that gets stored in /var/log/sysstat.

There is also a -s flag that allows you to set a start time in hh:mm:ss format.

https://www.thegeekstuff.com/2011/03/sar-examples/

Upvotes: 1

Raman Sailopal
Raman Sailopal

Reputation: 12877

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.

Upvotes: 0

Related Questions