Nagios – Monitoring our VMware vSphere VMs

In this document we will monitor interesting elements that we will obtain from our VMware vSphere-based virtual machines, centralizing in Nagios the checks we do to manage its values, Get alerts or generate graphs of your consumption. We will see, among other checks, in the VMs obtaining the values of their CPU Ready, CPU Wait, Memory Overhead, Memctl, Balloning, Write or read IOs…

 

Thanks to the 'check_vmware_api.pl script’ that we have already installed in a Previous document, we can now go ahead and monitor any parameter of a Virtual Machine, It doesn't matter which version we use, since installing the corresponding SDK will allow us to connect, whether vSphere 5.x or 6.x environments. Therefore, if you don't have the prerequisites installed, I recommend you read it!

 

[SourceCode]CPU – shows cpu info
+ usage – CPU usage in percentage
+ usagemhz – CPU usage in MHz
+ wait – CPU wait time in ms
+ ready – CPU ready time in ms

Mem – shows mem info
+ usage – mem usage in percentage
+ usagemb – mem usage in MB
+ swap – swap mem usage in MB
+ swapin – swapin mem usage in MB
+ swapout – swapout mem usage in MB
+ overhead – additional mem used by VM Server in MB
+ overall – overall mem used by VM Server in MB
+ active – active mem usage in MB
+ Memctl – mem used by VM memory control driver(vmmemctl) that controls ballooning

Net – shows net info
+ usage – overall network usage in KBps(Kilobytes per Second)
+ receive – receive in KBps(Kilobytes per Second)
+ send – send in KBps(Kilobytes per Second)
^ all net info(except usage and no thresholds)

io – shows disk I/O info
+ usage – overall disk usage in MB/s
+ read – read disk usage in MB/s
+ write – write disk usage in MB/s

Runtime – shows runtime info
+ with – connection state
+ CPU – allocated CPU in MHz
+ Mem – allocated mem in MB
+ state – virtual machine state (UP, DOWN, SUSPENDED)
+ status – overall object status (gray/green/red/yellow)
+ consoleconnections – console connections to VM
+ guest – guest OS status, needs VMware Tools
+ tools – VMware Tools status
+ issues – all issues for the host[/SourceCode]

These will be some of the Commands and Subcommands that we can pass to obtain the information that interests us about a VM, we can query a vCenter server or an ESXi host, followed by the name of the VM as seen from the vSphere Client. We can analyze any CPU parameter, Memory, Net, Disk or status of the VM. Something like this would work if we want to try to run it from shell:

[SourceCode]./check_vmware.api.pl -D DATA_CENTER | -H DIRECCION_IP_HOST_ESXi -N NOMBRE_MV -f FICHERO_AUTH -l COMMAND -s SUBCOMMAND -w WARNING -c CRITICAL[/SourceCode]

 

 

It will be enough to register the Command we need as always from Centreon, this will be a one-time time and then call you from each Monitoring Service we create. In this case I will directly attack an ESXi host so I will put its IP to pinrel, but everyone can configure this as they want, against a vCenter would be ideal. “Configuration” > Commands” > we doubled the 'check_vmware_api.pl’ that we have already created and we make a similar one to monitor the VMs. We complete at least:

  • Command Name: I'll call him 'check_vmware_api.pl_VM’ to know that with this Command we will monitor MVs.
  • Command Type: Select 'Check'.
  • Command Line: It will be what the Services we create will execute to monitor the items in the VMs. Something like the following would be useful where we will pass as arguments when creating the Service the Name of the VM, the Command, the Sub-Command, Warning and Value for Critical:

$USER1$/check_vmware_api.pl -H DIRECCION_IP_HOST_ESXi -N $ARG 1$ -f $USER 1$/check_vmware_api.auth -l $ARG 2$ -s $ARG 3$ -w $ARG 4$ -c $ARG 5$

 

We record with “Save”,

 

And nothing! It will be as simple as creating as many Services as we need, since “Configuration” > “Services”. In this case I will create the associated Services from Relations to each VM, I'll select the Command we just created from the combo, being 'check_vmware_api.pl_VM', and we will complete the arguments, indicating the name of the VM to be consulted, the command that in this type 'cpu’ and with the Subomando 'ready’ He will give us that, the CPU Ready time that the VM has, in addition to indicating the values to alert us of Warning and Critical (in this case it's milliseconds).

 

And nothing, if we record and export the settings as we already know, we will be able to return to the Monitoring view and see the values we are monitoring, in this case we see the CPU Ready or CPU Wait times, as well as the throughput of writing or reading in MB/s, as well as if the VC has used Balloning or Swap that we know are elements that will indicate that the VC is suffering. And it is interesting to know the VMware level status of the virtual machine as well as the status of the VMware Tools!!! Enjoy!

 

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!