Skip to content

Commit

Permalink
Add "prealloc" variable to configure script
Browse files Browse the repository at this point in the history
sar (or sadc) allocates empty records in the data files it creates so
that it can save statistics for devices (disks, network interfaces,
etc.) that may be added to the system after the file was created.
The drawback is that data files take more space on disk than actually
strictly necessary.
Using the "prealloc" variable with configure (before compiling sysstat),
the user can tell how much space he wants to allocate.
This variable will determine the size of data files created by sar/sadc.
The default value is 1, meaning that some empty records will be
allocated.
A value of 0 means that data files will be the smallest possible.
  • Loading branch information
Sebastien GODARD committed Sep 14, 2013
1 parent 2067d2f commit 436f85f
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sysstat
crontab
version.h
sysconfig.h
prealloc.h
sysstat.sysconfig
sysstat.service
sysstat.crond
Expand Down
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ xml_stats.o: xml_stats.c sa.h sadf.h ioconf.h sysconfig.h xml_stats.h

json_stats.o: json_stats.c sa.h sadf.h ioconf.h sysconfig.h json_stats.h

sa_wrap.o: sa_wrap.c sa.h rd_stats.h count.h rd_sensors.h
sa_wrap.o: sa_wrap.c sa.h rd_stats.h count.h rd_sensors.h prealloc.h

format.o: format.c sadf.h

Expand Down Expand Up @@ -506,7 +506,7 @@ clean:
find nls -name "*.gmo" -exec rm -f {} \;

almost-distclean: clean nls/sysstat.pot
rm -f sa1 sa2 sysstat cron/crontab version.h sysconfig.h
rm -f sa1 sa2 sysstat cron/crontab version.h sysconfig.h prealloc.h
rm -f sysstat.sysconfig cron/sysstat.crond cron/sysstat.cron.daily sysstat.service
rm -f cron/sysstat.cron.hourly cron/sysstat.crond.sample cron/sysstat.crond.sample.in
rm -f contrib/isag/isag
Expand Down
12 changes: 12 additions & 0 deletions build/prealloc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

sar (or sadc) allocates empty records in the data files it creates so that
it can save statistics for devices (disks, network interfaces, etc.) that
may be added to the system after the file was created. The drawback is that
data files take more space on disk than actually strictly necessary.
Answer here a positive integer number telling sar/sadc how much space they
should allocate for such devices. The default value (1) means that a few
records will be allocated. A greater value (e.g. 2 or 3) means that many
more of them will be allocated. A value of 0 doesn't allocate any empty
records.
The default value should be OK for most of you.

21 changes: 21 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,8 @@ COMPRESS_MANPG
IGNORE_MAN_GROUP
MAN_GROUP
man_group
PREALLOC_FACTOR
prealloc
COMPRESSAFTER
compressafter
HISTORY
Expand Down Expand Up @@ -758,6 +760,7 @@ sa_dir
conf_dir
history
compressafter
prealloc
man_group
cron_owner
cron_interval'
Expand Down Expand Up @@ -1407,6 +1410,8 @@ Some influential environment variables:
compressafter
number of days after which data files are compressed (default
value is 10)
prealloc preallocation factor that will determine data files size
(default value is 1)
man_group group for manual pages
cron_owner crontab owner
cron_interval
Expand Down Expand Up @@ -5053,6 +5058,19 @@ fi
$as_echo "$COMPRESSAFTER" >&6; }
# Preallocation factor
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking preallocation factor value" >&5
$as_echo_n "checking preallocation factor value... " >&6; }
if test x$prealloc = x""; then
PREALLOC_FACTOR=1
else
PREALLOC_FACTOR=$prealloc
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PREALLOC_FACTOR" >&5
$as_echo "$PREALLOC_FACTOR" >&6; }
# Manual page group
grep ^man: /etc/group >/dev/null 2>&1
if test $? = 0; then
Expand Down Expand Up @@ -5360,6 +5378,8 @@ ac_config_files="$ac_config_files version.h:version.in"
# File must be renamed
ac_config_files="$ac_config_files sysconfig.h:sysconfig.in"
# File must be renamed
ac_config_files="$ac_config_files prealloc.h:prealloc.in"
# File must be renamed
ac_config_files="$ac_config_files cron/sysstat.cron.daily"
ac_config_files="$ac_config_files cron/sysstat.cron.hourly"
Expand Down Expand Up @@ -6106,6 +6126,7 @@ do
"sysstat.sysconfig") CONFIG_FILES="$CONFIG_FILES sysstat.sysconfig" ;;
"version.h") CONFIG_FILES="$CONFIG_FILES version.h:version.in" ;;
"sysconfig.h") CONFIG_FILES="$CONFIG_FILES sysconfig.h:sysconfig.in" ;;
"prealloc.h") CONFIG_FILES="$CONFIG_FILES prealloc.h:prealloc.in" ;;
"cron/sysstat.cron.daily") CONFIG_FILES="$CONFIG_FILES cron/sysstat.cron.daily" ;;
"cron/sysstat.cron.hourly") CONFIG_FILES="$CONFIG_FILES cron/sysstat.cron.hourly" ;;
"cron/sysstat.crond") CONFIG_FILES="$CONFIG_FILES cron/sysstat.crond" ;;
Expand Down
12 changes: 12 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,17 @@ fi
AC_MSG_RESULT($COMPRESSAFTER)
AC_SUBST(COMPRESSAFTER)

