Add ability to have multiple monitors, and to change ping ID field #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Note, this change is dependent on upstream repo changes (digineo/go-ping/pull/19) which haven't been merged yet, so probably should not be merged until that happens]
This PR adds some new functionality:
identifier
field differently for different monitors, so they will generally be considered different "sessions" by NAT gateways, etc.identifier
for pings periodically, or under certain conditions (high packet loss, etc).I mostly added these features to deal with some situations in my own networking setup which the existing code could not really handle:
I have a NAT gateway router with redundant links to the internet (a main connection, and a backup DSL connection). Because the two outbound links use different NAT addresses, each outbound ping session gets tied to a particular interface, and all packets for that session will go out that interface, regardless of their destination, so I was unable to correctly ping both remote gateways at the same time, for example (because packets for one or the other would go out the interface for the other one).
Additionally, I discovered if something happened to the primary connection, and the gateway automatically failed over to using the backup, all the overall internet connection continued to work for everything else, but any ping targets beyond the gateway would show up as not responding (because the NAT session for that ping ID was still tied to the failed connection, and would not fail over when everything else did). With these changes, I can now configure the ping_exporter to essentially initiate a new ping session whenever packet loss indicates something has happened to the primary connection, or just periodically change it after a certain amount of time (to account for fail-back, etc).
(Sorry this is such a big PR, but it all kinda evolved as a bunch of interrelated changes..)