From: Scott Baker Date: Sun, 8 Sep 2013 00:38:22 +0000 (-0700) Subject: check in openstack healthcheck tool X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=326249502d9884ea5717afff63b8a7caf60f6c2c;p=plstackapi.git check in openstack healthcheck tool --- diff --git a/planetstack/tools/openstack-healthcheck.py b/planetstack/tools/openstack-healthcheck.py new file mode 100755 index 0000000..7163c7c --- /dev/null +++ b/planetstack/tools/openstack-healthcheck.py @@ -0,0 +1,50 @@ +#! /usr/bin/python +import os +import sys +import subprocess +import time + +def get_systemd_status(service): + p=subprocess.Popen(["/bin/systemctl", "is-active", service], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (out, err) = p.communicate() + out = out.strip() + return out + +libvirt_enabled = os.system("systemctl -q is-enabled libvirtd.service")==0 +nova_compute_enabled = os.system("systemctl -q is-enabled openstack-nova-compute.service")==0 +openvswitch_agent_enabled = os.system("systemctl -q is-enabled quantum-openvswitch-agent.service")==0 + +print "enabled:" +print " libvirtd=", libvirt_enabled +print " openstack-nova-compute=", nova_compute_enabled +print " quantum-openvswitch-agent=", openvswitch_agent_enabled + +if (not libvirt_enabled) or (not nova_compute_enabled) or (not openvswitch_agent_enabled): + print "services are not enabled. exiting" + sys.exit(0) + +libvirt_status = get_systemd_status("libvirtd.service") +nova_compute_status = get_systemd_status("openstack-nova-compute.service") +openvswitch_agent_status = get_systemd_status("quantum-openvswitch-agent.service") + +print "status:" +print " libvirtd=", libvirt_status +print " openstack-nova-compute=", nova_compute_status +print " quantum-openvswitch-agent=", openvswitch_agent_status + +if (libvirt_status=="failed") or (nova_compute_status=="failed") or (openvswitch_agent_status=="failed"): + print "services have failed. doing the big restart" + os.system("systemctl stop openstack-nova-compute.service") + os.system("systemctl stop quantum-openvswitch-agent.service") + os.system("systemctl stop libvirtd.service") + time.sleep(5) + os.system("systemctl start libvirtd.service") + time.sleep(5) + os.system("systemctl start quantum-openvswitch-agent.service") + time.sleep(5) + os.system("systemctl start openstack-nova-compute.service") + print "done" + + + +