Ad Widget

Collapse

Check multiple Items with one script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • berchtold
    Junior Member
    • Oct 2018
    • 6

    #1

    Check multiple Items with one script

    Hi,

    I am relatively new to Zabbix and experimenting around most of the time.
    Right now I stumbled across a system that doesn't want to be monitored by SNMP. There are simply no useful MIBs.
    However, it's possible to monitor the statuses of applications via SSH. So I wrote a discovery script to get all the needed Items.
    Here is my problem: If ther's a check added to the Items the check will be done once per Item, right? I don't really want that, as the SSH connection is fragile and redundant (as the applications are all monitored by the output of one command).
    Is there a way to update the status of multiple Items (discovered by a discovery rule) at once and to run a check only once with Zabbix?
    One thng that came up to my mind is doing the updates with the API, but this way the "Zabbix way" would be broken, and I really think that this should be the last possible soultion.

    I hope I posted this in the correct sub-foru, but this one seems to be the best-fitting choice.
    Regards
  • Gustavo Guido
    Junior Member
    Zabbix Certified Trainer

    • Oct 2018
    • 3

    #2
    Have you try dependent items, I never use them with a discover, give a try (and teach us)

    Comment

    • berchtold
      Junior Member
      • Oct 2018
      • 6

      #3
      Originally posted by Gustavo Guido
      Have you try dependent items, I never use them with a discover, give a try (and teach us)
      I managed to discover all the wanted services with a discovery for dependent items.
      However, the result is one item per application which would trigger one check per Item.
      The wanted result was to have:
      One "dummy" item which triggers the check execution.
      All existing applications as dependent item, and updated via the check result.
      Any ideas?

      Comment

      • Gustavo Guido
        Junior Member
        Zabbix Certified Trainer

        • Oct 2018
        • 3

        #4
        Let me know what you think about this

        1)
        Make a temporary file, and check the creation time.
        When any item check:
        First check if the temporary file is new, created in the last 5 min, for example
        if is NOT the case, execute the "heavy" script and write the file
        grep the result from the file

        2)
        The discovery create a "check item", the one that will execute the "heavy script", and a bunch of zabbix trappers items for storing the values
        when the check item execute his script, it will use the zabbix_sender to upload the values to the zabbix trappers items

        Comment

        • berchtold
          Junior Member
          • Oct 2018
          • 6

          #5
          I don't really like the idea of doing that. Ther should be a more useful way than this.
          what I did now is: (manually) creating one item in the template which runs the discovery, and manually crating dependent items which work through JSON Path.
          I guess that the dependent items can't be done through discovery, but the item which "discovers" should be possible.
          I will work my way through it and will try to achieve this

          Comment

          • kloczek
            Senior Member
            • Jun 2006
            • 1771

            #6
            Originally posted by berchtold
            Right now I stumbled across a system that doesn't want to be monitored by SNMP. There are simply no useful MIBs.
            You cannot choose which one MIB you are going to use with exact device. SNMP agent exposes set of metrics in OIDs tree using exact MIBs and nothing more.
            The same like knocking to someone doors you cannot choose in which one language you will be talking with person which will open doors. This person is able to speak only using exact languages.
            http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
            https://kloczek.wordpress.com/
            zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
            My zabbix templates https://github.com/kloczek/zabbix-templates

            Comment

            • berchtold
              Junior Member
              • Oct 2018
              • 6

              #7
              Originally posted by kloczek
              You cannot choose which one MIB you are going to use with exact device. SNMP agent exposes set of metrics in OIDs tree using exact MIBs and nothing more.
              The same like knocking to someone doors you cannot choose in which one language you will be talking with person which will open doors. This person is able to speak only using exact languages.
              Yeah, I understand that. Let me rephrase: There is no OID which represents the interesting health values for the device. I just wanted to make clear why i can't discover or check anything via snmp.

              Comment

              • kloczek
                Senior Member
                • Jun 2006
                • 1771

                #8
                Originally posted by berchtold

                Yeah, I understand that. Let me rephrase: There is no OID which represents the interesting health values for the device. I just wanted to make clear why i can't discover or check anything via snmp.
                If you have support for this device ask vendor how can you check HW status of the device and/or ask to expose those data over proper OIDs.
                http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
                https://kloczek.wordpress.com/
                zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
                My zabbix templates https://github.com/kloczek/zabbix-templates

                Comment

                • berchtold
                  Junior Member
                  • Oct 2018
                  • 6

                  #9
                  Originally posted by kloczek

                  If you have support for this device ask vendor how can you check HW status of the device and/or ask to expose those data over proper OIDs.
                  I have support, but the vendor doesn't think it's important and/or a security concern. I have to rely on my own scripts.

                  I managed it with a trick:
                  In the template for the devices I created a discovery frule which reports {#APPLICATION} and {#STATUS}
                  The Iten Prototype is configured as follows:

                  Name {#APPLICATION}, Key app.status[{#APPLICATION}]
                  Preprocessing: $['{#APPLICATION}'].status
                  Type: Dependent
                  Master Item: an item which returns a JSON per device structured like:
                  {"{#APPLICATION}": {"status":"{#STATUS}"}
                  This way all applications are discovered (once a day) and checked (every 10 minutes).

                  Comment

                  Working...