Ad Widget

Collapse

Trigger action - condition is ignored

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dpit
    Junior Member
    • Nov 2023
    • 8

    #1

    Trigger action - condition is ignored

    Hi,

    I'm struggling with a trigger action where it is ignoring a condition.

    So a trigger action is created to restart a Windows service when Zabbix detects it's stopped.
    I added a few conditions where I don't want this to happen because I stop a service on purpose during an offline backup of a database.
    Click image for larger version

Name:	image.png
Views:	77
Size:	45.6 KB
ID:	499370
    So far so good.


    There is another trigger action to execute a script on a host when a ups is running on battery (and capacity below a certain value).
    That is working fine as well, as a remote command a batch file is run on a specified client to stop certain services.


    But when I add another condition to the screenshot above so a service is NOT restarted when ups is on battery, that condition is getting ignored?

    Click image for larger version

Name:	image.png
Views:	180
Size:	44.0 KB
ID:	499369


    So conditions C, D and E are working but when B is added, it is still restarting a service even though the trigger that that ups is on battery has status = problem.

    Click image for larger version

Name:	image.png
Views:	76
Size:	7.5 KB
ID:	499371
    I tried playing around with AND/OR calculations but I can't get it to work when this "ups on battery condition" is added.
    I tried it with removing conditions C, D and E but still I see a service being restarted (I used the W32Time server for testing)?
    5448:20250220:103940.569 Executing command 'C:\Program Files\Zabbix Agent\shutdown_by_ups.bat'
    5444:20250220:104222.833 Executing command 'c:\windows\system32\net start W32Time'​


    Anyone got a clue why this condition for the ups on battery trigger is ignored here and why other conditions like the service names are working?

    This is on Zabbix 6.4

  • Brambo
    Senior Member
    • Jul 2023
    • 245

    #2
    Take a look how the Type of calculation looks when you add the extra B, you didn't put that in the second screenshot so it's hard to say how it's handled. A and ( .... )

    Could it be that the UPS doesn't have a tag WinService

    Comment

    • dpit
      Junior Member
      • Nov 2023
      • 8

      #3
      Hi,

      >> Could it be that the UPS doesn't have a tag WinService

      Yes I had questions about that one as well so I removed all conditions other than "Trigger does not equal DPUPS07: APC UPS: UPS is on battery".
      But even with this single condition the trigger action was still restarting a service even though that ups was on battery so the condition check should have been false (at least that's what I thought).


      I played around with some other options and it the end it seems I got it working:

      I removed the tag "WinService" from Template Windows by Zabbix agent > Discovery rules > Windows service discovery > Trigger prototypes
      I created a new tag there "servicerestart" with value = true

      Click image for larger version

Name:	afbeelding.png
Views:	145
Size:	20.9 KB
ID:	499439
      Click image for larger version

Name:	afbeelding.png
Views:	65
Size:	15.3 KB
ID:	499440


      Then on the trigger that ups is on battery with battery capacity < xx% I added that same tag but now with value = false
      Click image for larger version

Name:	afbeelding.png
Views:	72
Size:	51.6 KB
ID:	499441
      Click image for larger version

Name:	afbeelding.png
Views:	66
Size:	29.4 KB
ID:	499442



      The conditions in the trigger action now look like this:
      Click image for larger version

Name:	afbeelding.png
Views:	63
Size:	47.2 KB
ID:	499443


      I did some tests:
      - I put ups on battery and when battery capacity was below 82% a remote command was executed to stop the W32Time service. OK
      - When Zabbix detected that this service was stopped, the trigger was shown as a problem but now it was not restarted. OK
      - With ups back to 100% I manually stopped the W32Time service and now it was being restarted by this trigger action. OK
      - With ups back to 100% I manually stopped the WsusService service and this was not restarted because it's listed as an additional condition in the action trigger. OK




      Comment

      Working...