Ad Widget

Collapse

Use item value as condition in Trigger action

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Knuppel
    Junior Member
    • Jan 2024
    • 6

    #1

    Use item value as condition in Trigger action

    I have a trigger on my 2 UPS devices that monitors if power is lost for 30 seconds.
    I have an item called 'VM's active' on my 2 Hyper-V hosts that reflects if it is running VM's. (only 1 at a time is)

    Action: if power is lost for 30s on both UPS devices, send Pushover message and execute 'shutdown non-critical servers'.

    Now what i want is to conditionally execute a shutdown script based on the 'VM's active' item value. If VS1 is not running VM's shut it down, if VS2 is not running VM's shut it down.
    But it can't use an item value in a Trigger action condition. How can i achieve what i want?

    Click image for larger version

Name:	Schermafbeelding 2024-02-29 105318.png
Views:	582
Size:	40.6 KB
ID:	479878
  • Brambo
    Senior Member
    • Jul 2023
    • 245

    #2
    I think you first need to build a trigger on VS1 & 2 (or in the template running on both )which is triggered when there are no running VM's and then you could use that trigger in your action.

    Comment

    • Knuppel
      Junior Member
      • Jan 2024
      • 6

      #3
      Originally posted by Brambo
      I think you first need to build a trigger on VS1 & 2 (or in the template running on both )which is triggered when there are no running VM's and then you could use that trigger in your action.
      But then that trigger would always be in problem state? Having no VM's running isn't a failure, i just tells me the host can safely be shutdown.

      Comment

      • Brambo
        Senior Member
        • Jul 2023
        • 245

        #4
        The "error state" could be of level informational

        Comment

        • Knuppel
          Junior Member
          • Jan 2024
          • 6

          #5
          Originally posted by Brambo
          The "error state" could be of level informational
          You're right. I was overcomplicating this!
          Thanks!

          Comment

          • Knuppel
            Junior Member
            • Jan 2024
            • 6

            #6
            Originally posted by Brambo
            The "error state" could be of level informational
            Does not work unfortunately.
            In current problems i see my initial trigger is fired and it reports 'OPM-VS1 is running VM's' (informational). So far so good.
            In actions i then reference 3 triggers (this one + 2 ups batteries discharging. But nothing happens.

            Comment

            • TheOddPerson
              Junior Member
              • Feb 2024
              • 12

              #7
              When the on battery trigger goes then have it run a script with a loop

              Code:
              Shutdown VMs
              Do {
                  Check if VMs are running on hosts and shutdown
                  Wait 5 minutes
              } Until ( 3 hrs have passed / battery is dead / all servers are off )
              You can also go outside of Zabbix to implement this and merely have Zabbix initiate the loop.
              Personally I would use powershell which can integrate with the esx api but use whatever you're comfortable with.

              Comment

              Working...