Ad Widget

Collapse

Unix Timestamp in Items

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MRedbourne
    Senior Member
    • Feb 2023
    • 103

    #1

    Unix Timestamp in Items

    Hey Folks,

    Environment (Agents): All servers are RHEL9 x86_64, agent version Zabbix Agent2 (7.0.4-7.0.6)
    Environment (Servers): RHEL9 x86_64 Zabbix 7.0.4 in HA. No proxies.

    I'm adding some more systemd information on specific services we monitor outside what any of the normal templates will do for us. Two of the pieces of information I'm looking to get are "ActiveEnterTimestamp" and "ActiveExitTimestamp", returned via systemd.unit.info[<service>,<property>,...]. 1 Zabbix agent 2. We can get the UNIX timestamps just fine. However, when we set unit value to "unixtime" in the item, creates a display value that is evidently wrong. In the screenshot attached of "latest data", we see that the epoch/unix timestamp is 1734495447181053, which when converted through a public converter such as Epoch Converter - Unix Timestamp Converter​, we get a value of approx. Dec 18, 2024 3:17PM GMT+11. This is correct, given I patched the software (and restarted the service between 3PM and 4PM last night.

    When I look at the value Zabbix converts it to, I just get "> 2038-01-18 11:14:07 PM", which is evidently incorrect. If I reference the docs in the systemd (via Zabbix Agent 2), the docs list the time in microseconds, the same value I'm returning via the item.

    Does anyone know how to fix the unit in Zabbix server to it displays the correct date, or is this a bug?
    Attached Files
  • Answer selected by MRedbourne at 20-12-2024, 05:14.
    ISiroshtan
    Senior Member
    • Nov 2019
    • 324

    I'm pretty sure unix timestamp supposed to be in seconds, the timestamp you get from systemd is in microseconds. Try to add 'Custom multiplier" preprocessing with value of 0,000001 onto the item and see if it fixes the issue for you.

    Comment

    • mrnobody
      Member
      • Oct 2024
      • 61

      #2
      If you are having problems using agent + automatic conversion. Alternatively you can use a item with external check to run script that executes like "systemctl show --property=ActiveEnterTimestamp PROCNAME"

      Comment

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #3
        I'm pretty sure unix timestamp supposed to be in seconds, the timestamp you get from systemd is in microseconds. Try to add 'Custom multiplier" preprocessing with value of 0,000001 onto the item and see if it fixes the issue for you.

        Comment

        • MRedbourne
          Senior Member
          • Feb 2023
          • 103

          #4
          Originally posted by ISiroshtan
          I'm pretty sure unix timestamp supposed to be in seconds, the timestamp you get from systemd is in microseconds. Try to add 'Custom multiplier" preprocessing with value of 0,000001 onto the item and see if it fixes the issue for you.
          Jeez. I had tried something similar Value: (1/(1000*1000)) and it threw a floating point error. I just assumed it was unhappy as the division would create a floating point, not that it wanted a floating point as the value for preprocessing. Thank you for putting the same value in a different format. That worked.

          Comment

          Working...