Ad Widget

Collapse

Writing Active Zabbix Agent, what to send in “clock” and “ns”

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • allardkrings
    Junior Member
    • Oct 2020
    • 5

    #1

    Writing Active Zabbix Agent, what to send in “clock” and “ns”

    Hello,

    I am writing my own zabbix-agent for z/OS in REXX

    Everything works fine, the agent gets the active checks from the zabbix-server, the agent sends back the response, the zabbix server processes my response,

    however I am not sure what to put in the fields “clock” and “ns”

    Below is the example of the message protocol from the Zabbix documentation:


    <HEADER><DATALEN>
    { "request":"agent data",
    "data":[
    {
    "host":"<hostname>",
    "key":"agent.version",
    "value":"2.4.0",
    "clock":1400675595,
    "ns:6808644
    }
    ],
    "clock": 1400675595,
    "ns": 78211329
    }

    Anybody can explain the meaning of these fields is?

    Thanks in advance!

    Kind regards

    Allard
  • dimir
    Zabbix developer
    • Apr 2011
    • 1080

    #2
    Code:
    {
      "request":"agent data",
      "data":[
        {
          "host":"<hostname>",
          "key":"agent.version",
          "value":"2.4.0",
          "clock":1400675595, <-- value timestamp, when it was collected, seconds
          "ns:6808644         <-- value timestamp, when it was collected, nanoseconds
        }
      ],
      "clock": 1400675595, <-- timestamp of the whole request, when it was generated, seconds
      "ns": 78211329       <-- timestamp of the whole request, when it was generated, nanoseconds
    }

    Comment

    • allardkrings
      Junior Member
      • Oct 2020
      • 5

      #3
      Hello Dimir,

      thanks a lot for your quick response!

      Could you give me more information on the timestamp ? Relative to what moment should te values be calculated?

      Is it UNIX standard Epoch?

      If I take that value for today and now i get: “clock”: 1618073802
      Or in nanoseconds : “ns”: 1618073802000000000

      both are much longer than the example

      Kind regards

      Allard

      Comment

      • dimir
        Zabbix developer
        • Apr 2011
        • 1080

        #4
        In the "agent data" packet you have an array of metrics + timestamp of the packet itself. When an agent is collecting a metric it remembers the timestamp when it was collected, thus each metric has its pair - "value + timestamp of the value".

        When collected data is sent to server/proxy it's combined in one request as an array. When this request is generated it is assigned the creation timestamp too.

        Each "timestamp" in Zabbix is represented as pair "clock+ns". As to the "clock", yes, it's just the unix standard timestamp aka Epoch. The nanoseconds is additional fraction of the following second, i. e. it's the value from 0 to 999999999. Nanoseconds make sense for rare cases when the item can receive more than one value in a second. If you are sure that's not your case you can always set nanosecond to 0:
        Code:
        {
          "request":"agent data",
          "data":[
            {
              "host":"<hostname>",
              "key":"agent.version",
              "value":"2.4.0",
              "clock":1400675592
              "ns":0
            },
            {
              "host":"<hostname>",
              "key":"agent.hostname",
              "value":"webserver",
              "clock":1400675590
              "ns":0
            }
          ],
          "clock": 1400675595
          "ns": 0
        }
        Last edited by dimir; 10-04-2021, 20:06.

        Comment

        Working...