X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fsysstat.sh;h=5b496259cf0d3af5da636f7ea744c2d752f4907d;hb=2a10c83b2d506008cc6c01c134515fb6328e1f3a;hp=e4e28ff6cffb0e0a97328698b60d37e7af7c5b4f;hpb=c887df2200ea8a7a58e0aeb538affd0c93a48dfc;p=releng%2Fglobal-jjb.git diff --git a/shell/sysstat.sh b/shell/sysstat.sh index e4e28ff6..5b496259 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,12 +8,30 @@ # 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) + os_release=$(facter operatingsystemrelease) + case $os_release in + 16.04|18.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" ;; CentOS|RedHat) @@ -27,11 +45,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.