[content to come]
Last active
August 29, 2015 14:04
-
-
Save phillipkent/8a341836393b3665aeda to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#VDC API | |
#check-vm-state.sh : Display the state information about VMs in a VDC | |
. ticktick.sh | |
cloudmonkey set display json | |
DATA=`cloudmonkey list virtualmachines` | |
tickParse "$DATA" | |
echo | |
echo -e "Checking states of ``count`` VMs by cloudmonkey at $(date -u) :" | |
for ((i=0; i<``count``; i++)) | |
{ | |
index=`printf "%012d" "$i"` | |
varread="__tick_data_virtualmachine_${index}_name"; | |
eval vmname=\$$varread | |
varread2="__tick_data_virtualmachine_${index}_state"; | |
eval vmstate=\$$varread2 | |
if [ $vmstate = "Running" ] | |
then | |
printf " \e[32m %s\e[0m\n" $vmname | |
elif [ $vmstate = "Stopped" ] | |
then | |
printf " \e[31m %s (%s)\e[0m\n" $vmname $vmstate | |
else | |
printf " \e[36m %s (%s)\e[0m\n" $vmname $vmstate | |
fi | |
} | |
echo "--VM check complete--" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment