Ad Widget

Collapse

Use the value of an item as part of the key for another item

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • inventor96
    Junior Member
    • Dec 2021
    • 13

    #1

    Use the value of an item as part of the key for another item

    I've created a custom item with the key "service.ssh.port" that contains the port number that the SSH service is listening on for the given host. I would like to create another item that utilizes the "net.tcp.service[ssh]" simple check to make sure the service is running. My understanding is that I can set the key to "net.tcp.service[ssh,,<port>]", where "<port>" is the port number to check. How could I take the value from the "service.ssh.port" item and pass it into that third parameter of the "net.tcp.service[ssh]" check?
  • Answer selected by inventor96 at 19-01-2022, 09:10.
    Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    Use LLD to generate an item with the necessary parameters

    The logic is as follows: received the port number from the device, made json from it with {#SSHPORT} macro and fed it to LLD, who based on it made an item with the key "net.tcp.service[ssh,,{#SSHPORT}]"

    Comment

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

      #2
      You cannot use one items value in other items parameters... Is that port so often changing thing? You could use macros instead.

      Comment

      • inventor96
        Junior Member
        • Dec 2021
        • 13

        #3
        It's not changing, but we do have a handful of different ports used across our servers. It would be nice to automate it across all of our servers instead of having to configure each one.

        Comment

        • Hamardaban
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • May 2019
          • 2713

          #4
          Use LLD to generate an item with the necessary parameters

          The logic is as follows: received the port number from the device, made json from it with {#SSHPORT} macro and fed it to LLD, who based on it made an item with the key "net.tcp.service[ssh,,{#SSHPORT}]"

          Comment

          • locrian
            Junior Member
            • Feb 2023
            • 1

            #5
            Hello everyone,

            I've been trying something similar in my Zabbix configuration, but I still could need some help. I'm using the docker monitoring template and want to use the item prototype "Container {#NAME}: Image", which will query the current image name of the individual container and use this information as a parameter in another custom item prototype having the key "script.php["{#IMAGE_VERSION}", "{#NAME}"]. The {#IMAGE_VERSION} macro should have the value of the before mentioned item prototype, in order that I can use the image name of the individually discovered containers for further processing in my PHP script.

            Hamardaban, your approach using LLD seems quite interesting, thank you for that. I tried to adapt your solution to my scenario, but to no avail. I've never done anything with LLD before, so it would be nice if you could guide me a little bit on how to configure the LLD approach according to my use case Thank you in advance for any useful tips regarding this topic.

            Kind Regards,
            Locrian​

            Comment

            Working...