Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Created August 2, 2015 19:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpluimers/e2cd44ed996639ffa97d to your computer and use it in GitHub Desktop.
Save jpluimers/e2cd44ed996639ffa97d to your computer and use it in GitHub Desktop.
#!/bin/sh
VMS=`vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1}'`
for VM in $VMS ; do
# echo "Probing VM with id: $VM."
PWR=`vim-cmd vmsvc/power.getstate $VM | grep -v "Retrieved runtime info"`
name=`vim-cmd vmsvc/get.config $VM | grep -i "name =" | awk '{print $3}' | head -1 | awk -F'"' '{print $2}'`
echo "VM with id $VM has power state $PWR (name = $name)."
done
@zengyijian916
Copy link

Hi, can you update for just show the power on VMs, not all. Many Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment