oetiker / SmokePing

The Active Monitoring System
http://www.smokeping.org
GNU General Public License v2.0
1.35k stars 182 forks source link

Adding InfluxDB support to smokeping #201

Closed mad-ady closed 2 years ago

mad-ady commented 4 years ago

Hello all!

We're using smokeping to do some automated network parameter measurements to check on the perceived service quality we offer our end customers. We're using remote probes/slaves to do measurements from different points in the network and aggregating the data on the master. I've also created some plugins in the past few years, so we want to stick with smokeping for the measurements.

However, the web GUI is not really suitable for large scale data analysis. It's ok for historical analysis only. So, I'm planning on making a few (hopefully small) changes to smokeping to add support to write the measurements in an influxdb database, in addition to storing them as RRD. I hope to be able to push the changes (once they're working) to the main Smokeping branch. Having data in influxdb allows easier automated analysis (e.g. using an sql-like language to get the latest measurements for a destination from all the slaves, without having to parse the RRD files). It also opens up the possibility to have views exposed in Grafana and other more modern data visualization tools.

Here's what I'm planning:

  1. Allow the addition of custom configuration options to the config file so that those options can be mapped to influxdb tags (so that they are easily searchable in influxdb). For instance, something like this:
    
    + Hosts_in_region_A
    menu = Hosts in region A
    title = Hosts in region A

++ client1 host = 192.168.1.1 probe = fping influx_download = 100Mbps influx_upload = 10Mbps influx_service_type = FTTB


For now, when I try to add configuration options that are not defined, I
get the error:

ERROR: /opt/smokeping/bin/../etc/config, line 144: unknown variable 'influx_download'


I'm guessing I need to bypass or extend the parser so that such errors
are ignored, or become warnings. Or, better yet, if I stick with the
prefix influx_ I can make it accept any influx_ parameter, but complain
on other typos (which is useful). I'll need to do some reading on the
Grammar module...

2. Add a new config section that defines connectivity to influxdb (URL,
user, password)

3. Add a hook inside update_rrds() to intercept the data before being
written to the RRD (before or after the call to RRDs::update). Push the
raw data to influxdb (either inline for efficiency, or with a new
function call for readability).

I'm not 100% certain that the update_rrds() from Smokeping.pm gets
called for slave updates as well, or there is an equivalent in the CGI
interface. I'm guessing it's the same, but I will do some tests when I
get there.

So - what are your thoughts on this? Are there better/easier ways of
doing it?

Thanks!
JimKlapwijk commented 3 years ago

Hi @mad-ady. I'm afraid I can't code Perl, so I don't think this is a job for me unfortunately. If you happen to have time to take a look at it, that'd be really cool! In the mean time I'll try and setup a HAproxy or something in front of it to handle HTTP.

If you need testers, I'd be happy to lend you a hand, though I use a valid certificate, not self-signed. Thanks!

github-actions[bot] commented 3 years ago

This issue has become stale and will be closed automatically within 7 days. Comment on the issue to keep it alive.

JimKlapwijk commented 3 years ago

I don't want this to get closed, as I've been using it for months without any issues!

@mad-ady Any progress on the HTTPS support by any chance?

mad-ady commented 3 years ago

Well, if you've been using it for months, then it's not an issue anymore, is it? :rofl:

Regarding https - I must have forgotten about it :disappointed: ... I opened a new ticket with InfluxDB::HTTP creator, maybe he has the time to help out: https://github.com/raphaelthomas/InfluxDB-HTTP/issues/9 Regarding time to do it myself - sadly there is none in the foreseeable future :(

JimKlapwijk commented 3 years ago

Yeah it works fine with HTTP using a HAproxy in front of InfluxDB, but I'd like to remove the HAproxy part and directly talk HTTPS to it as a few other applications I use do support it.

We'll see if the creator has time, but is this by any chance what we are looking for? https://github.com/raphaelthomas/InfluxDB-HTTP/pull/7

mad-ady commented 3 years ago

Yes! That fork of InfluxDB::HTTP looks like it added SSL support. In order to use it with the current Smokeping release you can try the following hack:

JimKlapwijk commented 3 years ago

Hi @mad-ady. I installed the fork version, and made the changes, but I get the following error:

Aug 12 10:44:08 smokeping systemd[1]: Starting Latency Logging and Graphing System...
Aug 12 10:44:09 smokeping smokeping[459158]: Couldn't find declarator 'method' at /usr/local/lib/x86_64-linux-gnu/perl/5.32.1/Devel/Declare/Context/Simple.pm line 47.
Aug 12 10:44:09 smokeping smokeping[459158]:         Devel::Declare::Context::Simple::skip_declarator(Method::Signatures=HASH(0x55a34d90ecf0)) called at /usr/local/share/perl/5.32.1/Method/Signatures.pm line 877
Aug 12 10:44:09 smokeping smokeping[459158]:         Method::Signatures::parser(Method::Signatures=HASH(0x55a34d90ecf0), "method", 77, 1) called at /usr/local/lib/x86_64-linux-gnu/perl/5.32.1/Devel/Declare/MethodInstaller/Simple.pm line 25
Aug 12 10:44:09 smokeping smokeping[459158]:         Devel::Declare::MethodInstaller::Simple::__ANON__("method", 77) called at /usr/local/lib/x86_64-linux-gnu/perl/5.32.1/Devel/Declare.pm line 277
Aug 12 10:44:09 smokeping smokeping[459158]:         Devel::Declare::linestr_callback("const", "method", 77) called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108
Aug 12 10:44:09 smokeping smokeping[459158]:         require InfluxDB/HTTP.pm called at /usr/share/perl5/Smokeping.pm line 26
Aug 12 10:44:09 smokeping smokeping[459158]:         Smokeping::BEGIN() called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108
Aug 12 10:44:09 smokeping smokeping[459158]:         eval {...} called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108
Aug 12 10:44:09 smokeping smokeping[459158]:         require Smokeping.pm called at /usr/sbin/smokeping line 9
Aug 12 10:44:09 smokeping smokeping[459158]:         main::BEGIN() called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108
Aug 12 10:44:09 smokeping smokeping[459158]:         eval {...} called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108
Aug 12 10:44:09 smokeping smokeping[459158]: Compilation failed in require at /usr/share/perl5/Smokeping.pm line 26.
Aug 12 10:44:09 smokeping smokeping[459158]: BEGIN failed--compilation aborted at /usr/share/perl5/Smokeping.pm line 26.
Aug 12 10:44:09 smokeping smokeping[459158]: Compilation failed in require at /usr/sbin/smokeping line 9.
Aug 12 10:44:09 smokeping smokeping[459158]: BEGIN failed--compilation aborted at /usr/sbin/smokeping line 9.
Aug 12 10:44:09 smokeping systemd[1]: smokeping.service: Control process exited, code=exited, status=255/EXCEPTION
Aug 12 10:44:09 smokeping systemd[1]: smokeping.service: Failed with result 'exit-code'.
Aug 12 10:44:09 smokeping systemd[1]: Failed to start Latency Logging and Graphing System.

Does this tell you anything? Wasn't able to figure this out with Google.

mad-ady commented 3 years ago
  1. Make sure you pull the InfluxDB::HTTP from the develop branch, not the master branch.
  2. Note that the forked version has additional dependencies. You will probably need to install some extra perl module, like these: 'Attribute::Handlers'=>0, 'Clone'=>0, 'InfluxDB::LineProtocol'=>0, 'List::MoreUtils'=>0, 'JSON::MaybeXS'=>0, 'LWP::Protocol::http'=>0, 'LWP::Protocol::https'=>0, 'LWP::UserAgent'=>0, 'Object::Result'=>0, 'Sub::Delete'=>0, 'Switch'=>0, 'URI'=>0

It's also a good idea to run make test on InfluxDB::HTTP. Maybe it can prove if it works or not...

On Thu, Aug 12, 2021 at 12:13 PM JimKlapwijk @.***> wrote:

Hi @mad-ady https://github.com/mad-ady. I installed the fork version, and made the changes, but I get the following error:

Aug 12 10:44:08 smokeping systemd[1]: Starting Latency Logging and Graphing System... Aug 12 10:44:09 smokeping smokeping[459158]: Couldn't find declarator 'method' at /usr/local/lib/x86_64-linux-gnu/perl/5.32.1/Devel/Declare/Context/Simple.pm line 47. Aug 12 10:44:09 smokeping smokeping[459158]: Devel::Declare::Context::Simple::skip_declarator(Method::Signatures=HASH(0x55a34d90ecf0)) called at /usr/local/share/perl/5.32.1/Method/Signatures.pm line 877 Aug 12 10:44:09 smokeping smokeping[459158]: Method::Signatures::parser(Method::Signatures=HASH(0x55a34d90ecf0), "method", 77, 1) called at /usr/local/lib/x86_64-linux-gnu/perl/5.32.1/Devel/Declare/MethodInstaller/Simple.pm line 25 Aug 12 10:44:09 smokeping smokeping[459158]: Devel::Declare::MethodInstaller::Simple::ANON("method", 77) called at /usr/local/lib/x86_64-linux-gnu/perl/5.32.1/Devel/Declare.pm line 277 Aug 12 10:44:09 smokeping smokeping[459158]: Devel::Declare::linestr_callback("const", "method", 77) called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108 Aug 12 10:44:09 smokeping smokeping[459158]: require InfluxDB/HTTP.pm called at /usr/share/perl5/Smokeping.pm line 26 Aug 12 10:44:09 smokeping smokeping[459158]: Smokeping::BEGIN() called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108 Aug 12 10:44:09 smokeping smokeping[459158]: eval {...} called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108 Aug 12 10:44:09 smokeping smokeping[459158]: require Smokeping.pm called at /usr/sbin/smokeping line 9 Aug 12 10:44:09 smokeping smokeping[459158]: main::BEGIN() called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108 Aug 12 10:44:09 smokeping smokeping[459158]: eval {...} called at /usr/local/share/perl/5.32.1/InfluxDB/HTTP.pm line 108 Aug 12 10:44:09 smokeping smokeping[459158]: Compilation failed in require at /usr/share/perl5/Smokeping.pm line 26. Aug 12 10:44:09 smokeping smokeping[459158]: BEGIN failed--compilation aborted at /usr/share/perl5/Smokeping.pm line 26. Aug 12 10:44:09 smokeping smokeping[459158]: Compilation failed in require at /usr/sbin/smokeping line 9. Aug 12 10:44:09 smokeping smokeping[459158]: BEGIN failed--compilation aborted at /usr/sbin/smokeping line 9. Aug 12 10:44:09 smokeping systemd[1]: smokeping.service: Control process exited, code=exited, status=255/EXCEPTION Aug 12 10:44:09 smokeping systemd[1]: smokeping.service: Failed with result 'exit-code'. Aug 12 10:44:09 smokeping systemd[1]: Failed to start Latency Logging and Graphing System.

Does this tell you anything? Wasn't able to figure this out with Google.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oetiker/SmokePing/issues/201#issuecomment-897477344, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAO6KTF6FKQ2WMC5PQNKY3T4OGDPANCNFSM4I6AUBOA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

JimKlapwijk commented 3 years ago
root@smokeping:~/InfluxDB-HTTP# make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
Files=0, Tests=0,  0 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
Result: NOTESTS

It complained about 2 dependencies missing, which I installed, List::MoreUtils and Sub::Delete, and had to install libswitch-perl via apt.

All other dependencies are installed with the latest version. I also commented on the person who created the fork, hopefully he responds, but since the pull request was created in 2019, I doubt it.

mad-ady commented 3 years ago

Let's just say that his unit testing is on the light side: "Tests=0"...

On Fri, Aug 13, 2021 at 10:28 AM JimKlapwijk @.***> wrote:

@.**:~/InfluxDB-HTTP# make test PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t Files=0, Tests=0, 0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU) Result: NOTESTS

It complained about 2 dependencies missing, which I installed, List::MoreUtils and Sub::Delete, and had to install libswitch-perl via apt.

All other dependencies are installed with the latest version. I also commented on the person who created the fork, hopefully he responds, but since the pull request was created in 2019, I doubt it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oetiker/SmokePing/issues/201#issuecomment-898250197, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAO6KVXDWOFIKB4AN5J64DT4TCSJANCNFSM4I6AUBOA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

JimKlapwijk commented 3 years ago

Yeah, but the original gives the same result:

root@smokeping:~/test/InfluxDB-HTTP# make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
Files=0, Tests=0,  0 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
Result: NOTESTS

So not really helpful at all.

github-actions[bot] commented 2 years ago

This issue has become stale and will be closed automatically within 7 days. Comment on the issue to keep it alive.

JimKlapwijk commented 2 years ago

Bump, since I don't want this to be stale and merged in master :D

oetiker commented 2 years ago

hmmm I thought we had merged it all ... is there something missing?

mad-ady commented 2 years ago

I think @JimKlapwijk wants to have HTTPS support for InfluxDB, which depends on InfluxDB::HTTP supporting it - https://github.com/raphaelthomas/InfluxDB-HTTP/issues/9. Once it support HTTPS there are some extra config parameters that need to be added to Smokeping.

On Fri, Nov 12, 2021 at 10:34 AM Tobias Oetiker @.***> wrote:

hmmm I thought we had merged it all ... is there something missing?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oetiker/SmokePing/issues/201#issuecomment-966919046, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAO6KSWUSDVOZXSPV6FNWLULTGR7ANCNFSM4I6AUBOA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

JimKlapwijk commented 2 years ago

hmmm I thought we had merged it all ... is there something missing?

I think I'm a bit confused, it seems to be merged but the packages in Debian don't have the merge request from @mad-ady in them, hence when I install the package I didn't have InfluxDB integrated. So the question should be, is there a package release version with this, or what needs to be done to do this? I'm running Debian 11:

# apt search smokeping
Sorting... Done
Full Text Search... Done
smokeping/stable,now 2.7.3-3 all [installed]
  latency logging and graphing system

For now I guess I'll switch my Saltstack playbook to compile the master I think...

github-actions[bot] commented 2 years ago

This issue has become stale and will be closed automatically within 7 days. Comment on the issue to keep it alive.

clintonherring commented 1 month ago

are there any details on how to get this to work with influxdb 2? I set it up successfully using 1.8 but it doesn't work with 2

mad-ady commented 1 month ago

Sorry, the perl module used for the integration suports influx 1.x. I (personally) don't have plans to port the changes for Influx 2.x. Since my original project for which I used this is closed, I don't have the motivation (nor time) to pursue it further.

But somebody could continue based on what I submitted here and add influx 2 support.