vMetrics – Plugin for WordPress

January 20th, 2013 Leave a comment Go to comments

vMetrics for WordPress


Display metrics from your VMware vCenter Cluster or ESX hosts / lab on your WordPress blog. Works with vSphere 4, 5 and 5.1.


Recently I have been looking for a small pet project to complete in bits of spare time, and have been wanting to do something that integrates with WordPress, yet relates to VMware. For quite some time now I have been using Nicholas Weaver’s (@lynxbat) excellent WP-vSphereStats plugin for WordPress on my blog. This displays some stats from your vCenter server or a ESX host as a widget on your blog.


I thought it would be an awesome little side project to revamp what he has done on the WordPress side (the actual plugin/widget) and create a new updater utility that is more flexible and customisable. In addition to this, I am also adding a bunch of new metrics some of which include HA and DRS statistics. The result of all this work is vMetrics for WordPress!

vMetrics is a small plugin for WordPress that works in conjunction with a PowerCLI Updater Script. You install the plugin, add the Widget to your sidebar in WordPress, configure which stats you would like to show, then run, or schedule the PowerCLI script against a standalong ESX/ESXi host, or vCenter server. This is much the same way that Nicholas’ utility works, but is now in PowerCLI format instead of an executable cmd line utility. This means it is very customisable, allowing you to modify the PowerCLI script and change which metrics come back. You could even modify the PHP plugin on WordPress’ side to allow any other metrics not already catered for in my release to show through on your own blog. Kudos to Nick for his excellent work – I couldn’t have done vMetrics without hacking apart and using a lot of his PHP code that he used to create his WP-vSphereStats WordPress plugin.


In addition to re-creating a new WordPress plugin and developing the PowerCLI Collector script, Β I have also designed some original icons relating to different VMware vSphere objects – Clusters, Hosts, VMs, CPU, RAM, NIC etc… I’ll post these up as high-res icons for download in a separate blog post. So without further ado, here are the WordPress plugin downloads:


Latest version:

Download vMetrics Plugin for Wordpress 1.1 (1061)
Download vMetrics PowerCLI Updater script 1.1 (1048)

