Ad Widget

Collapse

Compare two files on different Hosts, Problem with trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Beam
    Junior Member
    • May 2007
    • 12

    #1

    Compare two files on different Hosts, Problem with trigger

    Hi,

    i want to compare two files on different hosts (host1, host2, host3). On host1 there is the "master"-file, which is copied with rsync to host2 and host3. I only want a notification if the file on host2 or host3 is different.

    e.g. there is an file /home/user/file on all hosts. I created an item on each host with key vfs.file.cksum[/home/user/file].

    Then i created a trigger with the following expression:

    {host2:vfs.file.cksum[/home/user/file].last(0)}#{host1:vfs.file.cksum[/home/user/file].last(0)}

    The trigger is created on host1 and host2! On each host there is the same trigger (with the same id). Actually the trigger isn't really assigned to a host, but to all hosts included in the expression?

    Is it possible to assign the trigger only to one host?
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    A trigger is assigned to all hosts having their items in the trigger expression.
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • gian72
      Junior Member
      Zabbix Certified Specialist
      • Aug 2009
      • 14

      #3
      hi have you found a solution for this problem?
      I've the same problem. Using zabbix 1.4.5.
      this is the string i'm using:
      ({xxx:vfs.file.md5sum[/myfile].last(0)})#({YYY:vfs.file.md5sum[/myfile].last(0)})

      but the trigger stays in an unknown state...
      As you can see I'm monitoring the differences between two files (that should stay identical) on two different machines.

      Thanks.

      Gianluca

      Comment

      • gian72
        Junior Member
        Zabbix Certified Specialist
        • Aug 2009
        • 14

        #4
        I've found a solution for my problem.
        I wrote a little script that compares, via md5sum, the files that I want to compare. This is done on the zabbix machine that connects to the machines where the files are using ssh.
        I call than the script via userparameters and check the results (the result can be 1 if the files are identical or 0 if not)
        This is the script:
        Code:
        a=`ssh -l zabbix $1 'md5sum' $2 |awk -F" " '{print $1}'`
        b=`ssh -l zabbix $3 'md5sum' $4 |awk -F" " '{print $1}'`
        
        
        if [ "$a" = "$b" ]; then
            echo 1
        else
            echo 0
        fi

        As you can see the script accepts 4 parameters:
        $1= machine-a
        $2= file on machine-a
        $3= machine-b
        $4= file on machine-b

        you need to setup your system so you can execute this script on machine-a and on machine-b without password request. In thge above script I login on the machine as user zabbix. For more details on how to do this, see http://linuxproblem.org/art_9.html

        In zabbix_agentd.conf you should have an entry like this:
        Code:
        UserParameter=compara[*],/etc/zabbix/bin/compara.sh $1 $2 $3 $4
        compara.sh is the name of the script above...

        In zabbix itself you should create an item with this
        Code:
        compara[machine-a,/file/on/machine-a,machine-b,/file/on/machine-b]
        Than you can add your trigger like this one that fires if the script gives 0 as result (eg. the files are different):
        Code:
        {zabbixserver:compara[machine-a,/file/on/machine-a,machine-b,/file/on/machine-b].last(0)}=0

        Hope this helps some one.

        Gianluca

        Comment

        • nishant
          Junior Member
          • Oct 2016
          • 1

          #5
          not supported by zabbix agent

          I'm getting the below error when I use the above steps :

          not supported by zabbix agent

          Can you please help

          Comment

          Working...