3

I am trying to figure a way to get the CPU utilization for the past 2 months. I have tried to use sar. What I found with sar is that you can collect and report CPU utilization with it and it is installed through the sysstat utility. Once installed the /usr/lib64/sa/sa1 directory stores "historical" references in the /var/log/sa/sadd directory where dd = day in the month. You setup specified parameters in the cron.d/sysstat file. Which for me looks like this:

# run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib64/sa/sa2 -A

Then /usr/lib64/sa/sa2 creates a daily report in the /var/log/sa/sadd directory. Which for me sa2 looks like this:

#!/bin/sh
# /usr/lib64/sa/sa2.sh
# (C) 1999-2006 Sebastien Godard (sysstat <at> wanadoo.fr)
#
# Changes:
# - 2004-01-22 Nils Philippsen <[email protected]>
#   make history configurable
#
HISTORY=7
[ -r /etc/sysconfig/sysstat ] && . /etc/sysconfig/sysstat
[ ${HISTORY} -gt 25 ] && HISTORY=25
S_TIME_FORMAT=ISO ; export S_TIME_FORMAT
umask 0022
DATE=`date  +%d`
RPT=/var/log/sa/sar${DATE}
ENDIR=/usr/bin
DFILE=/var/log/sa/sa${DATE}
[ -f "$DFILE" ] || exit 0
cd ${ENDIR}
${ENDIR}/sar $* -f ${DFILE} > ${RPT}
find /var/log/sa \( -name 'sar??' -o -name 'sa??' \) -mtime +"${HISTORY}" -exec rm -f {} \;

This is only set to have the history of 7 days. I guess my question is: Is there a way to get the CPU stats for the past 2 months using sar or is there a better way? It seems to me I may only have access to the past 7 days of stats.

1
  • I don't know about SAR, but a tool like munin can definitely keep stats for several months. Sep 19, 2012 at 14:38

1 Answer 1

0

if you change to HISTORY=60, then it should keep 2 months worth, approximately.

3
  • Thanks for the response. That will be implemented. But is there a way to get the past 2 months without having this implemented before hand or are we SOL at this point? Sep 19, 2012 at 16:30
  • I guess not, at least for sar, as the files were cleaned up by the script, unless you have other external programs that generated and kept stats. If your server is in a datacenter, your provider might have some standard monitoring to capture that. cpu utilization is one of the most basic things to monitor so if there is any monitoring, it should be there.
    – johnshen64
    Sep 19, 2012 at 17:57
  • Luckily you were right johnshen64. Just found out that we use TeamQuest. Nice little reporting tool. Thanks for all comments! Sep 19, 2012 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .