Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced ICMP options #240

Merged
merged 3 commits into from
Oct 6, 2017
Merged

Conversation

gouthamve
Copy link
Member

@gouthamve gouthamve commented Oct 2, 2017

@RichiH wanted to add the payload size and DF-bit to be configurable in the ICMP prober. While I had fun implementing this, I would like to know if this is okay before I put in more effort.

cc/ @brian-brazil @SuperQ


This change is Reviewable

config/config.go Outdated
@@ -96,7 +96,8 @@ type TCPProbe struct {

type ICMPProbe struct {
PreferredIPProtocol string `yaml:"preferred_ip_protocol,omitempty"` // Defaults to "ip6".

Payload int `yaml:"payload,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PayloadSize would make more sense

config/config.go Outdated
@@ -96,7 +96,8 @@ type TCPProbe struct {

type ICMPProbe struct {
PreferredIPProtocol string `yaml:"preferred_ip_protocol,omitempty"` // Defaults to "ip6".

Payload int `yaml:"payload,omitempty"`
DontFragment bool `yaml:"dontfragment,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont_fragment

prober/icmp.go Outdated
copy(data, "Prometheus Blackbox Exporter")
} else {
data = []byte("Prometheus Blackbox Exporter")
payload = 1500 // The usual MTU size.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

prober/icmp.go Outdated
@@ -136,3 +132,96 @@ func ProbeICMP(ctx context.Context, target string, module config.Module, registr
}
}
}

func getICMPSocket(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you're buying much by breaking this out, and it also makes it more difficult to review what has changed in the code

}

func (c *dfConn) ReadFrom(b []byte) (int, net.Addr, error) {
h, p, _, err := c.c.ReadFrom(b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work on Windows, which is a supported platform.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you propose I move about this? Different files for nix and windows? Or error when reading config?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First see if this can be done with Windows, we should be aiming for feature parity

@SuperQ
Copy link
Member

SuperQ commented Oct 2, 2017

Feature idea seems good to me.

@gouthamve gouthamve force-pushed the icmp-payload-config branch 2 times, most recently from 6a6d3ca to cebe76f Compare October 2, 2017 13:19
@gouthamve
Copy link
Member Author

Updated to incorporate feedback and to error if DontFragment is set on windows. Don't have a windows machine to test though.

@gouthamve gouthamve force-pushed the icmp-payload-config branch from cebe76f to 482d59b Compare October 2, 2017 13:24
@gouthamve gouthamve changed the title [WIP]: Advanced ICMP options Advanced ICMP options Oct 2, 2017
CONFIGURATION.md Outdated
@@ -168,6 +168,12 @@ validate_additional_rrs:
# The preferred IP protocol of the ICMP probe (ip4, ip6).
[ preferred_ip_protocol: <string> | default = "ip6" ]

# Set the DF-Bit in the IP-header. Only works with ip4 and on *nix systems.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bit

prober/icmp.go Outdated
copy(data[:], "Prometheus Blackbox Exporter")
if module.ICMP.PayloadSize != 0 {
data = make([]byte, module.ICMP.PayloadSize)
copy(data, "Prometheus Blackbox Exporter")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the payload size is smaller than this string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://play.golang.org/p/qrDFrlW6He Then only the payload size will be sen't with truncated string.

Signed-off-by: Goutham Veeramachaneni <[email protected]>
@gouthamve gouthamve force-pushed the icmp-payload-config branch from a00c3ad to 00d6bae Compare October 3, 2017 10:51
var data []byte
if module.ICMP.PayloadSize != 0 {
data = make([]byte, module.ICMP.PayloadSize)
copy(data, "Prometheus Blackbox Exporter")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, but it might make sense to include the exporter version in here.

@brian-brazil brian-brazil merged commit 4bc7b66 into prometheus:master Oct 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants