WBEM/CIM check script on Zabbix

https://www.zabbix.com/forum/showthread.php?t=45186

Here is a python script to monitor hosts using WBEM/CIM over http/https. This can be useful to monitor VMWare ESXi hosts for example, where the vendor CIM provider is the preferred method for monitoring the hardware.

It requires pywbem & zabbix_sender to be installed, and has been tested with python 2.7, and Dell and HP hardware.
Here are the CLI options :

Code:
zbxcim.py [-v] <host> [-u <username>] [-p <password>] [-s <sender>] [-z <server>] [-P <port> ] [-H <protocol>]

Options:
  <host>                                                   The CIM/WBEM Provider host
  -u, --username <username>                                The connection username
                                                           [default: root]
  -p, --password <password>                                The connection password
                                                           [default: password]
  -v, --verbose                                            Verbose mode
  -s, --zabbix-sender <zabbix_sender>                      The path to the zabbix_sender binary
                                                           [default: /usr/bin/zabbix_sender]
  -z, --zabbix-server <server>                             The Zabbix server or proxy
                                                           [default: localhost]
  -P, --port <port>                                        The CIM/WBEM Provider port
  -H, --protocol <protocol>                                The WBEM URL protocol (http or https)
                                                           [default: https]

You can change the default user/password in the script if needed.

Here is how to call it :

Code:
/usr/lib/zabbix/externalscripts $ ./zbxcim.py esx0.domain.local
{
    "data": [
        {
            "{#CIMHEALTHSTATE}": 0,
            "{#CIMPROPERTYINDEX}": 0,
            "{#CIMPROPERTYNAME}": "System Board 7:1",
            "{#CIMOPERSTATUS}": 0
        },
        {
            "{#CIMHEALTHSTATE}": 0,
            "{#CIMPROPERTYINDEX}": 1,
            "{#CIMPROPERTYNAME}": "System Board 7:2",
            "{#CIMOPERSTATUS}": 0
        },
        {
            "{#CIMHEALTHSTATE}": 0,
            "{#CIMPROPERTYINDEX}": 2,
            "{#CIMPROPERTYNAME}": "System Board 7:3",
            "{#CIMOPERSTATUS}": 0
        },
[...]

As you can see, it will display a JSON-formatted list of CIM properties for use with Zabbix Low Level Discovery, so all properties are automatically discovered. Under the hood, it also sends the values to the Zabbix server using zabbix_sender.

I also have attached the corresponding Zabbix template (no user & password are specified in the external script parameters as I have chosen to define them in the script). You can also create Zabbix macros for this purpose and pass them as arguments.

Here is the result :

You will need to create these value mapping tables to convert the results into human readable values :

Let me know if you find this useful.

Attached Files
File Type: zip zbxcim.zip (2.9 KB, 232 views)