Improve log collection

Logs from test runs on systemd systems were not being
collected properly. Allow logs to be collected from
systemd if available and fall back to the upstart
location. Also, only collect information from netstat
and iptables if present.

Change-Id: I000c3d0c7d576eeb4ab051f68a6fef8a83dc06fb
Closes-Bug: #1470128
This commit is contained in:
stephane 2016-02-23 17:28:57 -08:00
parent d9c93c669c
commit c785d947f6
1 changed files with 13 additions and 4 deletions

View File

@ -13,9 +13,18 @@ echo "Making logs directory and collecting logs."
sudo cp /var/log/libvirt/baremetal_logs/testvm1_console.log ${LOG_LOCATION}
sudo chown $USER ${LOG_LOCATION}/testvm1_console.log
dmesg &> ${LOG_LOCATION}/dmesg.log
sudo netstat -apn &> ${LOG_LOCATION}/netstat.log
sudo iptables -L -n -v &> ${LOG_LOCATION}/iptables.log
sudo cp /var/log/upstart/ironic-api.log ${LOG_LOCATION}/
if $(netstat --version &>/dev/null); then
sudo netstat -apn &> ${LOG_LOCATION}/netstat.log
fi
if $(iptables --version &>/dev/null); then
sudo iptables -L -n -v &> ${LOG_LOCATION}/iptables.log
fi
if $(journalctl --version &>/dev/null); then
sudo journalctl -u ironic-api &> ${LOG_LOCATION}/ironic-api.log
sudo journalctl -u ironic-conductor &> ${LOG_LOCATION}/ironic-conductor.log
else
sudo cp /var/log/upstart/ironic-api.log ${LOG_LOCATION}/
sudo cp /var/log/upstart/ironic-conductor.log ${LOG_LOCATION}/
fi
sudo chown $USER ${LOG_LOCATION}/ironic-api.log
sudo cp /var/log/upstart/ironic-conductor.log ${LOG_LOCATION}/
sudo chown $USER ${LOG_LOCATION}/ironic-conductor.log