python-diamond / Diamond

Diamond is a python daemon that collects system metrics and publishes them to Graphite (and others). It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.
http://diamond.readthedocs.org/
MIT License
1.74k stars 602 forks source link

[wip] Python 3 #762

Open erkie opened 2 years ago

erkie commented 2 years ago

It felt kinda weird that there was absolutely nothing in this repo about how to run Diamond using Python 3. Like many others I recently upgraded to Ubuntu 20.04 which does not ship with a fully formed python 2.7 environment so I gave a stab at making it work with Python 3.

This is very much a WIP but I got it running fully for our setup.

How to install for you:

pip3 install distro
pip3 install git+https://github.com/feederco/Diamond.git@d8429765009fdf115c85aca09a5f2c1b570f8078

Since platform.distro() was deprecated in 3.8 which setup.py relied on it now uses distro, which is a pip module that needs to be installed before running pip install diamond.

Todo:

References #396

erkie commented 2 years ago

Btw, since this is running fine in our environment I won't be working more on this. Any additional PR's and help is greatly appreciated.

shortdudey123 commented 1 year ago

Can you split out the diamond relative to full from /import statements like at the top of the handler files to a separate PR? Those changes are non-breaking and I can merge it right away. Also include the three lines changed in bin/diamond.

erkie commented 1 year ago

@shortdudey123 I won't have time to do this anytime soon, sorry! Feel free to take over this branch or if any future readers see this please feel free to work off this branch 🙏

kt97679 commented 1 year ago

Thank you very much for the effort @erkie ! Based on your change I introduced more fixes to make diamond work in my environment: https://github.com/kt97679/Diamond/commit/8fee22d11f0928b2548c3f78dc3b3ae4b285f70a I would like to emphasize that I had to change config processing in the src/diamond/collector.py: https://github.com/kt97679/Diamond/commit/8fee22d11f0928b2548c3f78dc3b3ae4b285f70a#diff-65d20bb86255c9b2b68200bc4532b54b0c3fea580cf4ccaa0181c8259b2c2f6aL199-R208 I noticed that subsections using double square brackets are not parsed correctly so I switched from

[collectors]
...
[[default]]

to

[collectors]
...
[collectors.default]

Other changes are mostly automatic from the 2to3 script. In some places I had to add encode()/decode() logic.