Merge "Set wget to quiet mode to hide Maven DL output"
[releng/global-jjb.git] / shell / sysstat.sh
1 #!/bin/bash
2 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> sysstat.sh"
12 set +e  # DON'T fail build if script fails.
13
14 OS=$(facter operatingsystem)
15 case "$OS" in
16     Ubuntu)
17         SYSSTAT_PATH="/var/log/sysstat"
18     ;;
19     CentOS|RedHat)
20         SYSSTAT_PATH="/var/log/sa"
21     ;;
22     *)
23         # nothing to do
24         exit 0
25     ;;
26 esac
27
28 SAR_DIR="$WORKSPACE/archives/sar-reports"
29 mkdir -p "$SAR_DIR"
30 cp "$SYSSTAT_PATH/"* $_
31 # convert sar data to ascii format
32 while IFS="" read -r s
33 do
34     [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/"sar${s//[!0-9]/}
35 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
36
37 # DON'T fail build if script fails.
38 exit 0