Ad Widget

Collapse

WBEM/CIM check script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tatapoum
    Senior Member
    • Jan 2014
    • 185

    #1

    WBEM/CIM check script

    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
  • bschmidt001
    Junior Member
    • Apr 2011
    • 24

    #2
    zbxcim.py Results

    Thank you for taking the time to write the script to pull WBEM/CIMC information. When I use the script against Cisco UCS 240s, I get inconsistent results across multiple servers. After controlling for firmware versions and the like, I do not see any signifcant differences. Is there a timing parameter that may be adjusted for the queries?

    Comment

    • tatapoum
      Senior Member
      • Jan 2014
      • 185

      #3
      Hi,
      The script is based on pywbem and I think that this library doesn't expose a timeout parameter. You should try to increase the Timeout parameter in your zabbix server/proxy configuration file to see if it helps.

      Comment

      • bschmidt001
        Junior Member
        • Apr 2011
        • 24

        #4
        zbxcim.py Results Redux

        After running the zbxcim.py script manually with verbose mode [-v] (to remove Zabbix from the equation), I am seeing the following:

        20140919 13:49:27 Connection to [servername redacted]
        20140919 13:49:27 Check classe CIM_ComputerSystem
        20140919 13:51:26 Unknown CIM Error: (-2, u'Error code -2')
        20140919 13:51:26 Check classe CIM_NumericSensor
        20140919 13:51:57 Unknown CIM Error: (-2, u'Error code -2')
        20140919 13:51:57 Check classe CIM_Memory
        20140919 13:52:27 Success: (-2, u'Error code -2')
        20140919 13:52:27 Class = CIM_Memory,Element Name = CPU1 Level-1 Cache
        20140919 13:52:27 Class = CIM_Memory,Element Name = CPU1 Level-2 Cache
        20140919 13:52:27 Class = CIM_Memory,Element Name = CPU1 Level-3 Cache
        20140919 13:52:27 Class = CIM_Memory,Element Name = CPU2 Level-1 Cache
        20140919 13:52:27 Class = CIM_Memory,Element Name = CPU2 Level-2 Cache
        20140919 13:52:27 Class = CIM_Memory,Element Name = CPU2 Level-3 Cache
        20140919 13:52:27 Class = CIM_Memory,Element Name = Memory
        20140919 13:52:27 Check classe CIM_Processor
        20140919 13:52:27 Success: (-2, u'Error code -2')
        20140919 13:52:27 Class = CIM_Processor,Element Name = CPU1
        20140919 13:52:27 Class = CIM_Processor,Element Name = CPU2
        20140919 13:52:27 Check classe CIM_RecordLog
        20140919 13:52:58 Unknown CIM Error: (1, u'Timeout (or other socket error) sending request to provider')
        20140919 13:52:58 Check classe OMC_Chassis
        20140919 13:53:58 Success: (1, u'Timeout (or other socket error) sending request to provider')
        20140919 13:53:58 Class = OMC_Chassis,Element Name = Chassis
        20140919 13:53:58 Check classe OMC_Fan
        20140919 13:57:58 Success: (1, u'Timeout (or other socket error) sending request to provider')
        20140919 13:57:58 Check classe OMC_PowerSupply
        20140919 13:58:58 Unknown CIM Error: (-2, u'Error code -2')
        20140919 13:58:58 Check classe VMware_StorageExtent
        20140919 13:59:28 Success: (-2, u'Error code -2')
        20140919 13:59:28 Check classe VMware_Controller
        20140919 13:59:28 Success: (-2, u'Error code -2')
        20140919 13:59:28 Check classe VMware_StorageVolume
        20140919 13:59:28 Success: (-2, u'Error code -2')
        20140919 13:59:28 Check classe VMware_Battery
        20140919 13:59:29 Success: (-2, u'Error code -2')
        20140919 13:59:29 Check classe VMware_SASSATAPort
        20140919 13:59:29 Success: (-2, u'Error code -2')
        20140919 13:59:29 Sending values to Zabbix server : 127.0.0.1
        20140919 13:59:29 [servername redacted]:CIMHealthState[0]:0 CIMOperStatus[0]:0
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[0] -o 0
        20140919 13:59:29 [servername redacted]:CIMHealthState[1]:0 CIMOperStatus[1]:0
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[1] -o 0
        20140919 13:59:29 [servername redacted]:CIMHealthState[2]:0 CIMOperStatus[2]:0
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[2] -o 0
        20140919 13:59:29 [servername redacted]:CIMHealthState[3]:0 CIMOperStatus[3]:0
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[3] -o 0
        20140919 13:59:29 [servername redacted]:CIMHealthState[4]:0 CIMOperStatus[4]:0
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[4] -o 0
        20140919 13:59:29 [servername redacted]:CIMHealthState[5]:0 CIMOperStatus[5]:0
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[5] -o 0
        20140919 13:59:29 [servername redacted]:CIMHealthState[6]:0 CIMOperStatus[6]:0
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[6] -o 0
        20140919 13:59:29 [servername redacted]:CIMHealthState[7]:5 CIMOperStatus[7]:2
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[7] -o 5
        20140919 13:59:29 [servername redacted]:CIMHealthState[8]:5 CIMOperStatus[8]:2
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[8] -o 5
        20140919 13:59:29 [servername redacted]:CIMHealthState[9]:0 CIMOperStatus[9]:0
        20140919 13:59:29 /usr/bin/zabbix_sender -z 127.0.0.1 -s [servername redacted] -k CIMHealthState[9] -o 0

        - - - - - -

        As you can see, the script does obtain some of the information, but appears to time out on other elements. Any ideas why one server might work and another would not?

        Several local servers report WBEM information properly, while one local does not. Remote servers report back information properly, with the exception of one remote server. Thus, it does not appear to be related to network timing, as far as I can tell...

        Comment

        • tatapoum
          Senior Member
          • Jan 2014
          • 185

          #5
          I'm sorry I don't know. This error code in returned by the pywbem module.

          Comment

          • bschmidt001
            Junior Member
            • Apr 2011
            • 24

            #6
            zbxcim.py Results Redux

            Thank you for responding. Checking using wbemcli.py from the pywbem code and when logging into the server using a variety of credentials shows the same results -- i.e. the "Error code -2." Therefore, as most of the other servers are working, I am working on the presumption that there is a firmware issue on the specific server.

            Comment

            • Guest

              #7
              I Have a problem

              hello, i have installed pywbem in my Debian 7 server and zabix sender.
              when i import the templates and copy the script in my externalscripts folder I have changed the permission with chmod a+x and now, when I use this command in the externalscrpits folder: ./zbxcim.py [-v] <host> [-u <username>] [-p <password>] [-s <sender>] [-z <server>] [-P <port> ] [-H <protocol>]
              Host: IP address of ESXI server
              sender: path zabbix sender
              port: 5988
              protocol: http

              I have this message for all items: Unknow CIM Error: (0, 'Socket error: [Errno 111] Connection refused')

              I have configurated the ESXI CIM server in ESXI 5.5 server enabling services.
              Please help me

              Comment

              • tatapoum
                Senior Member
                • Jan 2014
                • 185

                #8
                Can you use curl on the Zabbix server to check that it can reach your ESXis WBEM port ?
                curl -v -XGET "http://ipaddress:5988"
                Does it answer anything ?

                You can also install wbemcli (apt-get install sblim-wbemcli) to query your ESXis on the Zabbix and validate that everything is properly configured.

                Comment

                • Guest

                  #9
                  no, nothing, curl command not found.
                  sblim-wbemcli does not exist.
                  how do that?
                  excuse me for my bad english

                  Comment

                  • tatapoum
                    Senior Member
                    • Jan 2014
                    • 185

                    #10
                    I don't have a Debian 7 system to test, but you just need to install the right packages :
                    sudo apt-get install curl
                    For wbemcli, try to find which package provides it :
                    sudo apt-get install apt-file
                    sudo apt-file update
                    sudo apt-file search wbemcli

                    Comment

                    • Guest

                      #11
                      I aƬhave installed all.
                      But i have not result.

                      Comment

                      • sgiaicheca
                        Junior Member
                        • Feb 2014
                        • 18

                        #12
                        please could you help me to configure password in your script ?

                        Comment

                        Working...