#!/bin/bash



_install() {
	if [[ $VMFLAG = 1 ]];then
		return 0
	fi
	if [[ $ARCH = 'aarch64' ]];then
		return 0
	fi

    local SAR_CRON="$BASEDIR/configs/sar/sysstat"
    \cp -f $SAR_CRON /etc/cron.d/sysstat
    sed -i 's/^HISTORY.*/HISTORY=28/' /etc/sysconfig/sysstat
    sed -i 's/^COMPRESSAFTER.*/#COMPRESSAFTER=28/' /etc/sysconfig/sysstat
}

_check() {
	_check="PASS"

    if [[ $VMFLAG = 1 ]];then
		return 0
	fi
	if [[ $ARCH = 'aarch64' ]];then
		return 0
	fi
    grep -q 'HISTORY=28' /etc/sysconfig/sysstat
    if [[ $? -ne 0 ]];then
        _check="FAIL"
        PRINT_ERR "[ERROR] sysstat HISTROY is not 28"
    fi
    grep -q '^COMPRESSAFTER' /etc/sysconfig/sysstat
    if [[ $? -eq 0 ]];then
        _check="FAIL"
        PRINT_ERR "[ERROR] sysstat COMPRESSAFTER is on"
    fi
    grep -q '* * * * * root /usr/lib64/sa/sa1 2 30' /etc/cron.d/sysstat
    if [[ $? -ne 0 ]];then
        _check="FAIL"
        PRINT_ERR "[ERROR] sysstat crontab is not right"
    fi
}
