X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fsysstat.sh;h=eada1b35994b9181a21a98284ae30fd96430ae6f;hb=a86c6e8d376c95aa00b179fce9d207e61c8f72d0;hp=d90061c01513c824ee27faa359f9343a3b14ab29;hpb=8ec4cbe3b24fcda4eac98be1101db78e195cd747;p=releng%2Fglobal-jjb.git diff --git a/shell/sysstat.sh b/shell/sysstat.sh index d90061c0..eada1b35 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. # @@ -11,15 +11,33 @@ echo "---> sysstat.sh" set +e # DON'T fail build if script fails. +if awk -F/ '$2 == "docker"' /proc/self/cgroup | read -r; then + exit 0 +fi + + OS=$(facter operatingsystem) case "$OS" in Ubuntu) + os_release=$(facter operatingsystemrelease) + case $os_release in + 16.04|18.04|20.04) + if ! systemctl status sysstat > /dev/null; then + exit 0 + fi + ;; + 14.04) + if [[ ! -f /etc/default/sysstat ]] || \ + ! grep --quiet 'ENABLED="true"' /etc/default/sysstat; then + exit 0 + fi + ;; + *) + echo "ERROR: Unknown Release: Ubuntu $os_release" + exit 1 + ;; + esac 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" @@ -34,9 +52,8 @@ SAR_DIR="$WORKSPACE/archives/sar-reports" mkdir -p "$SAR_DIR" cp "$SYSSTAT_PATH/"* "$_" # convert sar data to ascii format -while IFS="" read -r s -do - [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/sar${s//[!0-9]/}" +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.