#!/bin/bash source /etc/kolla/admin-openrc.sh EXIT_CODE=0 # search for server with status ERROR OUTPUT="$(openstack server list --all --status=ERROR -c ID -c Name -c Status -f value)" #openstack server show ${SERVER_ID} -c fault -f value if [ -n "${OUTPUT}" ]; then echo "${OUTPUT}" EXIT_CODE=1 fi # search for server with status VERIFY_RESIZE OUTPUT="$(openstack server list --all --status=VERIFY_RESIZE -c ID -c Name -c Status -f value)" if [ -n "${OUTPUT}" ]; then echo "${OUTPUT}" EXIT_CODE=1 fi # search for server processes on wrong compute node for COMPUTE_NODE in $(openstack compute service list --service nova-compute -c Host -f value); do for SERVER_ID in $(ssh ${COMPUTE_NODE} pgrep qemu -a | grep -o -P '(?<=-uuid ).*(?= -smbios)'); do VM_HOST=$(openstack server show -c "OS-EXT-SRV-ATTR:host" -f value ${SERVER_ID}) if [ -n "${VM_HOST}" ]; then if [ "${VM_HOST}" != "${COMPUTE_NODE}" ]; then echo "VM ${SERVER_ID} on wrong compute node ${COMPUTE_NODE}" openstack server show ${SERVER_ID} -c OS-EXT-SRV-ATTR:hostname -c name -c id -c status -c OS-EXT-SRV-ATTR:instance_name EXIT_CODE=1 fi else echo "Server process ${SERVER_ID} on ${COMPUTE_NODE} not available in OpenStack" EXIT_CODE=1 fi done done # send notification echo exit ${EXIT_CODE}