Ad Widget

Collapse

LLD: use {#MACROS} as "IPMI sensor" value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lufa
    Member
    • Jul 2007
    • 46

    #1

    LLD: use {#MACROS} as "IPMI sensor" value

    Hello!

    Zabbix 2.0.2, running Ubuntu 12.10.

    I have a LL Discovery rule for discovering IPMI sensors, using a custom script.

    A corresponding "Item prototype" (type-IMPI) is created. All items has been created successfully, I can see it in the Host's items.

    "IPMI sensor" value for IMPI-item should be "variable" (different values for different IMPI-sensors).

    So I was trying to use my custom macros for IPMI-item: {#SENSOR_ID}.

    Code:
    #JSON
    {'data': [{'{#SENSOR_ID}': 'Pwr Unit Status', '{#SENSOR_NAME}': 'Pwr_Unit_Status'} ... ]}
    But! it seems like Zabbix does not allow to use the LLD-macros for "IPMI sensor" field. Because I got the following errors in the logs:
    Code:
    sensor or control {#SENSOR_ID}@[192.168.252.206]:623 does not exist
    Other macros, used in "Item name" and "Item key" was applied successfully (converted to real data), only "IMPI sensor" remains in "raw macros" value ("{#SENSOR_ID}").

    So. Is there a way to use LLD-marcos for "IPMI sensor" in the "Item prototype" for "IPMI agent" type?

    Thank you!

    P.S.
    Please look at the screenshots for better understanding.

    P.P.S.
    {#SENSOR_ID} exist for sure, because I was trying to use it as a Item name.
    Attached Files
    Last edited by Lufa; 19-06-2013, 08:56.
  • aigars
    Member
    • Apr 2010
    • 55

    #2
    Very interesting thing! Could you share LLD template for IPMI?
    Thanks.

    AP

    Comment

    • Lufa
      Member
      • Jul 2007
      • 46

      #3
      Originally posted by aigars
      Very interesting thing! Could you share LLD template for IPMI?
      Thanks.

      AP
      Because of the error (described in #1 post) I have to use python script for discovery AND IPMI items data. The script was written by a friend of mine, so sorry for any syntax issues in the code.

      /usr/local/etc/zabbixipmi_discovery.py:
      Code:
      #!/usr/local/bin/python
      
      import os,sys
      
      if len(sys.argv) == 3:
          if sys.argv[1] == "all":
      
              sensors = os.popen("sudo /usr/local/bin/ipmitool sensor").read().split("\n")
              sensor_list = {}
              data = []
              sensors_status = "ok"
      
              for sensor in sensors:
                  sensor_param = sensor.split("|")
                  if len(sensor_param) > 2:
                      if  sensor_param[2].strip() != "discrete":
                          sensor_data = { "{#SENSOR_NAME}":sensor_param[0].strip()}
                          data.append(sensor_data)
                          if not (sensor_param[3].strip() in ["ok", "0x0000", "0x8000", "na"]):
                              sensors_status = "error"
      
              sensor_list["data"]=data
              sensor_list_json = str(sensor_list).replace("\'","\"")
      
              if sys.argv[2] == "list":
                  print sensor_list_json
              elif sys.argv[2] == "status":
                  print sensors_status
      
          else:
              sensor_get_cmd = "sudo /usr/local/bin/ipmitool sensor get \""+sys.argv[1]+"\""
              sensor = os.popen(sensor_get_cmd).read().split("\n")
      
              for sensor_param in sensor:
      
                  if sys.argv[2] == "value":
                      if sensor_param.split(":")[0].strip() == "Sensor Reading":
                          print sensor_param.split(":")[1].strip().split(" ")[0]
      
                  if sys.argv[2] == "status":
                      if sensor_param.split(":")[0].strip() == "Status":
                          print sensor_param.split(":")[1].strip()
      zabbix_agentd.conf:
      Code:
      UserParameter=ipmi.data[*],/usr/local/etc/zabbix/externalscripts/ipmi_discovery.py "$1" "$2"
      Usage in Zabbix or CLI:
      Code:
      # IMPI sensors discovery (JSON data):
      ipmi.data["all","list"]
      
      # Prototype item, get value:
      ipmi.data[{#SENSOR_NAME},value]
      
      # Prototype trigger, get status [OK, not OK]:
      ipmi.data[{#SENSOR_NAME},status]
      Tested on Zabbix 2.0.3 , FreeBSD, IntelĀ® Server System R1304BTLSFAN server platform.
      Attached Files
      Last edited by Lufa; 05-07-2013, 15:39.

      Comment

      • aigars
        Member
        • Apr 2010
        • 55

        #4
        Great, thanks ! I will try to test.

        Comment

        • Lufa
          Member
          • Jul 2007
          • 46

          #5
          Originally posted by aigars
          Great, thanks ! I will try to test.
          Remember to install ipmitool for your system and set the correct path to it in the script.

          Comment

          Working...