Change log for version 1.1:

  • Added new metrics section for hardware information (Model and Vendor of first host in cluster – this is editable in the PowerCLI script)
  • Added configurable widget title section for Hardware
  • Updated PowerCLI updater script to have a DO WHILE loop (allowing you to run the script once on a management machine and it will keep updating your blog vMetrics every 30 minutes. (The script is called once every half hour). Thanks @dawoo for the idea πŸ™‚
  • Added PowerCLI section to send the vendor and model type of the first ESX host it finds back to vMetrics so that you can display this information in the widget too
  • Cleaned up PHP in main plugin code


Previous versions

Download vMetrics Plugin for Wordpress 1.0 (786)
Download vMetrics PowerCLI Updater script 1.0 (835)


WordPress Plugin Setup


  • Download both files listed above.
  • Extract the Plugin into your WordPress plugins directory. It should be named “vmetrics-plugin
  • Alternatively you can also upload the plugin .zip file using “Add new” from your plugins page in WordPress. If you get a “header error” when activating the plugin, just go direct to the plugins page and click “Activate” on the vMetrics plugin in that list – it should work via this method if the automatic activation after install doesn’t work.
  • Login to WordPress, navigate over to Plugins, then “Activate” the vMetrics Plugin
  • Go to Appearance -> Widgets in your admin page. Drag and drop the vMetrics Widget over to the relevant sidebar area you wish to display it on.
  • Customise the Widget to your liking – you can change which sets of metrics about your vSphere environment are displayed, and which are not. Tick all the options you want to display, the click “Save
  • If you look in your admin left sidebar area, you will now notice a new entry called vMetrics Plugin – this has both main page and settings page sub menus. Select the Settings page.
  • You will need to generate a “security key” that the PowerCLI updater script will use to validate itself with your WordPress plugin when it tries to connect and send the vMetric data back to WordPress.
    • Generate a key, wait a few seconds for the page to refresh, then copy the key down into notepad for now.

Example configuration of Widget in sidebar


PowerCLI Script setup


  • Go to the workstation or vCenter server you wish to use to run the updater script. As long as you have PowerCLI installed and you are able to connect to your Host or vCenter from here, it will do fine.
  • Copy the script over, and make sure it is not “blocked” (right click, properties, make sure “Unblock” has been done on the .ps1 file).
  • Open the PowerCLI Script with notepad or your favourite PowerShell editor and update the very top section labelled “Customisable Variables“. This is the only bit of the script you need to change. You will need to enter your own blog and connection details as per the examples below:
    • $WordpressURL -> Your WordPress blog URL and wordpress install. Enter exactly as it is, with no trailing slashes. For example: http://www.shogan.co.uk
    • $vCenter ->Β vCenter or ESX(i) host IP address or FQDN that the script will connect to, to fetch stats.
    • $User -> your username to connect to host or vCenter
    • $Pass -> your password
    • [string]$ClusterToDisplay -> the exact name of the Cluster (if you have one) that you want to fetch metrics for. (Enter exactly as it appears in vCenter).
    • [string]$authkey -> paste your security key you generated from the WordPress plugin here, exactly as it is, between the quotes.
    • Save the PowerCLI script
    • Example configuration of the script:


#region Customisable Variables
$WordpressURL = "http://www.mytechblogname.com"
# Use the $vCenter variable for the ESX(i) Host address if you are only using one Host (otherwise use it for your vCenter server address).
$vCenter = ""
$Username = "administrator"
$Pass = "MySecurePass"
# Only specify ClusterToDisplay if applicable - remember to deselect cluster
# options such as DRS and HA in the WP Widget options if you are only using one host
[string]$ClusterToDisplay = "MyMainClusterToGetStatsOn"
[string]$authKey = "ddGeHucQLi3tD0LmgEGJ9IuCwfkoz5qn5zVokLC1Gu" #Make sure you enter this correctly - get the key from the plugin settings page!


Run the PowerCLI Script


  • Open a PowerCLI console and make sure you are not already connected to any other hosts or vCenter servers (Disconnect-VIServer *)
  • Navigate to folder containing your updater script
  • Execute the script. Example .\vMetrics-Update.ps1
  • All going well the script will connect to your vCenter/Host and collect various bits of information. It will then send this along to your plugin and update the metrics displayed on your blog.
    • The script does not transmit your vCenter / ESX passwords!
    • Remember you can also select which metrics are displayed in the widget settings.
    • You can also schedule the script to run at a specific interval if you want – just use Windows Task Scheduler.

Example usage of the PowerCLI Updater script


If you have any feedback, or have any issues please drop a comment below. I would also be interested to see how you customise your vMetrics stats or how you are using it on your own blog, so please do leave a comment below!


  1. September 6th, 2012 at 16:45 | #1

    Nice work Sean! I was running Nick’s version for quite a while but I seem to rebuild my vCenter server frequently enough that I always forget to hook it back in afterwards. Looking at the stats on your blog you have a lab to be envious of!

  2. September 6th, 2012 at 17:34 | #2

    Hey Ed,

    Thanks! That is a problem – hooking all the little utilities and extensions back into vCenter after a lab rebuild πŸ™‚ I am lucky to have the lab environment to the right – it is a work based though, so my actual home lab is a little more modest!


  3. Joshua
    October 24th, 2012 at 04:57 | #3


    Your backup utility was amazing!!!!! Thanks for all your hard work. I am having an issue getting this plugin to show up in wordpress. It’s in my plugins directory in a folder called vmetrics-plugin. I changed permissions but wordpress still doesn’t see it. Any suggestions? Thanks again!

  4. October 24th, 2012 at 09:14 | #4

    Hey Joshua,

    What version of WordPress are you running? I have it tested on WordPress 3.4.1 at the moment… So under your plugins -> installed plugins section you don’t see it appearing there at all? Thanks for comment otherwise!


  5. Joshua
    October 28th, 2012 at 22:37 | #5


    Currently I’m running 3.4.2 so that could be part of the issue. Yup when I go to that location all I see is the akismet plugin which is in the same directory I placed the vmetrics-plugin folder. The permissions on the folder/files are 744 like the akismet plugin so I don’t believe that would be an issue. Thanks again for the help!

  6. October 29th, 2012 at 19:33 | #6

    Hey Josh,

    I just tested on WP 3.4.2 and can report it works fine for me. Very odd – so is the plugin currently sitting in your /wp-content/plugins directory? the full structure should therefore be blog.xyz/wp-content/plugins/vmetrics-plugin.

    In this directory, you should then have the vmetrics-plugin.php file and two folders: images and classes. I have the following permissions set on mine: vmetrics-plugin directory: 0755. vmetrics-plugin.php: 0644, images and classes directories: 0755. All files within the classes and images directories have permissions set at 0644. Perhaps try with those permissions and see if that works?


  7. Joshua
    October 31st, 2012 at 04:57 | #7


    Yea that is how I have it configured. I verified my permissions and I still see nothing on the plugins screen. I even renamed the akismet plugin in the directory for a test and that one disappeared from my installed plugin list, so it appears to be in the correct location. You can browse here and see the files look to be in the correct location, http://jfechter.com/wordpress/wp-content/plugins/. I’m still stumped by this issue. I tried various permissions but still nothing.


  8. November 2nd, 2012 at 10:53 | #8

    Hi Josh,

    Sent you an e-mail with another copy of the plugin to try out!


  9. Joshua
    November 4th, 2012 at 17:17 | #9

    Hey Sean,

    Figured it out! As I’ve come to realize in the tech field it’s always the simplest solution. I forgot I had a symlink to /var/www which is where I was adding the plugin. I was supposed to be placing it in /usr/share/wordpress/wp-content/plugin. Now it’s finally working! Hopefully this helps someone else so they realize the solution is extremely simple. If you want to check it out go to http://mrfechter.com/?page_id=5.

    Also one other thing that I spent a bit of time getting to work. When your using powercli to login and you type the username and pass in the command line window you need to escape special characters. I had a $ in my password and it kept erroring out. So after some searching on the web it turns out you need to escape special characters.


    $Pass=my3xampl$pa$$ (this will error out and say incorect login details)
    $Pass=my3xampl`$pa`$`$ (this one will word correctly)

    Thanks again for the help! The plugin works great!


  10. November 5th, 2012 at 16:32 | #10

    Hi Josh,

    Excellent! Glad you got it sorted, and too true πŸ™‚ Your site is looking nice and clean, and the widget seems to fit in nicely! Nice one πŸ™‚


  11. January 2nd, 2013 at 22:57 | #11

    Hi Sean;

    Found your blog while looking for Microserver stuff. Have posted your vMetrics WP Plugin to our Microserver followers.


  12. January 3rd, 2013 at 00:29 | #12

    Hi Joel,

    That is awesome – thanks for the link back, I see your Microserver page – great initiative!


  13. March 4th, 2013 at 13:09 | #13

    I have edited the script in nano
    and run it with the following command ./vMetrics-updater.ps1
    was given error ./vMetrics-updater.ps1: line 1: syntax error: unexpected newline
    in what may be the problem?

  14. March 4th, 2013 at 13:32 | #14

    Hi Nikita,

    The issue is that this is a PowerShell (PowerCLI script), so you won’t be able to execute it under bash. You need PowerShell and PowerCLI to be installed (Windows). You can grab it from here: http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli


  15. April 2nd, 2014 at 19:29 | #15


    Love the plugin…

    I’ve hopefully got a quick question.

    I managed to get it working without any problems until I decided to point at a single host rather than a cluster. It’s now display the data from the cluster and the single host with the data added together. As much as I like it saying I’ve got twice the resources I really have I’d like it to show the correct data. πŸ™‚

    I’ve tried deleting the plugin and reinstalling it but I’m assuming the plugin data is stored in the wordpress database as it didn’t change… I did have a quick look to see if I could find it but I couldn’t πŸ™

    Any advice?


  16. April 2nd, 2014 at 21:23 | #16

    Hi James,

    Thanks for the comment and feedback πŸ™‚

    You are correct, stats are indeed recorded in your WordPress MySQL DB. Check the wp_options table and you’ll find them all as vmetric_xxxx.

    I’ll check out the PowerCLI script if I get a chance at some point in the future, but my guess is that it is not handling the addition of figures correctly when looking at a single host. Thanks for pointing that out. If you do manage to fix the actual script itself, feel free to pastebin it and drop a link here in the comments for others to use πŸ™‚

    Hope that helps…


  17. April 2nd, 2014 at 22:37 | #17

    Hi Sean,

    Yes it does help, thanks for the quick reply btw πŸ™‚

    Somehow I’ve managed to fix it thanks to you pointing me in the right area in the database, and I didn’t destroy the database which is a bonus…

    There is very little chance I’ll be able to fix it… I’m not a coder and my powershell, php and MySQL skills are very very limited… However I do like a challenge and I will have a look and post my results if I get anywhere.

    Thanks Again πŸ™‚

  18. April 3rd, 2014 at 09:37 | #18

    No problem πŸ™‚

    Well done on fixing the values in the DB. Don’t stress about the PowerCLI script – if I ever get a free day I’ll take a look myself!

  19. September 3rd, 2014 at 00:31 | #19

    Hi Sean,

    Awesome work on the plugin, I have it installed and working great. One thing that would be nice is support for multiple vCenters/Clusters. I have more than one cluster in my home lab and change things up pretty often.

    Thanks again for a fun way to view my lab stats!

  20. September 3rd, 2014 at 01:02 | #20

    Thanks Mark πŸ™‚ If I do get around to updating the plugin I’ll definitely look to add that support. Thanks for the message!


  21. September 4th, 2014 at 20:16 | #21

    Hey Sean,

    Amazing plugin, i’ve been a huge fan since i first saw it running over at http://www.thehomeserverblog.com and i’ve wanted to integrate it onto a website ever since.

    I’m working on a “homelab” blog – nothing crazy, and got your plugin setup on it.

    The first run goes off without a hitch, but as it goes through and attempts to do metrics updates i start getting the following error…

    Cannot convert the “System.Net.HttpWebRequest” value of type “System.Net.HttpWebRequest” to type “System.Web.HttpRequest”. At mydirectoryobscured\vMetrics-updater\vMetrics-updater.ps1:161 char:2″

    Any thoughts?

  22. September 4th, 2014 at 21:31 | #22

    Hi Cody,

    Could you send the exact script you have along to me – link it as a dropbox download or something like that? Also, how are you executing or running the script to update the vMetric stats? I’ll see if I can reproduce the error myself and fix.


  23. September 4th, 2014 at 21:31 | #23

    Oh, and thanks for the kind words! πŸ˜€

  24. September 4th, 2014 at 22:31 | #24

    Actually, its kind of odd…its throwing that error message – but still uploading all the data.

    I’m running PowerCLI on Windows 8.1
    My VCenter environment is 5.5
    The dropbox link is – https://dl.dropboxusercontent.com/u/54999317/vMetrics-updater.ps1

    Obviously since its actually working – its not a big deal if you “fix” it or not. But maybe its something easy!

  25. September 4th, 2014 at 22:46 | #25


    Ah, I actually know what you mean now – that’s something I’ve seen happening and never bothered to fix. I need to handle the error with a try/catch perhaps. Thanks for pointing it out though! πŸ™‚


  26. September 5th, 2014 at 03:52 | #26

    Thanks Sean, Once i finish the setup of my blog – mind if I throw a linkback your way? Always like to ask permission before throwing links out to peoples pages (whenever possible…)

    It’s VERY much not anywhere near done yet – http://www.thehumblelab.com

  27. September 5th, 2014 at 09:01 | #27


    Not at all πŸ™‚ That would be much appreciated! I had a quick look at your site last night and must say the plugin looks great with that theme of yours! Best of luck with your blog : )

  28. September 8th, 2014 at 00:09 | #28


    I threw up a shoutout post for you with linkback – http://www.thehumblelab.com/?p=33

    Thanks again!


  29. September 8th, 2014 at 00:11 | #29

    Hey Cody,

    Many thanks! Glad to see your lab is up and running nicely! Come to think of it, I need to get my updater script rolling again – It stopped last time I moved house…


  30. Dan
    October 22nd, 2014 at 13:28 | #30

    Great script and worked first time.

    Is there anyway to monitor two seperate Vsphere ESXi boxes that are not linked and show them in seperate widgets? I assume if I run the script on both it would use the same key and mess up the stats?

    Also is there a easy way to collect the power status of a particular vm image? I.E I have a intranet with a list of servers on and I wanted to insert a nice icon status in a table next to each server name, so it collects separately for each and reports if that one is on, rather than all of the hosts.


  31. October 22nd, 2014 at 13:57 | #31

    Hey Dan,


    Unfortunately, there is no way to do that easily. Some development and modification of the plugin would be required (as well as the PowerCLI script). If you’re feeling confident with PHP you could give it a crack πŸ™‚ Of course, a single ESXi host would work on the current widget, but the power status is something you’d have to add a new field in for, and set up the plugin to handle (as well as create an entry in your wordpress DB that stores the value of the power status for the VM… all quite a lot to do!


  1. July 11th, 2012 at 22:53 | #1
  2. July 11th, 2012 at 23:11 | #2
  3. August 26th, 2012 at 12:09 | #3
  4. April 16th, 2013 at 03:18 | #4
  5. September 8th, 2014 at 00:03 | #5
  6. July 13th, 2015 at 20:11 | #6

ERROR: si-captcha.php plugin says GD image support not detected in PHP!

Contact your web host and ask them why GD image support is not enabled for PHP.

ERROR: si-captcha.php plugin says imagepng function not detected in PHP!

Contact your web host and ask them why imagepng function is not enabled for PHP.