There have been posts in the past about monitoring ESXi hosts / clusters / and VMs from Cacti, but none have been extremely exhaustive and inclusive. The one post linked to a website that was in french and I couldn't understand the flow to get those scripts to work, and many were built for ESX 3 or Nagios.
This community has been a wealth of resources in the past for me so I thought I would share my work here for others as well, and maybe someone could help me tweak it to be even better.
I’m afraid I don’t know much about exporting templates, so I’ve just uploaded the scripts themselves and outlines a few steps to get them to work here in this post.
The VMware Vi Perl SDK 5 with all installed CPAN modules is required. I have Cacti installed on a linux system, so if you’re running Windows you will have to adapt portions of this.
Create a new data input method of type “Script/Command”. Use the following for the “Input String” (Adapt for your environment accordingly):
/usr/bin/perl <path_cacti>/scripts/esxistats_mem.pl --url https://<vcenter>/sdk/webService --username <username> --password <password> --esxiname '<esxiname>'
Add the following Input Fields:
Code: Select all
Name Field Order Friendly Name
vcenter 1 vCenter FQDN or IP Address
username 2 Username to login to vCenter
password 3 Password to login to vCenter
esxiname 4 Name of the ESXi host as it appears in vCenter
I have a couple of issues however. For the user account that accesses vCenter we use Active Directory. I created a new service account in AD and granted it read only permission for use in these scripts. In order to get the script to work I have to put the username in the format “DOMAIN\USERNAME”. Whenever I create a new graph Cacti will drop the slash and in the poller cache it will appear as just “DOMAINUSERNAME”. I have tried adding two slashes but the result is the same. Any suggestions?
Also, the Perl SDK execution is painfully slow. Prior to adding these in my poller runtime was just above 30 seconds (see below graph for runtime):
Now I am hovering around 200 seconds. Does anyone have any Perl script knowledge they can use to help me cut down on execution time? Part of it is the SDK with finding the actual objects and populating the views, which I have cut down on by limiting what properties are pulled from vCenter, but the execution is still too long for my liking.
Hope people find this useful, and if anyone has any suggestions on how to improve the scripts please let me know!! Eventually I would like to add the ability to graph Cluster resources, but I will need to get a better understanding of the Perl SDK first
Here are some screenshots:
Datastore Usage
ESXi CPU and Memory
VM CPU and Memory
Config Screenshots