From 593a929642a9d0101b1253df23a6bceadd63c658 Mon Sep 17 00:00:00 2001 From: James Denton Date: Mon, 9 Dec 2019 13:10:47 -0500 Subject: [PATCH] Update scripts-library.sh to grab output when command exists This patch updates scripts-library.sh to only grab output from btrfs, nspawn, and iptables when the commands exist in order to aid in the troubleshooting of (real) failures. Change-Id: I5c8677d3e8d1e1c6a6486654d532a899b5d0cf29 --- scripts/scripts-library.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index c355aa492b..bd626cc743 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -336,8 +336,10 @@ function get_instance_info { networkctl lldp >> \ "/openstack/log/instance-info/host_networkd_lldp_${TS}.log" || true fi - (iptables -vnL && iptables -t nat -vnL && iptables -t mangle -vnL) > \ - "/openstack/log/instance-info/host_firewall_info_${TS}.log" || true + if [ "$(which iptables)" ]; then + (iptables -vnL && iptables -t nat -vnL && iptables -t mangle -vnL) > \ + "/openstack/log/instance-info/host_firewall_info_${TS}.log" || true + fi if [ "$(which ansible)" ]; then ANSIBLE_HOST_KEY_CHECKING=False \ ansible -i "localhost," localhost -m setup > \ @@ -347,8 +349,10 @@ function get_instance_info { "/openstack/log/instance-info/host_repo_info_${TS}.log" || true for i in nspawn-macvlan.service nspawn-networking.slice nspawn.slice; do - systemctl status ${i} > "/openstack/log/instance-info/${i}_${TS}.log" || true - journalctl -u ${i} >> "/openstack/log/instance-info/${i}_${TS}.log" || true + if [ "$(systemctl is-active --quiet ${i})" ]; then + systemctl status ${i} > "/openstack/log/instance-info/${i}_${TS}.log" || true + journalctl -u ${i} >> "/openstack/log/instance-info/${i}_${TS}.log" || true + fi done ip route get 1 > "/openstack/log/instance-info/routes_${TS}.log" || true @@ -366,7 +370,21 @@ function get_instance_info { ;; esac - if command -v zfs >/dev/null; then + # Storage reports + for dir_name in lxc machines; do + if [ "$(which btrfs)" ]; then + btrfs filesystem usage /var/lib/${dir_name} > \ + "/openstack/log/instance-info/btrfs_${dir_name}_usage_${TS}.log" || true + btrfs filesystem show /var/lib/${dir_name} > \ + "/openstack/log/instance-info/btrfs_${dir_name}_show_${TS}.log" || true + btrfs filesystem df /var/lib/${dir_name} > \ + "/openstack/log/instance-info/btrfs_${dir_name}_df_${TS}.log" || true + btrfs qgroup show --human-readable -pcre --iec /var/lib/${dir_name} > \ + "/openstack/log/instance-info/btrfs_${dir_name}_quotas_${TS}.log" || true + fi + done + + if [ "$(which zfs)" ]; then zfs list > "/openstack/log/instance-info/zfs_lxc_${TS}.log" || true fi