3 # Copyright (c) 2020 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 echo "---> jjb/scripts/setup_executor_env.sh"
20 OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
21 OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
23 dockerfile="/scratch/docker-build/Dockerfile"
24 file_delimiter="----- %< -----"
25 long_line="************************************************************************"
26 downloads_cache="/root/Downloads"
28 # Requires all nomad client machines to run the following command
29 # and mount /scratch/nomad into the docker container:
30 # sudo mkdir -p /scratch/nomad && echo "$(hostname)-$(uname -m)" | sudo tee /scratch/nomad/nomad-client
31 nomad_client_file="/scratch/nomad/nomad-client"
32 if [ -f "$nomad_client_file" ] ; then
33 NOMAD_CLIENT="$(cat $nomad_client_file)"
35 NOMAD_CLIENT="Unknown"
40 echo "Executor Runtime Attributes:"
41 echo "OS: $OS_ID-$OS_VERSION_ID"
43 echo "Nomad Client Hostname: $NOMAD_CLIENT"
44 echo "Container ID: $(hostname)"
47 if [ -f "$dockerfile" ] ; then
48 echo -e "Executor Dockerfile: ${dockerfile}\n${file_delimiter}"
50 echo "$file_delimiter"
52 echo "Unknown Executor: '$dockerfile' not found!"
55 # Performance analysis
58 if [ "$OS_ID" == "ubuntu" ] || [ "$OS_ID" = "debian" ] ; then
59 SYSSTAT_PATH="/var/log/sysstat"
60 elif [ "$OS_ID" == "centos" ] ; then
61 if [ "$OS_VERSION_ID" = "7" ] ; then
62 SYSSTAT_PATH="/var/log/sa/sa02"
64 SYSSTAT_PATH="/var/log/sa"
68 echo "Virtual memory stat"
69 vmstat ${perf_interval} ${perf_trials}
70 echo "CPU time breakdowns per CPU"
71 mpstat -P ALL ${perf_interval} ${perf_trials}
72 echo "Per-process summary"
73 pidstat ${perf_interval} ${perf_trials}
74 echo "Block device stats"
75 iostat -xz ${perf_interval} ${perf_trials}
76 echo "Memory utilization"
78 echo "Network interface throughput"
79 sar -n DEV -o ${SYSSTAT_PATH} ${perf_interval} ${perf_trials}
81 sar -n TCP,ETCP -o ${SYSSTAT_PATH} ${perf_interval} ${perf_trials}
85 echo "Executor package list:"
86 if [ "$OS_ID" == "ubuntu" ] || [ "$OS_ID" = "debian" ] ; then
87 dpkg-query -W -f='${binary:Package}\t${Version}\n' | column -t || true
88 elif [ "$OS_ID" == "centos" ] ; then
89 yum list installed || true
93 echo "Python3 package list:"
94 pip3 list 2>/dev/null | column -t || true
97 echo "Executor Downloads cache '$downloads_cache':"
98 ls -lh "$downloads_cache" || true
101 echo "DNS nameserver config in '/etc/resolv.conf':"
102 cat /etc/resolv.conf || true
105 if [ -n "$(which ccache || true)" ] ; then
106 if [ -z "${CCACHE_DIR:-}" ] || [ ! -d "$CCACHE_DIR" ] ; then
107 echo "CCACHE_DIR='$CCACHE_DIR' is missing, disabling CCACHE..."
108 export CCACHE_DISABLE="1"
110 if [ -n "${CCACHE_DISABLE:-}" ] ; then
111 echo "CCACHE_DISABLE = '$CCACHE_DISABLE'"
113 echo "ccache statistics:"
116 echo "WARNING: ccache is not installed!"
117 export CCACHE_DISABLE="1"