Ad Widget

Collapse

Compare a Dynamic Value (Number) between two servers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • highway_fixer_man
    Member
    • Jun 2022
    • 35

    #1

    Compare a Dynamic Value (Number) between two servers

    Hi,

    Let me describe the scenario:

    I have a situation where I have one "master" server, which has a value in a file. Lets call this value the "version number". The "master" server is connected via a LAN to several (up to about 30) hosts. These hosts also receive this version number and it appears in their application logs, but they receive it shortly after the "master" does.

    The version number changes every few hours on the master. A cronjob outputs a mysql command to a file every hour, and this file will then contain the version number.

    I then set up a UserParameter in the Zabbix agent config file as follows:

    UserParameter=list.version,cat /home/zabbixuser/zabbix_values/current_list_version

    And enabled this item on the template that is assigned to this class of server (The "master" server). If I open this "master" server's Latest Data, I can now see the "version number (list.version)" as expected.

    On the hosts connected via LAN to the "master" server, I can confirm which version they have by tailing the application logs. I can easily get this value into Zabbix per connected host with another UserParameter on the connected hosts.

    So, now I have two values in Zabbix. One is the list version on the master, and one is the list version on the connected host.

    How can I compare these two values, and alert if they are not the same for a period of time?

    Advice or suggestions appreciated.

    I will document the solution properly once I find it. Others have asked this kind of question before but usually end up giving up.

    Thanks in advance.



  • highway_fixer_man
    Member
    • Jun 2022
    • 35

    #2
    I have now added a cron to the connected hosts.

    They will ssh to the "master" and grab the value and output it to a file.

    Now, I have both values on one hosts "latest data" and its valid.

    How can I compare the two values?

    Do I need to do this in bash and output the result to zabbix, rather?

    Comment

    • fvilarnovo
      Junior Member
      • Jan 2023
      • 17

      #3

      Hi, you could use the distinct operator on a trigger in the slave host/template. For example:

      last(/CLIENT/list.version)<>last(/MASTER/list.version).

      This trigger should fire when the versions are unequal. However, to no have false positives you should consider adding some occurrences, for example #2/3 parameter to the master item.

      Hope it helps.

      Comment


      • highway_fixer_man
        highway_fixer_man commented
        Editing a comment
        Thanks for this.

        I tried, but it failed to add the trigger, with the error:

        "Trigger "List Check" belongs to templates with different linkages."

        I used:

        "last(/ClientTemplate/list.version)<>last(/MasterTemplate/list.version)"

        The item in question will always be a 5 digit number on both sides.

        If you have any other tips or advice, I would appreciate them.
    Working...