# Preallocation factor
AC_MSG_CHECKING(preallocation factor value)
AC_ARG_VAR([prealloc],[preallocation factor that will determine data files size (default value is 1)])
if test x$prealloc = x""; then
PREALLOC_FACTOR=1
else
PREALLOC_FACTOR=$prealloc
fi
AC_MSG_RESULT($PREALLOC_FACTOR)
AC_SUBST(PREALLOC_FACTOR)

# Manual page group
grep ^man: /etc/group >/dev/null 2>&1
if test $? = 0; then
Expand Down Expand Up @@ -566,6 +577,7 @@ AC_CONFIG_FILES([cron/crontab:cron/crontab.sample]) # File must be renamed
AC_CONFIG_FILES([sysstat.sysconfig])
AC_CONFIG_FILES([version.h:version.in]) # File must be renamed
AC_CONFIG_FILES([sysconfig.h:sysconfig.in]) # File must be renamed
AC_CONFIG_FILES([prealloc.h:prealloc.in]) # File must be renamed
AC_CONFIG_FILES([cron/sysstat.cron.daily])
AC_CONFIG_FILES([cron/sysstat.cron.hourly])
AC_CONFIG_FILES([cron/sysstat.crond])
Expand Down
10 changes: 8 additions & 2 deletions iconfig
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ if [ "${COMPRESSAFTER}" != "" ]; then
COMPRESSAFTER="compressafter=${COMPRESSAFTER} "
fi

# Preallocation factor
PREALLOC_ANSWER=`${ASK} 'Preallocation factor value:' "prealloc" "prealloc"`
if [ "${PREALLOC_ANSWER}" != "" ]; then
PREALLOC_ANSWER="prealloc=${PREALLOC_ANSWER} "
fi

# Manual page group
MAN=`${ASK} 'Group for manual pages:' "man_group" "man_group"`
if [ "${MAN}" != "" ]; then
Expand Down Expand Up @@ -194,11 +200,11 @@ fi

echo
echo "./configure ${PREFIX}${SA_LIB_DIR}${SA_DIR}${SYSCONFIG_DIR}${CLEAN_SA_DIR}${NLS} \
${YESTERDAY}${HISTORY}${COMPRESSAFTER}${MAN}${IGNORE_MAN}${CRON}${RCDIR} \
${YESTERDAY}${HISTORY}${COMPRESSAFTER}${PREALLOC_ANSWER}${MAN}${IGNORE_MAN}${CRON}${RCDIR} \
${COMPRESSMANPG}${INSTALL_DOC}${DEBUGINFO}${INSTALL_ISAG}${SENSORS}${STRIP}"
echo

./configure ${PREFIX}${SA_LIB_DIR}${SA_DIR}${SYSCONFIG_DIR}${CLEAN_SA_DIR}${NLS} \
${YESTERDAY}${HISTORY}${COMPRESSAFTER}${MAN}${IGNORE_MAN}${CRON}${RCDIR} \
${YESTERDAY}${HISTORY}${COMPRESSAFTER}${PREALLOC_ANSWER}${MAN}${IGNORE_MAN}${CRON}${RCDIR} \
${COMPRESSMANPG}${INSTALL_DOC}${DEBUGINFO}${INSTALL_ISAG}${SENSORS}${STRIP}

17 changes: 17 additions & 0 deletions prealloc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* sysstat: System performance tools for Linux
* (C) 1999-2013 by Sebastien Godard (sysstat <at> orange.fr)
*/

#ifndef _PREALLOC_H
#define _PREALLOC_H

/* Preallocation constants for sar */
#define NR_IFACE_PREALLOC (2 * @PREALLOC_FACTOR@)
#define NR_SERIAL_PREALLOC (2 * @PREALLOC_FACTOR@)
#define NR_DISK_PREALLOC (3 * @PREALLOC_FACTOR@)
#define NR_FREQ_PREALLOC (0 * @PREALLOC_FACTOR@)
#define NR_USB_PREALLOC (5 * @PREALLOC_FACTOR@)
#define NR_FILESYSTEM_PREALLOC (3 * @PREALLOC_FACTOR@)

#endif /* _PREALLOC_H */
9 changes: 1 addition & 8 deletions sa.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdio.h>

#include "common.h"
#include "prealloc.h"
#include "rd_stats.h"
#include "rd_sensors.h"

Expand Down Expand Up @@ -192,14 +193,6 @@
*/
#define BITMAP_SIZE(m) ((((m) + 1) / 8) + 1)

/* Pre-allocation constants */
#define NR_IFACE_PREALLOC 2
#define NR_SERIAL_PREALLOC 2
#define NR_DISK_PREALLOC 3
#define NR_FREQ_PREALLOC 0
#define NR_USB_PREALLOC 5
#define NR_FILESYSTEM_PREALLOC 3

#define UTSNAME_LEN 65
#define TIMESTAMP_LEN 16
#define HEADER_LINE_LEN 512
Expand Down

0 comments on commit 436f85f

Please sign in to comment.