]> granicus.if.org Git - sysstat/commitdiff
sa2: Wait for a random delay before running
authorSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 11 May 2020 08:04:17 +0000 (10:04 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 11 May 2020 08:07:35 +0000 (10:07 +0200)
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 <sysstat@users.noreply.github.com>
build/delay_range [new file with mode: 0644]
configure
configure.in
iconfig
man/sysstat.in
sa2.in
sysstat.sysconfig.in

diff --git a/build/delay_range b/build/delay_range
new file mode 100644 (file)
index 0000000..46af893
--- /dev/null
@@ -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.
index a8de46cd9c4896439cc651cabdc748976787d2d0..3c4556b5ed8d585952c31a444c4ea2e97d939a54 100755 (executable)
--- 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
index bbc3e83c40d7d57fedee4193499682fc2fce727f..38d387533eb5ab08090e2f2afefc35d9c4fb3e75 100644 (file)
@@ -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 7fae24e3f799557a410304940c05ddcea9c63b2c..82b49c27854d0b2d8e49485d727dcaefe95fda3e 100755 (executable)
--- 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}
index 6ef3b7d0d47b38bbb4484db28aba3525057fd87c..77288f6425db11a359667e0b2112ed544c956d8e 100644 (file)
@@ -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 4e50c9734364777b9489e41263e059b2832e49ef..14eeab5d21ef7ecca2cacb58236639c9a46f3fe2 100644 (file)
--- 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
index 69e4d17420763cb87300bfec94578e479794f82d..aec76569fd9f3d04fe7bba87d329fb8cbb5e1534 100644 (file)
@@ -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