VMware vSphere CLI tips & tricks with vPoller

As a sysadmin I often have the need to get information about an
environment quickly and efficiently. I am sure that most of the
fellow sysadmins out there also automate their daily tasks in some
form of scripts and tools, which make their life easier.

In this post I will share with you some of the CLI tools I use in
order to automate stuff when working in a VMware vSphere
environment. Over time they’ve proven to be invaluable to me and saved
me a lot of time, so hopefully it will do the same for you.

So, without further ado let’s see some VMware vSphere CLI tips &
tricks, which hopefully will find it’s place in your sysadmin toolkit
:)

Whetting your appetite

Let’s first see the tools we are going to talk about in this post.

As you can see from the above screenshot we have a pretty decent
number of vSphere CLI tools which we can use. Now let’s see some of
them in action.

Getting ‘about’ information from a vSphere host

This is how you could get the vSphere version and build numbers from a
vSphere host from the command-line:

Wait, we can even request more info if we ask to:

Pretty useful, isn’t it? :)

Discovering objects in our vSphere environment

Let’s now see how we can discover various objects from our VMware
vSphere environment.

This is how we can discover all datacenters for example:

What ESXi hosts do we have in our environment:

Okay, that’s good. We have one ESXi host in our environment, but what
is it’s power state?

What about our datastores?

Let’s see the datastore URLs as well:

As you can see we can virtually discover any vSphere managed object
in our environment. What we can also do is during discovery we can
request additional properties to be collected, which I think is pretty
neat.

Getting object properties from our vSphere environment

In the previous section we’ve seen how to discover various vSphere
objects, but what about getting properties for a single object? Is
that possible?

Sure, it is! :)

Let’s see what is the capacity and free space of our datastore1
datastore:

Okay, seems like our datastore is in good shape and is accessible.

Let’s see what is the amount of memory on our ESXi host and it’s
status:

Let’s see what disks do we have on a Virtual Machine:

And what is the capacity and free space of the /storage/db file
system: