]> granicus.if.org Git - sysstat/blob - sa1.in
mpstat.h: Remove unneeded 'aligned' attribute
[sysstat] / sa1.in
1 #!/bin/sh
2 # @SA_LIB_DIR@/sa1
3 # (C) 1999-2021 Sebastien Godard (sysstat <at> orange.fr)
4 #
5 #@(#) @PACKAGE_NAME@-@PACKAGE_VERSION@
6 #@(#) sa1: Collect and store binary data in system activity data file.
7 #
8
9 # Set default value for some variables.
10 # Used only if ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} doesn't exist!
11 HISTORY=0
12 SADC_OPTIONS=""
13 SA_DIR=@SA_DIR@
14 SYSCONFIG_DIR=@SYSCONFIG_DIR@
15 SYSCONFIG_FILE=@SYSCONFIG_FILE@
16 UMASK=0022
17 LONG_NAME=n
18
19 [ -r ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} ] && . ${SYSCONFIG_DIR}/${SYSCONFIG_FILE}
20
21 umask ${UMASK}
22
23 # If the user-supplied value for SA_DIR in sysconfig file is not a directory
24 # then fall back on default directory. Create this default directory if it doesn't exist.
25 [ -d ${SA_DIR} ] || SA_DIR=@SA_DIR@
26 [ -d @SA_DIR@ ] || mkdir @SA_DIR@
27
28 if [ ${HISTORY} -gt 28 ]
29 then
30         SADC_OPTIONS="${SADC_OPTIONS} -D"
31         LONG_NAME=y
32 fi
33
34 ENDIR=@SA_LIB_DIR@
35 cd ${ENDIR}
36 [ "$1" = "--boot" ] && shift && BOOT=y || BOOT=n
37 [ "$1" = "--sleep" ] && shift && SLEEP=y || SLEEP=n
38
39 ROTATE=n
40 [ "$1" = "--rotate" ] && shift && ROTATE=y && [ "$1" = "iso" ] && shift && LONG_NAME=y
41 if [ "${ROTATE}" = "y" ]
42 then
43         if [ "${LONG_NAME}" = "y" ]
44         then
45                 DATE=`date --date=yesterday +%Y%m%d`
46         else
47                 DATE=`date --date=yesterday +%d`
48         fi
49         SA_DIR=${SA_DIR}/sa${DATE}
50 fi
51
52 if [ "${SLEEP}" = "y" ]
53 then
54         exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} -C "LINUX SLEEP MODE ($*)" ${SA_DIR}
55 elif [ $# = 0 ] && [ "${BOOT}" = "n" ]
56 then
57 # Note: Stats are written at the end of previous file *and* at the
58 # beginning of the new one (when there is a file rotation) only if
59 # outfile has not been explicitly specified on the command line...
60         exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} 1 1 ${SA_DIR}
61 else
62         exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} $* ${SA_DIR}
63 fi