File xen-supportconfig of Package xen.19910

#!/bin/bash
#############################################################
# Name:        Supportconfig Plugin for Xen
# Description: Gathers important troubleshooting information
#              about Xen and its tools
# Author:      Jim Fehlig <jfehlig@suse.com>
#############################################################

# TODO:
# - Anything needed for UEFI?
#

RCFILE="/usr/lib/supportconfig/resources/scplugin.rc"

GRUB2_CONF_FILES="/etc/default/grub"
XEN_CONF_FILES="/etc/xen/xl.conf /etc/sysconfig/xencommons /etc/sysconfig/xendomains"
XEN_SERVICES="xencommons xendomains xen-watchdog"
VM_CONF_FILES=""
XEN_LOG_FILES=""

if [ -s $RCFILE ]; then
    if ! source $RCFILE; then
        echo "ERROR: Initializing resource file: $RCFILE" >&2
        exit 1
    fi
fi

rpm_verify() {
    thisrpm="$1"
    local ret=0

    echo
    echo "#==[ Validating RPM ]=================================#"
    if rpm -q "$thisrpm" >/dev/null 2>&1; then
        echo "# rpm -V $thisrpm"

        if rpm -V "$thisrpm"; then
            echo "Status: Passed"
        else
            echo "Status: WARNING"
        fi
    else
        echo "package $thisrpm is not installed"
	ret=1
    fi
    echo
    return $ret
}

# if no xen package we are done
if ! rpm_verify xen; then
    echo "Skipped"
    exit 0
fi

# if not a xen host (dom0) we are done
echo "#==[ Checking if booted Xen ]=================================#"
if [ ! -d /proc/xen ] || [ ! -e /proc/xen/capabilities ] || [ `cat /proc/xen/capabilities` != "control_d" ]; then
    echo "No"
    echo "Skipped"
    exit 0
else
    echo "Yes"
    echo
fi

# basic system information:
plugin_command "uname -r"
for service in $XEN_SERVICES; do
    plugin_command "systemctl status $service"
    plugin_command "systemctl is-enabled $service"
done
plugin_command "lscpu"
plugin_command "xl info --numa"
plugin_command "xl list"
plugin_command "xl pci-assignable-list"
plugin_command "xenstore-ls"
plugin_command "ps -ef | grep xen"
# dump grub2-related conf files
pconf_files "$GRUB2_CONF_FILES"
# dump Xen-related conf files
pconf_files "$XEN_CONF_FILES"

# detailed system info:
plugin_command "xl list --long"
plugin_command "xl dmesg"
# network-related info often useful for debugging
if [ systemctl is-enabled NetworkManager.service 2>&1 > /dev/null ]; then
    echo "NOTE: NetworkManager should not be enabled on a Xen host"
fi
plugin_command "route -n"
plugin_command "arp -v"
plugin_command "ip link show type bridge"
plugin_command "bridge link show"
# list contents of common config and image directories
plugin_command "ls -alR /etc/xen/vm/"
plugin_command "ls -alR /etc/xen/auto/"
plugin_command "ls -alR /var/lib/xen/images/"
# dump VM-related conf files
test -d /etc/xen/vm && VM_CONF_FILES=$(find -L /etc/xen/vm/ -type f | sort)
pconf_files "$VM_CONF_FILES"
# dump log files
test -d /var/log/xen && XEN_LOG_FILES="$(find -L /var/log/xen/ -type f | grep 'log$' | sort)"
plog_files 0 "$XEN_LOG_FILES"

echo "Done"
openSUSE Build Service is sponsored by