Ad Widget

Collapse

LLD from a JSON

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • slpefanis
    Member
    • Jan 2020
    • 52

    #1

    LLD from a JSON

    I am trying to create a discovery rule for SQL replication. I have a Key for discovery set "mssql.replication.discovery" which is configured on the local conf file as "UserParameter=mssql.replication.discovery,powershe ll -NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\Zabbix\mysql_replicationlisting.ps 1""The resulting JSON:
    Code:
    {
        "data":  [
                     {
                         "{#INST}":  "MSSQLSERVER",
                         "{#REPLICATION_PUBLICATION}":  "Repl1Name",
                         "{#REPLICATION_PUBLISHER_DB}":  "Repl1Database"
                     },
                     {
                         "{#INST}":  "MSSQLSERVER",
                         "{#REPLICATION_PUBLICATION}":  "Repl2Name",
                         "{#REPLICATION_PUBLISHER_DB}":  "Repl2Database"
                     }
                 ]
    }
    I would from this like to create items for each of the items returned from the next PS script. I have an single item configured with system.run["powershell C:\Scripts\Zabbix\mysql_replicationstatus.ps1"] The returned JSON is

    Code:
    {
        "data":  [
                     {
                         "{#REPLICATION_PUBLICATION}":  "Repl1Name",
                         "{#REPLICATION_PUBLICATION_ID}":  4,
                         "{#REPLICATION_PUBLICATION_TYPE}":  2,
                         "{#REPLICATION_STATUS}":  2,
                         "{#REPLICATION_WARNING}":  0,
                         "{#REPLICATION_WORST_LATENCY}":  null,
                         "{#REPLICATION_BEST_LATENCY}":  null,
                         "{#REPLICATION_AVERAGE_LATENCY}":  null,
                         "{#REPLICATION_LAST_DISTSYNC}":  "\/Date(1588303801383)\/",
                         "{#REPLICATION_RETENTION}":  14,
                         "{#REPLICATION_LATENCYTHRESHOLD}":  null,
                         "{#REPLICATION_EXPIRATIONTHRESHOLD}":  null,
                         "{#REPLICATION_AGENTNOTRUNNINGTHRESHOLD}":  null,
                         "{#REPLICATION_SUBSCRIPTIONCOUNT}":  2,
                         "{#REPLICATION_RUNNINGDISTAGENTCOUNT}":  0,
                         "{#REPLICATION_QREADER_AGENTNAME}":  null,
                         "{#REPLICATION_WORST_RUNSPEEDPERF}":  null,
                         "{#REPLICATION_BEST_RUNSPEEDPERF}":  null,
                         "{#REPLICATION_AVERAGE_RUNSPEEDPERF}":  null,
                         "{#REPLICATION_RETENTION_PERIOD_UNIT}":  null,
                         "{#REPLICATION_PUBLISHER}":  "REPL-SERVER-NAME"
                     },
                     {
                         "{#REPLICATION_PUBLICATION}":  "Repl2Name",
                         "{#REPLICATION_PUBLICATION_ID}":  2,
                         "{#REPLICATION_PUBLICATION_TYPE}":  0,
                         "{#REPLICATION_STATUS}":  3,
                         "{#REPLICATION_WARNING}":  0,
                         "{#REPLICATION_WORST_LATENCY}":  null,
                         "{#REPLICATION_BEST_LATENCY}":  null,
                         "{#REPLICATION_AVERAGE_LATENCY}":  null,
                         "{#REPLICATION_LAST_DISTSYNC}":  "\/Date(1588303887417)\/",
                         "{#REPLICATION_RETENTION}":  72,
                         "{#REPLICATION_LATENCYTHRESHOLD}":  30,
                         "{#REPLICATION_EXPIRATIONTHRESHOLD}":  80,
                         "{#REPLICATION_AGENTNOTRUNNINGTHRESHOLD}":  null,
                         "{#REPLICATION_SUBSCRIPTIONCOUNT}":  1,
                         "{#REPLICATION_RUNNINGDISTAGENTCOUNT}":  0,
                         "{#REPLICATION_QREADER_AGENTNAME}":  null,
                         "{#REPLICATION_WORST_RUNSPEEDPERF}":  null,
                         "{#REPLICATION_BEST_RUNSPEEDPERF}":  null,
                         "{#REPLICATION_AVERAGE_RUNSPEEDPERF}":  null,
                         "{#REPLICATION_RETENTION_PERIOD_UNIT}":  null,
                         "{#REPLICATION_PUBLISHER}":  "REPL-SERVER-NAME"
                     }
                 ]
    }


    I'm assuming I need to use LLD, but not sure how to configure this to work?
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    Rework the second script (mysql_replicationstatus.ps1) so that it takes the input parameter, for example, the value REPLICATION_PUBLICATION and outputs information only for it.
    Configure this script with the publisher[*] key on the agent via userparameter.
    Based on the first script (mssql.replication.discovery), you make an lld rule with a prototype of the data element with the publisher[{#REPLICATION_PUBLICATION}] key.

    Comment

    • slpefanis
      Member
      • Jan 2020
      • 52

      #3
      Thanks for your help. I've modified the script so it now takes a publication variable.
      I have in my userparameters, the following:
      Code:
      UserParameter=mssql.replication.discovery,powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\Zabbix\mssql_replicationlisting.ps1"
      I'm not completely sure what you mean by the second two steps sorry.

      Comment

      Working...