caas-team / sparrow

A monitoring tool to gather infrastructure network information
Apache License 2.0
6 stars 4 forks source link

Feat/traceroute #113

Closed niklastreml closed 3 months ago

niklastreml commented 4 months ago

Motivation

This pr implements a basic traceroute check.

Relates to #111, #112

Currently its using "github.com/aeden/traceroute" to implement the actual tracerouting logic, but I intend to to change this in the near future (more on this in #112).

In case you're testing this locally

The check is extremely slow, since it creates a lot of network requests. I tried to improve by concurrently running the check for every target, but the internals of the library do everything synchronously so there isn't much we can actually improve there outside of #112. While developing I used the below config, with retries set to 0, and it took a minute or so per run of the check.

Config

traceroute:
  interval: 5s
  timeout: 3s
  retries: 3
  maxHops: 8
  targets:
    - addr: 8.8.8.8

Debugging

Since this check requires extra permissions to open the required sockets, debugging is a bit complicated. I have added a script in scripts/debug-elevated.sh which compiles sparrow as an unoptimized binary and launches it with a headless debugger and elevated permissions. You can then use the Connect to server target in the .vscode/launch.json to connect to the debugger and debug as usual. This is only necessary, when you actually need to debug the traceroute check, you can debug the others as usual.

Changes

For additional information look at the commits.

Tests done

TODO

lvlcn-t commented 4 months ago

@niklastreml Please also document the check in a new section of the README.