Some simple example for checking Openstack services

  • check nova service list

#!/bin/sh
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=******
export OS_AUTH_URL=http://controller:35357/v3
export OS_IMAGE_API_VERSION=2
export OS_VOLUME_API_VERSION=2 data=$(nova service-list 2>&1)
rv=$? if [ "$rv" != "0" ] ; then
echo $data
exit $rv
fi #echo "$data" | grep "up" | wc -l
num=`echo "$data" | grep "up" | wc -l` if [ $num -lt 5 ]; then
exit $STATE_CRITICAL
fi echo "Must have 5 service components"
exit $STATE_OK
  • check neutron agent list
#!/bin/sh
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=bhu890-=
export OS_AUTH_URL=http://controller:35357/v3
export OS_IMAGE_API_VERSION=2
export OS_VOLUME_API_VERSION=2 data=$(neutron agent-list 2>&1)
rv=$? if [ "$rv" != "0" ] ; then
echo $data
exit $rv
fi #echo "$data" | grep "up" | wc -l
num=`echo "$data" | grep "True" | wc -l` if [ $num -lt 5 ]; then
exit $STATE_CRITICAL
fi echo "Must have 5 neutron agents"
exit $STATE_OK
05-11 17:51