From: Sebastien GODARD Date: Wed, 11 Nov 2020 15:33:32 +0000 (+0100) Subject: sa1: Add --rotate option X-Git-Tag: v12.5.1~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3ff4079d4cc92f7fc6f7921319d34f3017e6a26;p=sysstat sa1: Add --rotate option This option tells sa1 to add a statistics record to the system activity daily data file of the previous day. This should be done shortly after midnight in order to make sure that the data file covers the whole day, including the last interval of time just before midnight. Signed-off-by: Sebastien GODARD --- diff --git a/sa1.in b/sa1.in index 4466dae..3ae2e3b 100644 --- a/sa1.in +++ b/sa1.in @@ -14,6 +14,7 @@ SA_DIR=@SA_DIR@ SYSCONFIG_DIR=@SYSCONFIG_DIR@ SYSCONFIG_FILE=@SYSCONFIG_FILE@ UMASK=0022 +LONG_NAME=n [ -r ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} ] && . ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} @@ -27,12 +28,27 @@ umask ${UMASK} if [ ${HISTORY} -gt 28 ] then SADC_OPTIONS="${SADC_OPTIONS} -D" + LONG_NAME=y fi ENDIR=@SA_LIB_DIR@ cd ${ENDIR} [ "$1" = "--boot" ] && shift && BOOT=y || BOOT=n [ "$1" = "--sleep" ] && shift && SLEEP=y || SLEEP=n + +ROTATE=n +[ "$1" = "--rotate" ] && shift && ROTATE=y && [ "$1" = "iso" ] && shift && LONG_NAME=y +if [ "${ROTATE}" = "y" ] +then + if [ "${LONG_NAME}" = "y" ] + then + DATE=`date --date=yesterday +%Y%m%d` + else + DATE=`date --date=yesterday +%d` + fi + SA_DIR=${SA_DIR}/sa${DATE} +fi + if [ "${SLEEP}" = "y" ] then exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} -C "LINUX SLEEP MODE ($*)" ${SA_DIR} @@ -40,7 +56,7 @@ elif [ $# = 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... +# outfile has not been explicitly specified on the command line... exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} 1 1 ${SA_DIR} else exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} $* ${SA_DIR}