Monitoring vSphere ESXi servers with Nagios and check_mk plugins. 3

Since 1.2.3i1 version, check_mk include a very interesting plugin to check vSphere ESXi servers. We can read documentation about this fantastic plugin in official check_mk page.

Check_mk vSphere plugin allow to access ESXi data directly from ESXi servers or via vCenter.

Let’s see how to do the configuration of the vSphere ESXi, and vCenter servers check_mk plugin.

Create user and profile in ESXi server and/or vCenter.

Fist of all we must create a user and a role with appropriate permissions. It is very important to use the necessary permissions only. We will explain the steps necessary to create users in vCenter and / or ESXi servers.

You must create a local user on the ESXi. This is done by connecting directly with viClient against ESXi (this can probably also be done with scripts). This step is only for ESXi servers. Vcenter use users from local system or a directory as Active Directory.

We will create the local user (tab “Local Users & Groups”), e.g., “nagios”:


We must create e.g. the Role “Monitoring” from Menu / Home / Roles / Add Role (mark only within Section “Host” the “CIM” option. This step is identical for both the ESXi server and the vCenter.


We assign the Monitor role to Nagios user. In the “Permissions” tab, right-click “Add permission”, select “nagios” user and “Monitoring” role. This step is identical for both the ESXi host to the vCenter.


In this way we have created our user with access only to the properties of servers accessible by CIM.

Prerequisites in Nagios / check_mk server to run vSphere CMK plugin.

To work CMK vSphere specific plugin only demands a prerequisite. You need to first install “pysphere-0.1.7” (Python API for interaction With the vSphere Web Services SDK). º

It seems necessary only to connect with vCenter but not to connect directly with ESXi servers. In a Centos with EPEL repositories configured would be as simple as:

yum install python-pip.noarch
easy_install -U pysphere

Of course.Yo need a running install of Nagios + Check_mk. This post can be interesting about this.


Testing plugin.

Before configuring checks in CMK we can test the plugin in command line to verify that it works and return data. Normally, the binary “agent_vsphere” will be in the location: /usr/share/ check_mk/agents/special. Examples for our “nagios” user password “PASSWORD”:

Against vCenter (if we created the user in vCenter)

./agent_vsphere -u 'nagios' -s 'PASSWORD' -i hostsystem --hostname '' --timeout 5

Against a Esxi server (user having previously created on ESXi as indicated)

./agent_vsphere -u 'nagios' -s 'PASSWORD' -i hostsystem,datastore,counters --direct --timeout 5

With -i option we define the options to inventory different information (hostsystem, virtualmachine, datastore, counters). We can get info about virtual machines too.

Objects configuration in Check_mk.

The configuration can be done in CMK graphical interface WATO or directly in configuration files as in our case. CMK use special agents config for this plugin.

The following definition applies to to hosts that have the tag “esxi”. It use user “nagios” and the password “PASSWORD” and get next information (hostsystems, datastore, counters, …)

"/usr/share/check_mk/agents/special/agent_vsphere -u 'nagios' -s 'PASSWORD' "
"-i hostsystem,datastore,counters --direct "
"--hostname '<HOST>' --timeout 5 <IP>", ["esxi"], ALL_HOSTS 

Esxi Hosts defined objects must have an identification tag “esxi” in the form:

all_hosts += [

Finally you only need to scan your ESXi hosts from CMK and restart it. As always with:

cmk -I hostname


This article is a translation of the original in spanish:


Leave a comment

Your email address will not be published. Required fields are marked *


3 thoughts on “Monitoring vSphere ESXi servers with Nagios and check_mk plugins.

  • Matthias

    There is an error in your code! You missed the “” and “” flags () in the code for “datasource_programs.append”. They are exists on the spanish site. Should read:

    “–hostname ” –timeout 5 “

    • Matthias

      Ok, now I know why these flags are missing. They are interpreted as html tags, because they use < (less than sign) and > (greater than sign) … ;)

      Second try with html code for the special signs:

      There is an error in your code! You missed the “<HOST>” and “<IP>” flags () in the code for “datasource_programs.append”. They are exists on the spanish site. Should read:

      “–hostname “<HOST>” –timeout 5 “<IP>”“

      • distractedman1 Post author

        Problem source was in my english translated document in Libre Office :(
        Thanks a lot Mattias. :)