From: Sebastien GODARD Date: Mon, 11 May 2020 08:04:17 +0000 (+0200) Subject: sa2: Wait for a random delay before running X-Git-Tag: v12.4.0~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8294da83b698a8b41b198218e2f0bca865517f90;p=sysstat sa2: Wait for a random delay before running Add a new option ("delay_range=") to configure script to tell sa2 script to wait for a random delay in the indicated range before running. This delay (expressed in seconds) is aimed at preventing a massive I/O burst at the same time on VM sharing the same storage area. Signed-off-by: Sebastien GODARD --- diff --git a/build/delay_range b/build/delay_range new file mode 100644 index 0000000..46af893 --- /dev/null +++ b/build/delay_range @@ -0,0 +1,4 @@ +Tell sa2 script to wait for a random delay in the indicated range before +running. This delay is expressed in seconds, and is aimed at preventing +a massive I/O burst at the same time on VM sharing the same storage area. +Default value is 0, meaning that sa2 will generate reports files immediately. diff --git a/configure b/configure index a8de46c..3c4556b 100755 --- a/configure +++ b/configure @@ -645,6 +645,8 @@ COMPRESS_MANPG IGNORE_FILE_ATTRIBUTES MAN_GROUP man_group +DELAY_RANGE +delay_range COMPRESSAFTER compressafter HISTORY @@ -777,6 +779,7 @@ conf_dir conf_file history compressafter +delay_range man_group cron_owner cron_interval @@ -1430,6 +1433,8 @@ Some influential environment variables: compressafter number of days after which data files are compressed (default value is 10) + delay_range maximum delay (in seconds) to wait before sa2 script generates + its reports man_group group for manual pages cron_owner crontab owner cron_interval @@ -5249,6 +5254,7 @@ echo . # conf_dir sysstat configuration directory (default is /etc/sysconfig) # conf_file sysstat configuration file (default is sysstat) # history number of daily datafiles to keep (default value is 7) +# delay_range maximum delay (in seconds) to wait before sa2 script generates its reports # compressafter number of days after which datafiles are compressed # man_group group for man pages # cron_owner crontab owner @@ -5528,6 +5534,19 @@ fi $as_echo "$COMPRESSAFTER" >&6; } +# Random delay to wait before sa2 script runs +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking random delay to wait before sa2 script runs" >&5 +$as_echo_n "checking random delay to wait before sa2 script runs... " >&6; } + +if test x$delay_range = x""; then + DELAY_RANGE=0 +else + DELAY_RANGE=$delay_range +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DELAY_RANGE" >&5 +$as_echo "$DELAY_RANGE" >&6; } + + # Manual page group grep ^man: /etc/group >/dev/null 2>&1 if test $? = 0; then diff --git a/configure.in b/configure.in index bbc3e83..38d3875 100644 --- a/configure.in +++ b/configure.in @@ -214,6 +214,7 @@ echo . # conf_dir sysstat configuration directory (default is /etc/sysconfig) # conf_file sysstat configuration file (default is sysstat) # history number of daily datafiles to keep (default value is 7) +# delay_range maximum delay (in seconds) to wait before sa2 script generates its reports # compressafter number of days after which datafiles are compressed # man_group group for man pages # cron_owner crontab owner @@ -433,6 +434,17 @@ fi AC_MSG_RESULT($COMPRESSAFTER) AC_SUBST(COMPRESSAFTER) +# Random delay to wait before sa2 script runs +AC_MSG_CHECKING(random delay to wait before sa2 script runs) +AC_ARG_VAR([delay_range],[maximum delay (in seconds) to wait before sa2 script generates its reports]) +if test x$delay_range = x""; then + DELAY_RANGE=0 +else + DELAY_RANGE=$delay_range +fi +AC_MSG_RESULT($DELAY_RANGE) +AC_SUBST(DELAY_RANGE) + # Manual page group grep ^man: /etc/group >/dev/null 2>&1 if test $? = 0; then diff --git a/iconfig b/iconfig index 7fae24e..82b49c2 100755 --- a/iconfig +++ b/iconfig @@ -88,6 +88,12 @@ if [ "${HISTORY}" != "" ]; then HISTORY="history=${HISTORY} " fi +# Random delay before sa2 script generates its reports files +DELAY_RANGE=`${ASK} 'Maximum delay in seconds to wait before sa2 script runs:' "delay_range" "delay_range"` +if [ "${DELAY_RANGE}" != "" ]; then + DELAY_RANGE="delay_range=${DELAY_RANGE} " +fi + # Delay after which datafiles are to be compressed COMPRESSAFTER=`${ASK} 'Number of days after which sar datafiles must be compressed:' "compressafter" "compressafter"` if [ "${COMPRESSAFTER}" != "" ]; then @@ -222,7 +228,8 @@ fi echo echo -n "./configure ${PREFIX}${SA_LIB_DIR}${SA_DIR}${SYSCONFIG_DIR}${SYSCONFIG_FILE} \ -${CLEAN_SA_DIR}${NLS}${HISTORY}${COMPRESSAFTER}${MAN}${IGNORE_FILE_ATTR}${CRON}${USE_CROND}${RCDIR}" +${CLEAN_SA_DIR}${NLS}${HISTORY}${DELAY_RANGE}${COMPRESSAFTER}${MAN}${IGNORE_FILE_ATTR} \ +${CRON}${USE_CROND}${RCDIR}" if [ "${SADC_OPT}" != "" ]; then echo -n "sadc_options=\"${SADC_OPT}\"" @@ -232,6 +239,6 @@ echo ./configure ${PREFIX}${SA_LIB_DIR}${SA_DIR}${SYSCONFIG_DIR}${SYSCONFIG_FILE} \ ${CLEAN_SA_DIR}${NLS} \ -${HISTORY}${COMPRESSAFTER}${MAN}${IGNORE_FILE_ATTR}${CRON}${USE_CROND}${RCDIR} \ +${HISTORY}${DELAY_RANGE}${COMPRESSAFTER}${MAN}${IGNORE_FILE_ATTR}${CRON}${USE_CROND}${RCDIR} \ sadc_options="${SADC_OPT}" ${COMPRESSMANPG}${INSTALL_DOC}${DEBUGINFO}${SENSORS} \ ${PCP}${STRIP}${COPY_ONLY} diff --git a/man/sysstat.in b/man/sysstat.in index 6ef3b7d..77288f6 100644 --- a/man/sysstat.in +++ b/man/sysstat.in @@ -1,4 +1,4 @@ -.TH SYSSTAT 5 "JULY 2018" Linux "Linux User's Manual" -*- nroff -*- +.TH SYSSTAT 5 "MAY 2020" Linux "Linux User's Manual" -*- nroff -*- .SH NAME sysstat \- sysstat configuration file. .SH DESCRIPTION @@ -17,6 +17,13 @@ The compression program is given in the .B ZIP variable. +.TP +.B DELAY_RANGE +Tell sa2 script to wait for a random delay in the indicated range before running. +This delay is expressed in seconds, and is aimed at preventing a massive I/O burst +at the same time on VM sharing the same storage area. +A value of 0 means that sa2 script will generate its reports files immediately. + .TP .B HISTORY The number of days during which a daily data file or a report diff --git a/sa2.in b/sa2.in index 4e50c97..14eeab5 100644 --- a/sa2.in +++ b/sa2.in @@ -16,12 +16,21 @@ COMPRESSAFTER=@COMPRESSAFTER@ ZIP="@ZIP@" UMASK=0022 ENDIR=@SAR_DIR@ +DELAY_RANGE=@DELAY_RANGE@ # Read configuration file, overriding variables set above [ -r ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} ] && . ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} umask ${UMASK} +# Wait for a random delay if requested +if [ ${DELAY_RANGE} -gt 0 ] +then + RANDOM=$$ + DELAY=$((${RANDOM}%${DELAY_RANGE})) + sleep ${DELAY} +fi + [ -d ${SA_DIR} ] || SA_DIR=@SA_DIR@ # if YESTERDAY=no then today's summary is generated diff --git a/sysstat.sysconfig.in b/sysstat.sysconfig.in index 69e4d17..aec7656 100644 --- a/sysstat.sysconfig.in +++ b/sysstat.sysconfig.in @@ -27,6 +27,12 @@ ZIP="@ZIP@" # Set this variable to false to disable reports generation. #REPORTS=false +# Tell sa2 to wait for a random delay in the range 0 .. ${DELAY_RANGE} before +# executing. This delay is expressed in seconds, and is aimed at preventing +# a massive I/O burst at the same time on VM sharing the same storage area. +# Set this variable to 0 to make sa2 generate reports files immediately. +DELAY_RANGE=@DELAY_RANGE@ + # The sa1 and sa2 scripts generate system activity data and report files in # the @SA_DIR@ directory. By default the files are created with umask 0022 # and are therefore readable for all users. Change this variable to restrict