============
Exploitation
============

Generals Principles
-------------------

Centreon-vmware is a Perl program in charged to get back VMWare indicators. This program uses the SDK Perl provided by VMWare in order to connect and get back the informations of one (or more) Virtual Center. To do this, it makes a TCP connection with the VirtualCenter.

By default "centreon-vmware" starts at least two processes (named "handle-client" and "handle-vsphere-xxxx") :

*« handle-client »*:
  *Process waiting for requests of clients.*

Steps of operation :

- A client connects.
- The client ask an monitoring indicator on a VirtualCenter.
- The process "handle-client" sends the request to process "handle-vsphere-xxxx".
- A response is sent by "handle-vsphere-xxxx" to "handle-client".
- The process "handle-client" sends the response to the client.

*« handle-vsphere-xxxx »*:
  *Process responsible to connect and to keep opened a session with the VirtualCenter. To ensure quality performance, a cache of datas description is created.*

Then, this process gets back the VMWare indicators creating a subprocess per request.

Centreon-vmware necessitates the utilization of one (or more) VirtualCenter (or ESX).
This is a example of a distributed architecture :

.. image:: ../images/archi.png

Operating mode
--------------

The "centreon-vmware" program only works in "daemon" mode (a client is needed).

Connector configuration
-----------------------

The « centreon-vmware » daemon is configured with the « centreon_vmware.pm » configuration file:
::
 
    %centreon_vmware_config = (
        vsphere_server => {
                        'default' => {'url' => 'https://vcenter/sdk',
                                     'username' => 'test@test.fr',
                                     'password' => 'xxxx'},
                        }
    );

« vsphere_server » attribute configures VirtualCenter access.
In case you have many VirtualCenters, the configuration is (note the use of "," as a separator):
::

    %centreon_vmware_config = (
        vsphere_server => {
                        'default' => {'url' => 'https://vcenter/sdk',
                                     'username' => 'test@test.fr',
                                     'password' => 'xxxx'},
                        'other' => {'url' => 'https://other_vcenter/sdk',
                                     'username' => 'test@test.fr',
                                     'password' => 'xxxx'},
                        },
    );

'other' and 'default' are containers name.

Client Usage
------------

Check vmtools states of virtual machines (with name matching the regexp 'prd'):
::

    $ perl centreon_plugins.pl --plugin=apps::vmware::connector::plugin  --custommode=connector --connector-hostname=127.0.0.1 --container=default --verbose --mode=tools-vm --display-description --vm-hostname='prd' --filter
    WARNING: 1 VM with VMTools not installed |
    vmtools not installed:
        prd-Reporting - 10.0.0.1 [description xxxx]

Check datastore IOPs of virtual machines (with name matching the regexp 'centreon-central-1|Formation'):
::

    $ perl centreon_plugins.pl --plugin=apps::vmware::connector::plugin  --custommode=connector --connector-hostname=127.0.0.1 --container=default --verbose --mode=datastore-vm --vm-hostname='centreon-central-1|Formation' --filter
    OK: All Datastore IOPS counters are ok | 'riops_Formation-Reporting - 10.30.2.89_R&D-BI'=0.00iops;;;0; 'wiops_Formation-Reporting - 10.30.2.89_R&D-BI'=1.43iops;;;0; 'riops_centreon-central-1_INTEGRATION'=0.00iops;;;0; 'wiops_centreon-central-1_INTEGRATION'=0.60iops;;;0;
    'Formation-Reporting - 10.30.2.89' read iops on 'R&D-BI' is 0.00
    'Formation-Reporting - 10.30.2.89' write iops on 'R&D-BI' is 1.43
    'centreon-central-1' read iops on 'INTEGRATION' is 0.00
    'centreon-central-1' write iops on 'INTEGRATION' is 0.60

Check the health of ESX Servers:
::

    $ perl centreon_plugins.pl --plugin=apps::vmware::connector::plugin  --custommode=connector --connector-hostname=127.0.0.1 --container=default --verbose --mode=health-host --esx-hostname='.*' --filter --disconnect-status='ok'
    OK: All ESX health checks are ok | 'problems_srvi-clus-esx-n2.merethis.net'=0;;;0;299 'problems_srvi-clus-esx-n1.merethis.net'=0;;;0;299 'problems_srvi-clus-esx-n4.merethis.net'=0;;;0;186 'problems_srvi-clus-esx-n3.merethis.net'=0;;;0;186
    Checking srvi-clus-esx-n2.merethis.net
    299 health checks are green
    Checking srvi-clus-esx-n1.merethis.net
    299 health checks are green
    Checking srvi-clus-esx-n4.merethis.net
    186 health checks are green
    Checking srvi-clus-esx-n3.merethis.net
    186 health checks are green

Troubleshooting
---------------

It is possible to get this kind of errors in the « logs » of « centreon-vmware »:
::

    ...SOAP request error - possibly a protocol issue: read failed: error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac...

VMWare Perl SDK sometimes generates this error that does not alter the behaviour of the connector. The bug comes from OpenSSL. It should be fix in OpenSSL 1.0.1h (CVE-2010-5298).

You can have the following error returns by the connector:
::

    # perl centreon_plugins.pl --plugin=apps::vmware::connector::plugin ...
    Cannot get value for counters...
    
Please check that your VirtualCenter and ESX time synchronization. Most of the time, the server with the connector and/or VirtualCenter/ESX are not well synchronized.
