vSphere Infrastructure Navigator or VIN for short is a really useful tool that helps you map out and visualize application services and dependencies between your virtual machines. This is extremely helpful when trying to identify what applications or ports a given virtual machine is running and how it is related or dependent on other virtual machines within your virtual infrastructure.
One thing that I found lacking in VIN today is the ability to export or extract some of this useful information for external use such as a CMDB (Configuration Management Database) as one potential use case. This would allow users to always have an up-to-date CMDB that does not rely on a manual process of adding CI (Configuration Items) and services to your CMDB which can potentially lead to incorrect or more importantly, out of date information (I have seen this happen in the past as an System Admin).
While deploying the latest release of VIN 1.2 in my home lab, I decided to poke around in the VIN appliance and I noticed a web application called Jolokia (not the hot pepper) that was running. After a quick Google, I came across this Jolokia tutorial and with some trial and error, I was able to validate the steps against VIN and was able to access the data VIN was discovering about the virtual machines.
In part 1 of this article, I will show how to get setup and start exploring the data VIN is collecting and in part 2, I will provide a sample script which can be used to automate the extraction of some of this data found in VIN. In the example below, I will be leveraging the vMA appliance, you could use another system that can install the Jolokia client packages, please refer to tutorial for more details.
Disclaimer: This is not officially supported by VMware, use at your own risk.
VIN Appliance Setup:
Before we begin, we need to configure a few things on the VIN appliance which will allow us to connect remotely which is disabled by default.
Step 1 - Edit the following configuration file /opt/vadm-engine/webapps/jolokia/WEB-INF/classes/jolokia-access.xml and specify the remote IP Address you wish to connect to VIN from. By default, VIN is configured to only allow connections from localhost (127.0.0.1).
Step 2 - Run the following script called /opt/vadm-engine/bin/disable_security.sh which disables some of the security configurations such as firewalls, JMX security, etc. which is required to connect to Jolokia interface remotely.
Step 3 - Finally, for the changes to go into effect, you will need to restart the VIN discovery engine by running the following command: /etc/init.d/vadm-engine restart
Step 4 - To verify the configuration above, go ahead and login to the remote host of the IP Address that you added to the jolokia-access.xml file and perform the following curl command: curl http://[VIN_IP_ADDRESS]:8080/jolokia and you should get back a reply which confirms you can communicate with the Jolokia service on your VIN host remotely.
Note: You can also take the URL and paste that into a web browser and it should also respond with the same information. If you do use a browser, make sure you add the IP Address of the desktop that is running the browser to jolokia-access.xml file.
Installing Jmx4Perl on vMA:
Step 5 - To explore the data in VIN, we will be installing Jmx4Perl as noted in the Jolokia tutorial which includes an interactive utility called j4psh which will make it easier to view the information in VIN. You will need to install Jmx4Perl via CPAN or manually install the following Perl packages in this order:
Luckily, you do not need to manually do this as I wrote a quick shell script called setupJMX4PERL.sh which will download the packages above and install Jmx4Perl for you. All you need to do is just execute the script and then select "yes" when prompted.
Step 6 - Once Jmx4Perl has been installed, you should now have a utility called j4psh which we will use to connect to the Jolokia service running on your VIN appliance remotely from vMA. Run the following command: j4psh http://[VIN_IP_ADDRESS]:8080/jolokia
Note: This can take awhile, in my lab environment it took up to 10 minutes before it connected. Please be patient as it could take longer, I can only assume some amount of data is being cached on the client.
Once you have successfully connected, you should now have a prompt displaying the VIN address. There are multiple namespaces or MBeans and we will be looking at the com.vmware.vadm which is the VIN application. To change into this specific Mbean, run the following command: cd com.vmware.vadm as shown in the screenshot above. Once you have switched to VIN's MBean, you can then run the ls command, similar to UNIX/Linux ls (list) command. You can also just type help for all available commands.
What you see listed above in the screenshot are the different sub-MBeans that are available in the com.vmware.vadm Mbean and we will take a look at a few of these to show you how to navigate your way around.
Exploring VIN MBeans:
Note: Please be very careful when executing operations, I would highly recommend you do this in a lab environment to ensure you do not impact your VIN system.
The first MBean we will take a look at is name=inceptionConfigurationMBean,type=ConfigurationMBean and as you might have guessed from the name it is related to some type of configuration. Go ahead and cd into that Mbean and then type ls.
We can see from this Mbean, there are a bunch of attributes that we can access. To view an attribute, we just run the cat command and the name of the attribute. In this example, I am checking the value of vc.credentials.host which should contain the address of the vCenter Server that the VIN Server is currently registered with. Before proceeding to the next Mbean, you will need to cd back out to main MBean, to do so, just type cd .. as you would on a UNIX/Linux machine to change to previous directory.
The next Mean we will take a look at is name=vcInventory,type=VcConnector and as you might have guess this is dealing with the vCenter inventory. Go ahead and cd to this Mbean and type ls.
For this Mbean, when we perform the list command, we are only shown operations or methods for this Mbean. The operations shown on the left will display the required parameters and we can see they all require a string input except for the getAllVms() so let's go ahead and execute that and see what happens (of course we can probably guess, a list of all VMs will be displayed). To execute an operation, you will need to run the exec command, go ahead and run the following command: exec getAllVms as shown in the screenshot above. As you can see from the screenshot, we are listing all VMs that have been discovered by VIN including a nice summary of each virtual machine.
Let's go ahead and run through two additional operations that accept parameters such as getVmByName and getVmByIp. You will use the exec command but now you will need specify an additional parameter based on the operation. The screenshot below demonstrates calling both of these operations and specifying the appropriate input parameter:
The next two operations will be located in the same Mbean which deals with the application services found on each VM as well as any external VM dependencies. The first operation is name=ApplicationService,type=ApplicationService and we will be looking specifically at the findApplicationComponentsByInfrastructureElemenBusinessKeys operation which accepts the MoRef Id of the VM in question which must be in JSON format (this took me awhile to figure out). From the previous operations above, you will need a MoRef Id of a VM you are interested in seeing what application services are running and run the following command: exec findInfrastructureElementsByBusinessKeys '[{"moid":"vm-232"}]' and be sure to replace the MoRef Id with your own.
As you can see from the output, it contains quite a bit of information including the three services this VM is running and one of these services is vCenter Operations. If you hop over to the vSphere Web Client and find this VM, you should see the same set of services listed.
The second operation that we will take a look at is called findOutgoingDependentInfrastructureElements and it also accepts MoRef Id as input and noticed the help option shows it requiring a single entry as well as an array entry of the MoRef Id, again in JSON format. To view the dependency of this VM to other VMs in your virtual infrastructure, run the following command: exec findOutgoingDependentInfrastructureElements '{"moid":"vm-385"}' '[{"moid":"vm-385"}]' and be sure to replace the MoRef Id with your own.
From the output, you can see the VM's that are depended on by this VM as well as other information.
I have not explored all the Mbeans and operations, but I highly encourage you to browse around and see what you can find. Just be careful when executing operations that you are performing READ operations and not WRITE operations as you can impact your VIN system. In part 2 of this article, I will show you how to easily export some of this useful information found in VIN using a simple script.
Justin Turver says
Nice - I was looking at a way to automate membership in VM DRS groups based on installed application/service, or VIN application definition. Personally I found it simpler to disable security (as per your post) and then use a remote psql connection (e.g. via Powershell or perl) to query relevant tables in the inception DB e.g. "select business_key from application_component where business_key like '%SQL%';". Am also using this to automate membership in various monitoring dashboards outside of vCOPs. Thanks again!
wsellers says
Do you have any notes on connecting to the psql dB? 🙂 --- I'm looking to pull the same info you are.... THANKS!
wsellers says
wsellers at gmail dot com
wsellers says
@Justin Turver ---- Do you have any notes on connecting to the psql dB? 🙂