LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-26-2020, 06:31 PM   #1
jeffchung
LQ Newbie
 
Registered: Nov 2018
Posts: 14

Rep: Reputation: Disabled
How to Modify "Storage cycle of sa"


Hi

I want to reduce the file "sa" (/var/log/sa00). I don't use sar file so I remarked sa2 line in sysstat.

```code
# Run system activity accounting tool every 5 seconds
* * * * * root /usr/lib64/sa/sa1 5 12
# 0 * * * * root /usr/lib64/sa/sa1 5 12
# Generate a daily summary of process accounting at 23:53
#53 23 * * * root /usr/lib64/sa/sa2 -A
```

But 28 of them (sa00) file still is created. I want to reduce the cycle like 28 -> 7.

I tried to modified this file.
In the line below, I have modified the History value (28 -> 7). But it is not reflected.


```code
# vi /usr/lib64/sa/sa1
# Used only if ${SYSCONFIG_DIR}/sysstat doesn't exist!
#!/bin/sh
# /usr/lib64/sa/sa1
# (C) 1999-2012 Sebastien Godard (sysstat <at> orange.fr)
#
#@(#) sysstat-10.1.5
#@(#) sa1: Collect and store binary data in system activity data file.
#

# Set default value for some variables.
# Used only if ${SYSCONFIG_DIR}/sysstat doesn't exist!
HISTORY=7

SADC_OPTIONS=""
DDIR=/var/log/sa
DATE=`date +%d`
CURRENTFILE=sa${DATE}
CURRENTDIR=`date +%Y%m`
SYSCONFIG_DIR=/etc/sysconfig
umask 0022
[ -r ${SYSCONFIG_DIR}/sysstat ] && . ${SYSCONFIG_DIR}/sysstat
if [ ${HISTORY} -gt 28 ]
then
cd ${DDIR} || exit 1
[ -d ${CURRENTDIR} ] || mkdir -p ${CURRENTDIR}
# If ${CURRENTFILE} exists and is a regular file, then make sure
# the file was modified this day (and not e.g. month ago)
# and move it to ${CURRENTDIR}
[ ! -L ${CURRENTFILE} ] &&
[ -f ${CURRENTFILE} ] &&
[ "`date +%Y%m%d -r ${CURRENTFILE}`" = "${CURRENTDIR}${DATE}" ] &&
mv -f ${CURRENTFILE} ${CURRENTDIR}/${CURRENTFILE}
touch ${CURRENTDIR}/${CURRENTFILE}
# Remove the "compatibility" link and recreate it to point to
# the (new) current file
rm -f ${CURRENTFILE}
ln -s ${CURRENTDIR}/${CURRENTFILE} ${CURRENTFILE}
else
# If ${CURRENTFILE} exists, is a regular file and is from a previous
# month then delete it so that it is recreated by sadc afresh
[ -f ${CURRENTFILE} ] && [ "`date +%Y%m -r ${CURRENTFILE}`" -lt "${CURRENTDIR}" ] && rm -f ${CURRENTFILE}
fi
ENDIR=/usr/lib64/sa
cd ${ENDIR}
[ "$1" = "--boot" ] && shift && BOOT=y || BOOT=n
if [ $# = 0 ] && [ "${BOOT}" = "n" ]
then
# Note: Stats are written at the end of previous file *and* at the
# beginning of the new one (when there is a file rotation) only if
# outfile has been specified as '-' on the command line...
exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} 1 1 -
else
exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} $* -
fi
```

Is there anyone how to I can change storage cycle of sa file?

Thanks.
 
Old 07-26-2020, 07:23 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
The configuration is done in /etc/sysconfig/sysstat (except if your distro does it differently). See also the sysstat manual page.

EDIT: Not sure if you can change the frequency of storing the data.

Last edited by berndbausch; 07-26-2020 at 07:28 PM.
 
Old 07-27-2020, 02:53 PM   #3
jeffchung
LQ Newbie
 
Registered: Nov 2018
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
The configuration is done in /etc/sysconfig/sysstat (except if your distro does it differently). See also the sysstat manual page.

EDIT: Not sure if you can change the frequency of storing the data.
------

Thanks for your answer.
I already modified sysstat file. but It still doesn't seem to work.
After I modified the file, Do I have to restart some service file?!

```code
# cat /etc/sysconfig/sysstat
# sysstat-10.1.5 configuration file.

# How long to keep log files (in days).
# If value is greater than 28, then log files are kept in
# multiple directories, one for each month.
HISTORY=7

# Compress (using gzip or bzip2) sa and sar files older than (in days):
COMPRESSAFTER=31

# Parameters for the system activity data collector (see sadc manual page)
# which are used for the generation of log files.
SADC_OPTIONS="-S DISK"

# Compression program to use.
ZIP="bzip2"
```
 
Old 07-27-2020, 06:26 PM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
I would add echo commands to the sa1 and sa2 scripts to see what's happening.
 
Old 08-09-2020, 09:19 AM   #5
jeffchung
LQ Newbie
 
Registered: Nov 2018
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
I would add echo commands to the sa1 and sa2 scripts to see what's happening.
thanks. I will try that.
 
  


Reply

Tags
linux, sa, sar



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How? Run portable apps like firefox on seperate drive [Storage Drive] "USB" "HDD" "SSD" ? abc123xyz Slackware 5 03-25-2019 07:55 AM
"Well, udev in this devel cycle has certainly been interesting! " onebuck Slackware 2 08-05-2012 10:03 AM
Help With Java Problem Please"""""""""""" suemcholan Linux - Newbie 1 04-02-2008 06:02 PM
How to modify the library path variable?modify the Electronkz Linux - Newbie 1 04-13-2004 06:18 AM
modify file access & modify timestamps i2itstud Linux - General 1 05-20-2003 03:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration