Skip to content

Instantly share code, notes, and snippets.

@askb
Created March 2, 2018 01:38
Show Gist options
  • Save askb/78eeec07b75024abd87a3506a7409e63 to your computer and use it in GitHub Desktop.
Save askb/78eeec07b75024abd87a3506a7409e63 to your computer and use it in GitHub Desktop.
Update sysstat polling frequency to 1 minute and restart service on Ubuntu 16.04
sudo apt-get install sysstat -y
sudo sed -i -e 's#ENABLED="false"#ENABLED="true"#' /etc/default/sysstat
sudo sed -i -e 's#5-55/10#5-55/1#' /etc/cron.d/sysstat
sudo systemctl restart sysstat.service
@askb
Copy link
Author

askb commented Mar 2, 2018

# process collected data

echo "---> sysstat.sh"
set +e  # DON'T fail build if script fails.

OS=$(facter operatingsystem)
case "$OS" in
    Ubuntu)
        SYSSTAT_PATH="/var/log/sysstat"

        # Dont run the script when systat is not enabled by default
        if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
            exit 0
        fi
    ;;
    CentOS|RedHat)
        SYSSTAT_PATH="/var/log/sa"
    ;;
    *)
        # nothing to do
        exit 0
    ;;
esac

SAR_DIR="$WORKSPACE/archives/sar-reports"
mkdir -p "$SAR_DIR"
cp "$SYSSTAT_PATH/"* "$_"
# convert sar data to ascii format
while IFS="" read -r sarfilenum
do
    [ -f "$sarfilenum" ] && LC_TIME=POSIX sar -A -f "$sarfilenum" > "$SAR_DIR/sar${sarfilenum//[!0-9]/}"
done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)

# DON'T fail build if script fails.
exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment