forked from sysstat/sysstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sa2.in
45 lines (39 loc) · 1.39 KB
/
sa2.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
# @SA_LIB_DIR@/sa2
# (C) 1999-2014 Sebastien Godard (sysstat <at> orange.fr)
#
#@(#) @PACKAGE_NAME@-@PACKAGE_VERSION@
#@(#) sa2: Write a daily report
#
S_TIME_FORMAT=ISO ; export S_TIME_FORMAT
umask 0022
prefix=@prefix@
exec_prefix=@exec_prefix@
SA_DIR=@SA_DIR@
SYSCONFIG_DIR=@SYSCONFIG_DIR@
HISTORY=@HISTORY@
COMPRESSAFTER=@COMPRESSAFTER@
ZIP="@ZIP@"
YESTERDAY=@YESTERDAY@
DATE=`date ${YESTERDAY} +%d`
[ -r ${SYSCONFIG_DIR}/sysstat ] && . ${SYSCONFIG_DIR}/sysstat
[ -d ${SA_DIR} ] || SA_DIR=@SA_DIR@
if [ ${HISTORY} -gt 28 ]
then
DATE=`date ${YESTERDAY} +%Y%m%d`
fi
CURRENTFILE=sa${DATE}
CURRENTRPT=sar${DATE}
RPT=${SA_DIR}/${CURRENTRPT}
DFILE=${SA_DIR}/${CURRENTFILE}
ENDIR=@bindir@
[ -f "$DFILE" ] || exit 0
cd ${ENDIR}
${ENDIR}/sar $* -f ${DFILE} > ${RPT}
find ${SA_DIR} \( -name 'sar??' -o -name 'sa??' -o -name 'sar??.xz' -o -name 'sa??.xz' -o -name 'sar??.gz' -o -name 'sa??.gz' -o -name 'sar??.bz2' -o -name 'sa??.bz2' \) \
-mtime +"${HISTORY}" -exec rm -f {} \;
find ${SA_DIR} \( -name 'sar????????' -o -name 'sa????????' -o -name 'sar????????.xz' -o -name 'sa????????.xz' -o -name 'sar????????.gz' -o -name 'sa????????.gz' -o -name 'sar????????.bz2' -o -name 'sa????????.bz2' \) \
-mtime +"${HISTORY}" -exec rm -f {} \;
find ${SA_DIR} \( -name 'sar??' -o -name 'sa??' -o -name 'sar????????' -o -name 'sa????????' \) -type f -mtime +"${COMPRESSAFTER}" \
-exec ${ZIP} {} \; > /dev/null 2>&1
exit 0