Ad Widget

Collapse

service.info custom implementation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • drenriza
    Junior Member
    • May 2019
    • 19

    #1

    service.info custom implementation

    I would like to create a PowerShell script for getting all certificates from a target host as a JSON array object like service.discovery does for services.
    Than i would like to create item prototypes based on matches from the filter like service.info does.

    the discovery script is executed at the agent through system.run and returns all certificates as JSON.

    What i dont understand is
    How do (for example) service.discovery pass the JSON array object to service.info as a parameter so items for each match can be created.
    service.info only takes a parameter of [service,<param>] and not the JSON array object itself so it can be iterated.
    Last edited by drenriza; 19-08-2019, 11:05.
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    I think you should use UserParameter.

    Comment

    • drenriza
      Junior Member
      • May 2019
      • 19

      #3
      Thanks for the reply Atsushi!
      Quick question, if i use service.info as a item prototype key, how is this than linked with service.discovery?
      How do service.info know that it needs to get the data from service.discovery's JSONArray and not ask the agent again for information it already has, and where in the zabbix directory structure would you place such a script on the server?
      Last edited by drenriza; 16-08-2019, 14:26.

      Comment

      • drenriza
        Junior Member
        • May 2019
        • 19

        #4
        Thanks for the reply splitek !
        I understand what you say and i have edited my question at #0 now that i know how to ask the question better, i hope you will still reply since i am very stuck.

        Atsushi

        I place the edited question here also for good measure.

        I would like to create a PowerShell script for getting all certificates from a target host as a JSON array object like service.discovery does for services.
        Than i would like to create item prototypes based on matches from the filter like service.info does.

        the discovery script is executed at the agent through system.run and returns all certificates as JSON.

        What i dont understand is
        How do (for example) service.discovery pass the JSON array object to service.info as a parameter so items for each match can be created.
        service.info only takes a parameter of [service,<param>] and not the JSON array object itself so it can be iterated.


        Thank you for your patience!
        Best regards!
        Last edited by drenriza; 19-08-2019, 11:06.

        Comment

        • drenriza
          Junior Member
          • May 2019
          • 19

          #5
          splitek Thanks for the reply! What if i in my first script return all the data i need in one go?

          For example, if my discovery script finds the following two certificates

          {
          "data": [
          {
          "{#NAME}": "NAME1",
          "{#SUBJECT}": "SUBJECT1",
          "{#EXPIRE}": 498,
          "{#THUMBPRINT}": xxxxxxxx
          },
          {
          "{#NAME}": "NAME2",
          "{#SUBJECT}": "SUBJECT2",
          "{#EXPIRE}": 284,
          "{#THUMBPRINT}": xxxxxxxx
          }
          ]
          }

          And this is all the information i want, from here i would just like to create two items without creating a second script. Is that possible in Zabbix?
          Last edited by drenriza; 20-08-2019, 15:44.

          Comment

          • drenriza
            Junior Member
            • May 2019
            • 19

            #6
            splitek Thanks for the explanation!
            I run 4.0 so i have created two scripts

            1. Certificate discovery script (returns {#NAME}, {#SUBJECT}, {#EXPIRE}, {#THUMBPRINT})
            2. Certificate expiration script (returns a single integer, no JSON object)

            I created the second script after i looked at what service.info returns, and this just returns a single Integer without anything else.

            And now it works THANKS! Though it pains me that i need to make more than one request to the agent in 4.0 instead of being able to use the
            {#THUMBPRINT} macro value as the key in item prototype

            Is there an official Zabbix location where we share templates, scripts and such with eachother?
            Last edited by drenriza; 21-08-2019, 09:44.

            Comment

            Working...