Enable sar report collection for global-jjb 21/5121/6
authorAnil Belur <abelur@linuxfoundation.org>
Wed, 7 Jun 2017 21:48:59 +0000 (07:48 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Sat, 10 Jun 2017 07:08:58 +0000 (17:08 +1000)
Change-Id: I0615d295b17151ade5c899350069516d66e6d809
Jira: releng-46
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
jjb/lf-macros.yaml
shell/sysstat.sh [new file with mode: 0644]

index 310df5d..bc64719 100644 (file)
       - description-setter:
           regexp: '^Build logs: .*'
 
+- builder:
+    name: lf-infra-sysstat
+    builders:
+      - shell: !include-raw:
+          - ../shell/sysstat.sh
+
 - builder:
     name: lf-jacoco-nojava-workaround
     builders:
     publishers:
       - postbuildscript:
           builders:
+            - lf-infra-sysstat
             - lf-infra-ship-logs
           script-only-if-succeeded: false
           script-only-if-failed: false
diff --git a/shell/sysstat.sh b/shell/sysstat.sh
new file mode 100644 (file)
index 0000000..e4e28ff
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+echo "---> lftools-sysstat.sh"
+set +e  # DON'T fail build if script fails.
+
+OS=$(facter operatingsystem)
+case "$OS" in
+    Ubuntu)
+        SYSSTAT_PATH="/var/log/sysstat"
+    ;;
+    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 s
+do
+    [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/"sar${s//[!0-9]/}
+done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
+
+# DON'T fail build if script fails.
+exit 0