Ad Widget

Collapse

issue with unix timestamp / now

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • piti87
    Junior Member
    • Jun 2020
    • 23

    #1

    issue with unix timestamp / now

    I created an item which based on an powershell script and deliver the last modified date from a directory as unix timestamp (on a windows server).
    Type: Zabbix agent
    Key: folder.lastmodtime["C:\ProgramData\FTPGetter\LOG"]
    Type of information: Numeric (unsigned)
    Units: s
    Update interval: 3m


    The goal is to trigger the trigger, if the delivered unix timestamp is older than 300 seconds.

    I see the item-values like expected in "Latest Data"

    Timestamp (Zabbix)
    Value (Item)

    2024-11-05 16:58:40
    173082229813907

    2024-11-05 16:55:41
    173082211799967

    ...


    but my Trigger does not work.

    Trigger Definition:
    (now() - last(/AD-SRV-0002/folder.lastmodtime["C:\ProgramData\FTPGetter\LOG"])) > 300s

    If I stop the ftp tool, which caused that there is no longer modify in the logfile directory (i see it also in Latest Data (same [old] value [unix-timestamp] for over 15 minutes) nothing happend.

    If I change from larger ( > 300s) to smaller (< 300s) the alert box (trigger) works. Also when I stopped the tool and there is obviously no change in the directory

    Latest Data:

    2024-11-05 17:22:40
    173082304882813


    2024-11-05 17:19:40
    173082304882813

    2024-11-05 17:16:40
    173082304882813

    2024-11-05 17:13:41
    173082304882813


    , it will work (even also after 300 seconds) and the alert message did not disappear.
    But smaller (< 300) does not make sense for me.

    Any ideas for me?

    Thanks!
    Last edited by piti87; 05-11-2024, 18:23.
  • Answer selected by piti87 at 06-11-2024, 10:02.
    ISiroshtan
    Senior Member
    • Nov 2019
    • 324

    Your Powershell returns timestamp as microseconds, while Zabbix function now() returns in seconds. At the same time, for Zabbix math function both are just numbers. Microseconds returns WAAAAAAAY bigger number, so result of subtraction is a negative number, which is never >300 -> alert does not fire.

    Either modify PS script to return result in seconds, or rewrite trigger to be "now - (result_from,_ps / 1 000 000)"

    Comment

    • ISiroshtan
      Senior Member
      • Nov 2019
      • 324

      #2
      Your Powershell returns timestamp as microseconds, while Zabbix function now() returns in seconds. At the same time, for Zabbix math function both are just numbers. Microseconds returns WAAAAAAAY bigger number, so result of subtraction is a negative number, which is never >300 -> alert does not fire.

      Either modify PS script to return result in seconds, or rewrite trigger to be "now - (result_from,_ps / 1 000 000)"

      Comment

      • piti87
        Junior Member
        • Jun 2020
        • 23

        #3
        That's it. A big thank you to you!!
        Simple but comprehensible solution.

        Regards

        Comment

        Working...