Is there any way to get my server’s load and memory usage history from commandline?
Yes, it’s possible by using the command-line utility SAR. System Activity Reporter is abbreviated as SAR.
It is an important tool to monitor server’s different important metrics at different points of time. Using SAR it will be possible to monitor the performance of various Linux subsystems (CPU, Memory, I/O..) in real time.
If you had a problem with your server performance, you can check the resource usage history by using SAR utility, so you will get clear idea about resources usage history.
sysstat - daemon
Top command usages and examples in Unix/Linux
Top command has an important role in Unix/Linux system/server administration side. The command “top” displays a dynamic view of process that are currently running under the system. Read more..
SAR for load monitoring purpose
The above command will report load averages at different times. (It fetch data from /var/log/sa(sysstat)/sa*, where sa* represent the date like sa10,sa11,sa12etc). If you want to fetch details of previous dates, you need to use the switch -f along with -q, and that details are added in the last section of this article.
>> sar -q
It simply lists current day’s load averages starting from 12:00:00, with 10 minute interval and this is the commonly using switch because we mostly check Load history.
>> sar -q 1 5
It lists load averages 5 times from when we enter this with an interval of 1 sec.
>> sar -q -f /var/log/sa/sa23
Previous dates details are stored in the directory “/var/log/sa/”. The switch “f” along with the command SAR can fetch previous days details, so you can check previous dates details from this saved file.
SAR for memory monitoring purpose
Report memory details.
>> sar -r
It simply lists current day’s memory usage averages starting from 12:00:00, with 10 minute interval and it lists all about systems memory usages.
>> sar -r 1 5
It lists memory usage averages 5 times from when we enter this with an interval of 1 sec, and it’s useful for realtime tracking.
>> sar -r -f /var/log/sa/sa23
Fetch data from /var/log/sa/sa23.