Skip to content

Commit 36dc6d1

Browse files
committed
Add diagnostics.sh
This is a copy of roles/kayobe-diagnostics/files/get_logs.sh in Kayobe.
1 parent d18dbe4 commit 36dc6d1

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

tools/diagnostics.sh

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#!/bin/bash
2+
3+
# NOTE(mgoddard): This has been adapted from tests/get_logs.sh in Kolla
4+
# Ansible.
5+
6+
# Environment variables:
7+
# $LOG_DIR is the directory to copy logs to.
8+
# $CONFIG_DIR is the directory to copy configuration from.
9+
# $PREVIOUS_CONFIG_DIR is the directory to copy previous configuration, prior
10+
# to an upgrade, from.
11+
12+
set +o errexit
13+
14+
copy_logs() {
15+
cp -rnL /var/lib/docker/volumes/kolla_logs/_data/* ${LOG_DIR}/kolla/
16+
if [[ -d ${CONFIG_DIR} ]]; then
17+
cp -rnL ${CONFIG_DIR}/etc/kayobe/* ${LOG_DIR}/kayobe_configs
18+
cp -rnL ${CONFIG_DIR}/etc/kolla/* ${LOG_DIR}/kolla_configs
19+
cp -rnL /etc/kolla/* ${LOG_DIR}/kolla_node_configs
20+
# Don't save the IPA images.
21+
rm ${LOG_DIR}/kayobe_configs/kolla/config/ironic/ironic-agent.{kernel,initramfs}
22+
rm ${LOG_DIR}/kolla_configs/config/ironic/ironic-agent.{kernel,initramfs}
23+
rm ${LOG_DIR}/kolla_node_configs/ironic-http/ironic-agent.{kernel,initramfs}
24+
rm ${LOG_DIR}/kolla_node_configs/ironic-tftp/ironic-agent.{kernel,initramfs}
25+
fi
26+
if [[ -n ${PREVIOUS_CONFIG_DIR} ]] && [[ -d ${PREVIOUS_CONFIG_DIR} ]]; then
27+
mkdir -p ${LOG_DIR}/previous_{kayobe,kolla}_configs
28+
cp -rnL ${PREVIOUS_CONFIG_DIR}/etc/kayobe/* ${LOG_DIR}/previous_kayobe_configs
29+
cp -rnL ${PREVIOUS_CONFIG_DIR}/etc/kolla/* ${LOG_DIR}/previous_kolla_configs
30+
# NOTE: we can't save node configs in /etc/kolla for the pervious
31+
# release since they'll have been overwritten at this point.
32+
# Don't save the IPA images.
33+
rm ${LOG_DIR}/previous_kayobe_configs/kolla/config/ironic/ironic-agent.{kernel,initramfs}
34+
rm ${LOG_DIR}/previous_kolla_configs/config/ironic/ironic-agent.{kernel,initramfs}
35+
fi
36+
37+
if [[ -d /opt/kayobe/etc/kolla ]]; then
38+
cp -rnL /opt/kayobe/etc/kolla/* ${LOG_DIR}/kolla_build_configs/
39+
fi
40+
41+
cp -rvnL /var/log/* ${LOG_DIR}/system_logs/
42+
43+
if [[ -x "$(command -v journalctl)" ]]; then
44+
journalctl --no-pager > ${LOG_DIR}/system_logs/syslog.txt
45+
journalctl --no-pager -u docker.service > ${LOG_DIR}/system_logs/docker.log
46+
journalctl --no-pager -u vbmcd.service > ${LOG_DIR}/system_logs/vbmcd.log
47+
journalctl --no-pager -u NetworkManager.service > ${LOG_DIR}/system_logs/NetworkManager.log
48+
else
49+
cp /var/log/upstart/docker.log ${LOG_DIR}/system_logs/docker.log
50+
fi
51+
52+
if [[ -d /etc/sysconfig/network-scripts/ ]]; then
53+
cp -r /etc/sysconfig/network-scripts/ ${LOG_DIR}/system_logs/
54+
fi
55+
56+
if [[ -d /etc/NetworkManager/system-connections/ ]]; then
57+
cp -r /etc/NetworkManager/system-connections/ ${LOG_DIR}/system_logs/
58+
fi
59+
60+
if [[ -d /etc/yum.repos.d/ ]]; then
61+
cp -r /etc/yum.repos.d/ ${LOG_DIR}/system_logs/
62+
fi
63+
64+
if [[ -d /etc/apt/sources.list.d/ ]]; then
65+
cp -r /etc/apt/sources.list.d/ ${LOG_DIR}/system_logs/
66+
fi
67+
68+
if [[ -d /etc/systemd/ ]]; then
69+
cp -rL /etc/systemd/ ${LOG_DIR}/system_logs/
70+
fi
71+
72+
df -h > ${LOG_DIR}/system_logs/df.txt
73+
# Gather disk usage statistics for files and directories larger than 1MB
74+
du -d 5 -hx / | sort -hr | grep '^[0-9\.]*[MGT]' > ${LOG_DIR}/system_logs/du.txt
75+
free > ${LOG_DIR}/system_logs/free.txt
76+
cat /etc/hosts > ${LOG_DIR}/system_logs/hosts.txt
77+
parted -l > ${LOG_DIR}/system_logs/parted-l.txt
78+
mount > ${LOG_DIR}/system_logs/mount.txt
79+
env > ${LOG_DIR}/system_logs/env.txt
80+
ip address > ${LOG_DIR}/system_logs/ip-address.txt
81+
ip route > ${LOG_DIR}/system_logs/ip-route.txt
82+
ip route show table all > ${LOG_DIR}/system_logs/ip-route-all-tables.txt
83+
ip rule list > ${LOG_DIR}/system_logs/ip-rule-list.txt
84+
85+
iptables-save > ${LOG_DIR}/system_logs/iptables.txt
86+
87+
if [ `command -v dpkg` ]; then
88+
dpkg -l > ${LOG_DIR}/system_logs/dpkg-l.txt
89+
fi
90+
if [ `command -v rpm` ]; then
91+
rpm -qa > ${LOG_DIR}/system_logs/rpm-qa.txt
92+
fi
93+
94+
# final memory usage and process list
95+
ps -eo user,pid,ppid,lwp,%cpu,%mem,size,rss,cmd > ${LOG_DIR}/system_logs/ps.txt
96+
97+
# available entropy
98+
cat /proc/sys/kernel/random/entropy_avail > ${LOG_DIR}/system_logs/entropy_avail.txt
99+
100+
# docker related information
101+
(docker info && docker images && docker ps -a) > ${LOG_DIR}/system_logs/docker-info.txt
102+
103+
for container in $(docker ps -a --format "{{.Names}}"); do
104+
docker logs --tail all ${container} &> ${LOG_DIR}/docker_logs/${container}.txt
105+
done
106+
107+
# Bifrost: grab config files and logs from the container.
108+
if [[ $(docker ps -q -f name=bifrost_deploy) ]]; then
109+
for service in dnsmasq ironic-api ironic-conductor ironic-inspector mariadb nginx rabbitmq-server; do
110+
mkdir -p ${LOG_DIR}/kolla/$service
111+
docker exec bifrost_deploy \
112+
systemctl status $service -l -n 10000 > ${LOG_DIR}/kolla/$service/${service}-systemd-status.txt
113+
docker exec bifrost_deploy \
114+
journalctl -u $service --no-pager > ${LOG_DIR}/kolla/$service/${service}-journal.txt
115+
done
116+
docker exec -it bifrost_deploy \
117+
journalctl --no-pager > ${LOG_DIR}/kolla/bifrost-journal.log
118+
for d in dnsmasq.conf ironic ironic-inspector nginx/nginx.conf; do
119+
docker cp bifrost_deploy:/etc/$d ${LOG_DIR}/kolla_node_configs/bifrost/
120+
done
121+
docker cp bifrost_deploy:/var/log/mariadb/mariadb.log ${LOG_DIR}/kolla/mariadb/
122+
fi
123+
124+
# IPA build logs
125+
if [[ -f /opt/kayobe/images/ipa/ipa.stderr ]] || [[ -f /opt/kayobe/images/ipa/ipa.stdout ]]; then
126+
mkdir -p ${LOG_DIR}/kayobe
127+
cp /opt/kayobe/images/ipa/ipa.stderr /opt/kayobe/images/ipa/ipa.stdout ${LOG_DIR}/kayobe/
128+
fi
129+
130+
# Overcloud host image build logs
131+
if [[ -f /opt/kayobe/images/deployment_image/deployment_image.stderr ]] || [[ -f /opt/kayobe/images/deployment_image/deployment_image.stdout ]]; then
132+
mkdir -p ${LOG_DIR}/kayobe
133+
cp /opt/kayobe/images/deployment_image/deployment_image.stderr /opt/kayobe/images/deployment_image/deployment_image.stdout ${LOG_DIR}/kayobe/
134+
fi
135+
136+
# Rename files to .txt; this is so that when displayed via
137+
# logs.openstack.org clicking results in the browser shows the
138+
# files, rather than trying to send it to another app or make you
139+
# download it, etc.
140+
for f in $(find ${LOG_DIR}/{system_logs,kolla,docker_logs} -name "*.log"); do
141+
mv $f ${f/.log/.txt}
142+
done
143+
144+
chmod -R 777 ${LOG_DIR}
145+
}
146+
147+
copy_logs

0 commit comments

Comments
 (0)