Fix bashate
Change-Id: I7769428dc0e65f67b79693b033c7e70681a11a6c
This commit is contained in:
@@ -36,29 +36,29 @@ export RSYNC_CMD="rsync --archive --safe-links --ignore-errors --quiet --no-perm
|
|||||||
# things to this list please alphabetize the entries so it's
|
# things to this list please alphabetize the entries so it's
|
||||||
# easy for folks to find and adjust items as needed.
|
# easy for folks to find and adjust items as needed.
|
||||||
COMMON_ETC_LOG_NAMES="apt \
|
COMMON_ETC_LOG_NAMES="apt \
|
||||||
apache2 \
|
apache2 \
|
||||||
haproxy \
|
haproxy \
|
||||||
httpd \
|
httpd \
|
||||||
memcached \
|
memcached \
|
||||||
mongodb \
|
mongodb \
|
||||||
my.cnf \
|
my.cnf \
|
||||||
mysql \
|
mysql \
|
||||||
netplan \
|
netplan \
|
||||||
network \
|
network \
|
||||||
nginx \
|
nginx \
|
||||||
pip.conf \
|
pip.conf \
|
||||||
qpid-dispatch \
|
qpid-dispatch \
|
||||||
rabbitmq \
|
rabbitmq \
|
||||||
repo \
|
repo \
|
||||||
resolv.conf \
|
resolv.conf \
|
||||||
rsyslog \
|
rsyslog \
|
||||||
sasl2 \
|
sasl2 \
|
||||||
sysconfig/network-scripts \
|
sysconfig/network-scripts \
|
||||||
sysconfig/network \
|
sysconfig/network \
|
||||||
systemd/network \
|
systemd/network \
|
||||||
yum \
|
yum \
|
||||||
yum.repos.d \
|
yum.repos.d \
|
||||||
zypp"
|
zypp"
|
||||||
|
|
||||||
COMMON_ETC_LOG_NAMES+=" $(awk -F'os_' '/name.*os_.*/ {print $2}' $(dirname $(readlink -f ${BASH_SOURCE[0]}))/../ansible-role-requirements.yml | tr '\n' ' ')"
|
COMMON_ETC_LOG_NAMES+=" $(awk -F'os_' '/name.*os_.*/ {print $2}' $(dirname $(readlink -f ${BASH_SOURCE[0]}))/../ansible-role-requirements.yml | tr '\n' ' ')"
|
||||||
|
|
||||||
@@ -95,67 +95,67 @@ function repo_information {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function store_artifacts {
|
function store_artifacts {
|
||||||
# Store known artifacts only if they exist. If the target directory does
|
# Store known artifacts only if they exist. If the target directory does
|
||||||
# exist, it will be created.
|
# exist, it will be created.
|
||||||
# USAGE: store_artifacts /src/to/artifacts /path/to/store
|
# USAGE: store_artifacts /src/to/artifacts /path/to/store
|
||||||
if sudo test -e "${1}"; then
|
if sudo test -e "${1}"; then
|
||||||
if [[ ! -d "${2}" ]]; then
|
if [[ ! -d "${2}" ]]; then
|
||||||
mkdir -vp "${2}"
|
mkdir -vp "${2}"
|
||||||
|
fi
|
||||||
|
echo "Running artifact sync for \"${1}\" to \"${2}\""
|
||||||
|
sudo ${RSYNC_CMD} ${1} ${2} || true
|
||||||
fi
|
fi
|
||||||
echo "Running artifact sync for \"${1}\" to \"${2}\""
|
|
||||||
sudo ${RSYNC_CMD} ${1} ${2} || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function store_journal_artifacts {
|
function store_journal_artifacts {
|
||||||
# Store lines from a known unit's journal as a plain-text log file.
|
# Store lines from a known unit's journal as a plain-text log file.
|
||||||
# USAGE: store_journal_artifacts UNIT_TO_MATCH /path/to/store
|
# USAGE: store_journal_artifacts UNIT_TO_MATCH /path/to/store
|
||||||
if [ $? == 0 ]; then
|
if [ $? == 0 ]; then
|
||||||
if [[ ! -d "${2}" ]]; then
|
if [[ ! -d "${2}" ]]; then
|
||||||
mkdir -vp "${2}"
|
mkdir -vp "${2}"
|
||||||
|
fi
|
||||||
|
if [[ ${3:-false} != false ]]; then
|
||||||
|
if [[ -f "${3}/system.journal" ]]; then
|
||||||
|
SYSTEMD_UNITS=$(sudo journalctl --file="${3}/system.journal" -F _SYSTEMD_UNIT | grep "${service}")
|
||||||
|
for service_unit in $(echo -e "${SYSTEMD_UNITS}"); do
|
||||||
|
echo "Pulling journal for ${service_unit}"
|
||||||
|
sudo journalctl --file="${3}/system.journal" \
|
||||||
|
--unit="${service_unit}" | sudo tee "${2}/${service_unit}.journal-${TS}.log" &>/dev/null
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
SYSTEMD_UNITS=$(sudo journalctl --output=json-pretty -F _SYSTEMD_UNIT | grep "${service}")
|
||||||
|
for service_unit in $(echo -e "${SYSTEMD_UNITS}"); do
|
||||||
|
echo "Pulling journal for ${service_unit}"
|
||||||
|
sudo journalctl --unit="${service_unit}" | sudo tee "${2}/${service_unit}.journal-${TS}.log" &>/dev/null
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ ${3:-false} != false ]]; then
|
|
||||||
if [[ -f "${3}/system.journal" ]]; then
|
|
||||||
SYSTEMD_UNITS=$(sudo journalctl --file="${3}/system.journal" -F _SYSTEMD_UNIT | grep "${service}")
|
|
||||||
for service_unit in $(echo -e "${SYSTEMD_UNITS}"); do
|
|
||||||
echo "Pulling journal for ${service_unit}"
|
|
||||||
sudo journalctl --file="${3}/system.journal" \
|
|
||||||
--unit="${service_unit}" | sudo tee "${2}/${service_unit}.journal-${TS}.log" &>/dev/null
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
SYSTEMD_UNITS=$(sudo journalctl --output=json-pretty -F _SYSTEMD_UNIT | grep "${service}")
|
|
||||||
for service_unit in $(echo -e "${SYSTEMD_UNITS}"); do
|
|
||||||
echo "Pulling journal for ${service_unit}"
|
|
||||||
sudo journalctl --unit="${service_unit}" | sudo tee "${2}/${service_unit}.journal-${TS}.log" &>/dev/null
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_files {
|
function find_files {
|
||||||
find "${WORKING_DIR}/logs/" -type f \
|
find "${WORKING_DIR}/logs/" -type f \
|
||||||
! -name "*.gz" \
|
! -name "*.gz" \
|
||||||
! -name '*.html' \
|
! -name '*.html' \
|
||||||
! -name '*.subunit' \
|
! -name '*.subunit' \
|
||||||
! -name "*.journal" \
|
! -name "*.journal" \
|
||||||
! -name 'ansible.sqlite' | grep -v 'stackviz'
|
! -name 'ansible.sqlite' | grep -v 'stackviz'
|
||||||
}
|
}
|
||||||
|
|
||||||
function rename_files {
|
function rename_files {
|
||||||
find_files |\
|
find_files |\
|
||||||
while read filename; do \
|
while read filename; do \
|
||||||
mv ${filename} ${filename}.txt || echo "WARNING: Could not rename ${filename}"; \
|
mv ${filename} ${filename}.txt || echo "WARNING: Could not rename ${filename}"; \
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function compress_files {
|
function compress_files {
|
||||||
# We use 'command' to ensure that we're not executing with an alias.
|
# We use 'command' to ensure that we're not executing with an alias.
|
||||||
GZIP_CMD="command gzip --force --best"
|
GZIP_CMD="command gzip --force --best"
|
||||||
find_files |\
|
find_files |\
|
||||||
while read filename; do \
|
while read filename; do \
|
||||||
${GZIP_CMD} ${filename} || echo "WARNING: Could not gzip ${filename}"; \
|
${GZIP_CMD} ${filename} || echo "WARNING: Could not gzip ${filename}"; \
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
## Main ----------------------------------------------------------------------
|
## Main ----------------------------------------------------------------------
|
||||||
@@ -206,31 +206,31 @@ done
|
|||||||
|
|
||||||
# Gather container etc artifacts
|
# Gather container etc artifacts
|
||||||
if which lxc-ls &> /dev/null; then
|
if which lxc-ls &> /dev/null; then
|
||||||
for CONTAINER_NAME in $(sudo lxc-ls -1); do
|
for CONTAINER_NAME in $(sudo lxc-ls -1); do
|
||||||
CONTAINER_PID=$(sudo lxc-info -p -n ${CONTAINER_NAME} | awk '{print $2}')
|
CONTAINER_PID=$(sudo lxc-info -p -n ${CONTAINER_NAME} | awk '{print $2}')
|
||||||
ETC_DIR="/proc/${CONTAINER_PID}/root/etc"
|
ETC_DIR="/proc/${CONTAINER_PID}/root/etc"
|
||||||
MACHINE_ID="$(sudo cat ${ETC_DIR}/machine-id)"
|
MACHINE_ID="$(sudo cat ${ETC_DIR}/machine-id)"
|
||||||
LOG_DIR="/proc/${CONTAINER_PID}/root/var/log"
|
LOG_DIR="/proc/${CONTAINER_PID}/root/var/log"
|
||||||
JOURNAL_DIR="/proc/${CONTAINER_PID}/root/run/log/journal/${MACHINE_ID}"
|
JOURNAL_DIR="/proc/${CONTAINER_PID}/root/run/log/journal/${MACHINE_ID}"
|
||||||
repo_information ${CONTAINER_NAME}
|
repo_information ${CONTAINER_NAME}
|
||||||
PIDS=()
|
PIDS=()
|
||||||
for service in ${COMMON_ETC_LOG_NAMES}; do
|
for service in ${COMMON_ETC_LOG_NAMES}; do
|
||||||
echo "Running in container collection for service ${service}"
|
echo "Running in container collection for service ${service}"
|
||||||
store_artifacts ${ETC_DIR}/${service} "${WORKING_DIR}/logs/etc/openstack/${CONTAINER_NAME}/" &
|
store_artifacts ${ETC_DIR}/${service} "${WORKING_DIR}/logs/etc/openstack/${CONTAINER_NAME}/" &
|
||||||
pid=$!
|
pid=$!
|
||||||
PIDS[${pid}]=${pid}
|
PIDS[${pid}]=${pid}
|
||||||
store_artifacts ${LOG_DIR}/${service} "${WORKING_DIR}/logs/openstack/${CONTAINER_NAME}/" &
|
store_artifacts ${LOG_DIR}/${service} "${WORKING_DIR}/logs/openstack/${CONTAINER_NAME}/" &
|
||||||
pid=$!
|
pid=$!
|
||||||
PIDS[${pid}]=${pid}
|
PIDS[${pid}]=${pid}
|
||||||
store_journal_artifacts ${service} "${WORKING_DIR}/logs/openstack/${CONTAINER_NAME}" "${JOURNAL_DIR}" &
|
store_journal_artifacts ${service} "${WORKING_DIR}/logs/openstack/${CONTAINER_NAME}" "${JOURNAL_DIR}" &
|
||||||
pid=$!
|
pid=$!
|
||||||
PIDS[${pid}]=${pid}
|
PIDS[${pid}]=${pid}
|
||||||
|
done
|
||||||
|
echo "Waiting for container collection jobs for ${CONTAINER_NAME} to finish"
|
||||||
|
for job_pid in ${!PIDS[@]}; do
|
||||||
|
wait ${PIDS[$job_pid]} || exit 99
|
||||||
|
done
|
||||||
done
|
done
|
||||||
echo "Waiting for container collection jobs for ${CONTAINER_NAME} to finish"
|
|
||||||
for job_pid in ${!PIDS[@]}; do
|
|
||||||
wait ${PIDS[$job_pid]} || exit 99
|
|
||||||
done
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -258,10 +258,10 @@ repo_information host
|
|||||||
|
|
||||||
# Record the active interface configs
|
# Record the active interface configs
|
||||||
if which ethtool &> /dev/null; then
|
if which ethtool &> /dev/null; then
|
||||||
for interface in $(ip -o link | awk -F':' '{print $2}' | sed 's/@.*//g'); do
|
for interface in $(ip -o link | awk -F':' '{print $2}' | sed 's/@.*//g'); do
|
||||||
echo "ethtool -k ${interface}"
|
echo "ethtool -k ${interface}"
|
||||||
ethtool -k ${interface} > "${WORKING_DIR}/logs/ethtool-${interface}-${TS}-cfg.txt" || true
|
ethtool -k ${interface} > "${WORKING_DIR}/logs/ethtool-${interface}-${TS}-cfg.txt" || true
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "No ethtool available" | tee -a "${WORKING_DIR}/logs/ethtool-${TS}-${interface}-cfg.txt"
|
echo "No ethtool available" | tee -a "${WORKING_DIR}/logs/ethtool-${TS}-${interface}-cfg.txt"
|
||||||
fi
|
fi
|
||||||
@@ -275,3 +275,4 @@ sudo chmod -R ugo+rX "${WORKING_DIR}/logs"
|
|||||||
sudo chown -R $(whoami) "${WORKING_DIR}/logs"
|
sudo chown -R $(whoami) "${WORKING_DIR}/logs"
|
||||||
|
|
||||||
echo "#### END LOG COLLECTION ###"
|
echo "#### END LOG COLLECTION ###"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user