1

I am trying to send some data to an speficic item on the Zabbix Server. I found this library: https://github.com/kmomberg/pyZabbixSender In the example:

#Creating a sender object
z = pyZabbixSender(server="zabbix-server", port=10051)

# Adding data (without timestamp)
z.addData(hostname="test_host", key="test_trap_1", value="12")
z.addData("test_host", "test_trap_2", "2.43")

# Adding data (with timestamp)
z.addData("test_host", "test_trap_2", "2.43", 1365787627)

What Format is "1365787627" ? What Format is Zappix Server using? How to I get this in python script:

Background: I am have a remote Zabbix Server whichs is polling Data from an Raspberry Pi over the Agent. The interval time for the polling is about 2 sec. ->The Zabbix Server is not always online and I would like to store the data on the Raspberry Pi (mySQL database) and after I start the Zappix Server, I would like to import the Data (around 10-30 min of Sensor-Data ) by simply using a python script with this library

I hope somebody can help.

Sorry, could be newbie question->never worked with Zabbix before. By the way, if you have a better idea, how to do this, let me know :)

Greetings, Günther

GüntherMeng
  • 11
  • 1
  • 3

1 Answers1

1

It is using Epoch format.

You can get it in python script:-

import datetime

epoch = datetime.datetime.utcfromtimestamp(0)

def unix_time_millis(dt):
    return (dt - epoch).total_seconds() * 1000.0

so pass the datetime object you have to unix_time_millis and it will return the desired output.

reference : How can I convert a datetime object to milliseconds since epoch (unix time) in Python?

Community
  • 1
  • 1
Namit Singal
  • 1,506
  • 12
  • 26
  • thanks for the fast response. I would have two further more questions :) : First, the example uses an integer and you are returning an float, will that be a problem or do i just simply round ? 2.) I live in Berlin, do i have to change utcfromtimestamp(value) because we have GMT+1? – GüntherMeng Mar 20 '16 at 07:40
  • @GüntherMeng you can round it off, also it won't matter what timezone you have, since difference between the dates will remain the same regardless of the timezone. Hope that helps – Namit Singal Mar 20 '16 at 09:29