Ad Widget

Collapse

create new hosts based on LLD

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • baramann
    Junior Member
    • Jan 2021
    • 9

    #1

    create new hosts based on LLD


    Hi@all,

    i try to create new hosts via LLD. to do this, i trigger a LLD rule an a host which returns this json:
    { "data":[
    {
    "NewSQLHost": "test1",
    "{#sqlClusterRole}": "SQL Server (test1)",
    "{#sqlResName}": "test1",
    "{#sqlResNameDNS}": "test1",
    "{#sqlResNameIP}": "10.10.10.10"
    },
    {
    "NewSQLHost": "test2",
    "{#sqlClusterRole}": "SQL Server (test2)",
    "{#sqlResName}": "sqltest2",
    "{#sqlResNameDNS}": "sqltest2",
    "{#sqlResNameIP}": "1.2.3.4"
    }
    ]}

    ​Next, my goal is, that based on this, 2 new hosts are created. In the LLD is set as LLD Macro:

    Macro Json Path
    {#SQLNAME} --> $.[].NewSQLHost

    The Host prototype use for the Hostname: {#SQLNAME}

    But, i got the error von LLD:

    Cannot create host "{#SQLNAME}": name contains invalid character '{'.

    What do i wrong???

    Thank for hints!

    bjoern


  • baramann
    Junior Member
    • Jan 2021
    • 9

    #2
    So, i found the solution - the spelling of macro names in the json need names without the {#} - then it works :-)

    Correkt json:
    { "data":[
    {
    "NewSQLHost": "test1",
    "sqlClusterRole": "SQL Server (test1)",
    "sqlResName": "test1",
    "sqlResNameDNS": "test1",
    "sqlResNameIP": "10.10.10.10"
    },
    {
    "NewSQLHost": "test2",
    "sqlClusterRole": "SQL Server (test2)",
    "sqlResName": "sqltest2",
    "sqlResNameDNS": "sqltest2",
    "sqlResNameIP": "1.2.3.4"
    }
    ]}​

    Then i can use them in die LLD macro and the new hosts were correct created.

    Macro Json Path
    {#SQLIP} --> $.sqlResNameIP
    {#SQLNAME} --> $.NewSQLHost

    I think this a little bit strange because in "normal" LLD for items and triggers, the {#} can be used . My Zabbix version is 6.0.12​

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4811

      #3
      LLD macros are in capital letters.... Think about it ,, Test it... Maybe you dont need that LLD macro pointing after all...

      Comment

      Working...