To get this, /usr/bin/sar should be installed. It is a default package.
cpu logs should be there in /var/log/sa folder in centos or redhat
If there is no /var/log/sa folder in ubuntu so the logs are stored in /var/log/sysstat. There is daily file of stored log.
usrname@hostname:~/Desktop$ ls /var/log/sysstat
sa09 sa10 sa11 sa12 sa13 sa14 sa15 sar09 sar10 sar11 sar13 sar14
You can find last 30 days logs here.
Suppose To check the logs of 15th, run command
sar -f /var/log/sysstat/sa15
CPU %user %nice %system %iowait %steal %idle
11:45:01 AM IST all 15.59 1.82 3.71 2.11 0.00 76.77
11:55:02 AM IST all 14.55 0.00 3.59 3.55 0.00 78.31
12:05:01 PM IST all 14.24 0.00 3.30 0.71 0.00 81.75
12:15:01 PM IST all 14.06 0.00 3.31 0.58 0.00 82.06
12:25:02 PM IST all 14.02 0.00 3.39 0.88 0.00 81.71
12:35:01 PM IST all 15.12 0.00 3.32 0.79 0.00 80.77
12:45:01 PM IST all 13.96 0.00 3.36 1.09 0.00 81.59
12:55:02 PM IST all 12.23 0.06 3.13 2.70 0.00 81.87
01:05:01 PM IST all 2.12 0.00 1.00 0.56 0.00 96.32
01:15:01 PM IST all 10.70 0.00 3.49 2.65 0.00 83.16
01:25:01 PM IST all 13.24 0.03 3.99 2.80 0.00 79.94
01:35:01 PM IST all 11.66 0.04 3.39 3.13 0.00 81.78
You will get the cpu usage of complete day. Above is a part of the output.
If logs are not stored, active enabling the flag in file.
sudo nano /etc/default/sysstat
ENABLED="true"
Restart service
sudo systemctl restart sysstat.service