Ad Widget

Collapse

Defining a host trigger that works accross two hosts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmcgrath
    Junior Member
    • Dec 2018
    • 2

    #1

    Defining a host trigger that works accross two hosts

    Hi

    I am running zabbix 3.4

    I have two servers with a floating IP address. I have two custom monitors (one one each server) with key server1_floating_ip and server2_floating_ip. server 1 should normally have the IP address, and I consider my cluster failed over if server 2 has the address.

    The custom monitors return 0 if the server has the floating IP and non zero if not. (I used regex as sometime my monitor scripts return a text error)

    I defined a trigger against server1

    {server1:_server1_public_floating_ip.regexp(^0$,#1 )}=0 which sets OK if server 1 has IP and problem if it does not. (works as expected)

    I then defined a trigger against server2

    {server1:server1_floating_ip.regexp(^0$,#1)}=1 and {server2:server2_floating_ip.regexp(^0$,#1)}=0 which sets OK if server 1 has IP and sever 2 does not have server IP. This is working as expected.

    I then tried to modify the trigger for server2 so that if server 1 has IP and server 2 does not OR server 1 has not go the IP address but sever 2 has the IP address then to set OK. This means server 2 should show OK if server 1 or server 2 have the ip address So my final trigger expression is

    (
    {server1:server1_floating_ip.regexp(^0$,#1)}=1 and {server2:server2_floating_ip.regexp(^0$,#1)}=0
    )
    or
    (
    {server1:server1_floating_ip.regexp(^0$,#1)}=0 and {server2:server2_floating_ip.regexp(^0$,#1)}=1
    )

    So if the address is on server 2 I want the server 1 trigger to show problem and the server 2 trigger to show OK. But when I add the the or to the expression the trigger returns problem when server 2 has the IP Address.

    I have noticed that once I mentioned server 1 in the server 2 trigger it shows as a trigger on both server 1 and server 2. It seems like zabbix is eval the trigger I hoped was defined against server 2 against sever 1 and server 2 at the same time.

    Regards

    David
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #2
    - create dummy host (127.0.0.1 in interface)
    - add trigger which parts of the expression will be using metrics from other two hosts
    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

    • dmcgrath
      Junior Member
      • Dec 2018
      • 2

      #3
      Thanks for the suggestion I managed to solve the problem myself whilst waiting for my post to be moderated.

      I solved it by updating my expression with an extra pair of brackets and making the whole expression equal to zero!

      (
      (
      {server1:server1_floating_ip.regexp(^0$,#1)}=1 and {server2:server2_floating_ip.regexp(^0$,#1)}=0
      )
      or
      (
      {server1:server1_floating_ip.regexp(^0$,#1)}=0 and {server2:server2_floating_ip.regexp(^0$,#1)}=1
      )
      )=0

      Happy Christmas everyone :-)

      David

      Comment

      Working...