Netdata Community

Using ayncio and mtrpacket with Python.d.plugin by switching to Python3

I am tryinng to write a data collection module in Python and I need to use these libraries, asyncio and mtrpacket, that are written for Python3. However, python.d, uses pythonv2 for debugging and I have a SyntaxError while running the code. The error is:

[mtr] error on loading source : SyntaxError(‘invalid syntax’, (’/usr/libexec/netdata/python.d/’, 16, 9, ‘async def trace(host):\n’)), skipping it

Is there any way to switch to Python3 in order to use these libraries?

Netdata is installed on Ubuntu 18.04 laptop.

Any help would be extremely useful.

1 Like

Hey @LydiaKN,

Welcome to our community!

As per the following GitHub issue, it is possible to use python3 for both the debug and the normal use of Netdata.

To enable python3 for Netdata in general, please go to netdata.conf and make the following additions:

	# update every = 1
	command options = -ppython3

For the debug, you will need to pass the python version as an argument: ./python.d.plugin -ppython3 <name_of_plugin> debug trace

If it doesn’t work out, please tell me so and we will make it work!

We would love to hear about the collector you have created! If you want to share more about your use-case, why you created the collector, and how you use it, we would love to continue the discussion in #agent-development. If you need any help in further developing your collector, just create a new topic there!


1 Like

Thank you very much for your quick and helpful reply.
I am trying to create a chart, which displays every RTT(round trip time) of packets, received from each successive host in a network path(route).

1 Like

@ilyam8 perhaps you will find this interesting :v: