Ad Widget

Collapse

Triggers from two different hosts with and condition

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hserna
    Junior Member
    • Feb 2025
    • 5

    #1

    Triggers from two different hosts with and condition

    Hello

    I've got Zabbix 7.2 running with next inventory

    Two test hosts that receive information thru SNMP.
    The current test that I've got simulate both hosts (The zabbix server and test hosts run in the same VM)
    Each host has a private trigger that is fired by a TRAP received
    There is a shared trigger that should be fired when private trigger at HOST_A and B is fired.

    The triggers with simple expression works fine, but the trigger with logical and conditions not.

    I attached the screenshot with my environment.

    The shared trigger is TRIGGER_G

    The Trigger at host_A is TRIGGER_HOST_A, and obiously the trigger at host B "TRIGGER_HOST_B"

    The attached pictures shown the status that singles trigger are fired, but shared fired not.

    Why TRIGGER_G is not fired?

    Best regards


    Trigger HOST B

    Click image for larger version

Name:	Captura de pantalla 2025-02-21 131350.png
Views:	164
Size:	76.3 KB
ID:	499458

  • Answer selected by hserna at 06-03-2025, 13:51.
    Brambo
    Senior Member
    • Jul 2023
    • 245

    The .last examples from chatgpt are wrong if you use a zabbix 6.x or higher.
    The help is very clear in this: https://www.zabbix.com/documentation...pes/calculated
    Function (which goes in the formula section) most of the time you could use the same syntax as that from triggers.

    And sorry but if you aren't looking in the manual what are you trying to build.

    Comment

    • hserna
      Junior Member
      • Feb 2025
      • 5

      #2
      I forgot to add the picture with details of trigger TRIGGER_G

      Click image for larger version

Name:	Captura de pantalla 2025-02-24 092219.png
Views:	156
Size:	54.7 KB
ID:	499524

      Comment

      • Brambo
        Senior Member
        • Jul 2023
        • 245

        #3
        I think there are multiple ways to solve it. However the one you could do is.
        Create on 1 of the host or a separate virtual one a calculated item which either does the sum of both or you create 2 of them (1 for each host) and then use these 2 calculated items the triggers.
        I use this in a 3 nodes setup and combined with a macro which provides the value of the amount of nodes all calculations are done.
        However the code for that isn't something I could easily share without exposing certain company details.

        Comment

        • hserna
          Junior Member
          • Feb 2025
          • 5

          #4
          Hello

          I was working these days trying to solve my problem at several ways but none worked for me.

          First one trying to evaluate two business conditions at trigger level (The pictures that I attached at begining of the post).

          Second with trigger dependencies, same result.

          The last way that I'm working is create a trigger for each host, and at each one only evaluate their own condition.

          My idea is on virtual host create a trigger an evaluate de status of both trigger FAIL or INFO.

          On HOST_A
          TRIGGER NAME HOST_A_ALFADISC
          find(/HOST_A/snmptrap[],,"regexp","hrDeviceKeyboard.*ALFADISC"")=1

          On HOST_B
          TRIGGER NAME HOST_B_ALFADISC
          find(/HOST_B/snmptrap[],,"regexp","hrDeviceKeyboard.*ALFADISC"")=1


          The next tryout I followed is one that I found at ChatGPT

          "Using Calculated Items"
          Create a Calculated Item: This item will evaluate the status of the original trigger.
          Go to Configuration > Hosts > Items.
          Click Create item and select Calculated as the type.
          Use an expression that checks the status of the original trigger. For example:
          {hostname:trigger.key.last()}=1

          I tried to create a calculated item on virtual host with next information:
          Name: whatever
          Type: Calculated
          Key: {HOST_A:HOST_A_ALFADISC.key.last()}=1
          Type: Numeric

          Click image for larger version  Name:	Captura de pantalla 2025-03-04 093312.png Views:	0 Size:	32.8 KB ID:	499907

          When I Test the item or try to Add, the next error it's shown:
          Incorrect value for field "key_": incorrect syntax near "{HOST_A:HOST_A_ALFADISC.key.last()}=1".

          I would be pleased if somebody could assist me with this issue

          Best regards
          Last edited by hserna; 04-03-2025, 10:38.

          Comment

          • Brambo
            Senior Member
            • Jul 2023
            • 245

            #5
            The .last examples from chatgpt are wrong if you use a zabbix 6.x or higher.
            The help is very clear in this: https://www.zabbix.com/documentation...pes/calculated
            Function (which goes in the formula section) most of the time you could use the same syntax as that from triggers.

            And sorry but if you aren't looking in the manual what are you trying to build.

            Comment

            Working...