X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fsysstat.sh;h=6ecab67705c37f5fbc73229d1af376a78a769665;hb=6eefde1f463638b5021c2ec96eb67a017d379f1f;hp=e4e28ff6cffb0e0a97328698b60d37e7af7c5b4f;hpb=0786d5870812545b09f27699d7f71d197a257575;p=releng%2Fglobal-jjb.git diff --git a/shell/sysstat.sh b/shell/sysstat.sh index e4e28ff6..6ecab677 100644 --- a/shell/sysstat.sh +++ b/shell/sysstat.sh @@ -1,5 +1,5 @@ #!/bin/bash -# @License EPL-1.0 +# SPDX-License-Identifier: EPL-1.0 ############################################################################## # Copyright (c) 2017 The Linux Foundation and others. # @@ -8,13 +8,18 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################## -echo "---> lftools-sysstat.sh" +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" @@ -27,11 +32,11 @@ esac SAR_DIR="$WORKSPACE/archives/sar-reports" mkdir -p "$SAR_DIR" -cp "$SYSSTAT_PATH/"* $_ +cp "$SYSSTAT_PATH/"* "$_" # convert sar data to ascii format -while IFS="" read -r s +while IFS="" read -r sarfilenum do - [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/"sar${s//[!0-9]/} + [ -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.