Asking for a help with creating a collector which will take information from text file

Hello everyone!

I was wondering if there’s anyone willing to help me (or guide me through) with a following idea/problem:

I’ve got a Wireguard docker container working on my server, with multiple users (peers) logging into VPN server.
I have an output (wg show) using which I can see the total traffic consumption of every peer. Every time I’m entering “wg show” the number increases.

I need to grab/parse the information from this output about each peer and put it into monitoring system to see how much traffic each peer consumes.

Unfortunately, I’m not a coder/developer by any means and the most I managed to do is to generate a .txt file with the output of that command. I might be able to parse the required data in some kind of dictionary { peer : traffic_consumption } using Python, but that’s my maximum level of programming languages.
I tried to figure out if this is possible to do with any existing collectors, but got no luck.

If there’s someone who has any idea on how to do this, I’d appreciate any help!

Thank you.

I think this guide will help you: Develop a custom data collector in Python | Learn Netdata

Thanks for your reply.
It will take me a significant time to dive into this guide and manage it (Which I don’t mind doing at all), but can you tell me from the top of your head if it’s even possible to collect the “numbers” (the bandwidth used each, say, minute) and build a graph out of it, using that guide?
It’s incredibly difficult to understand whether it’s even possible to be done when you’ve got no experience in it.
Thanks.

Yes, it is possible.

1 Like

The best way to accomplish this with limited programming knowledge is to find an existing python collector that does almost exactly the same thing for a different command. I wouldn’t bother with the .txt file to be honest, it’s just one more step that could go wrong.

One example of a python collector that executes a shell command and processes the output is Adaptec RAID controller monitoring with Netdata | Learn Netdata. I’m sure you will find many more in that category.

I would actually take it a step further, to reduce the code required and process the output of wg show in the shell ahead of time, e.g. by doing wg show | grep xyz | awk '{print ...}', so that you only get back exactly what you want in your charts (namely, names and values).

Another option is for you to describe precisely what charts would make sense to see (i.e. how they would be organized and what they would contain) and we write the collector in go instead. I believe that option would be preferrable. You can create an issue in netdata/netdata for that and one of the guys will collaborate with you to get it done.

1 Like

Hello Christopher,

The latter option is the one I’d like to follow. I’d try to create an issue as you suggested and see if someone would be interested to help me there.

Thank you!

Great, please link to it from here when you create it.

1 Like

That’s the link to the issue created. I’ll also cross-link this thread to the issue.