Ad Widget

Collapse

Trigger with machine time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patrick.douglas
    Junior Member
    • Aug 2018
    • 1

    #1

    Trigger with machine time

    Good afternoon everyone!

    I want to know how I can create a trigger using the system.localtime.time item of the Linux OS template as a parameter.
    I want it to alarm when the monitored server time is up or late ... if possible
  • Linwood
    Senior Member
    • Dec 2013
    • 398

    #2
    I found it easiest to do a comparison in an external check, something like this (not tested, stripped from something more complex):

    Code:
    #!/usr/bin/perl
    #  Call:  timeDisffAgent.pl[{HOST.CONN}]  - returns float of difference in seconds
    use strict;
    use warnings;
    my $IP=$ARGV[0];
    my $remoteTime = `zabbix_get -s $IP -k "system.localtime[utc]"`;
    
    if ($remoteTime =~ /\d*\n/ )
    {
        my $localTime = time;
        my $diff = $localTime - $remoteTime;
        print $diff;
    } else
    {
        print $remoteTime;   # it's an error message, return it and it becomes unsupported
    }
    The result is an integer which is time difference you can trigger against. I have a similar one for SNMP checks (not all SNMP devices can return time though).

    This compares the zabbix server to the remote server, it doesn't tell you which is right of course.

    Comment

    Working...