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

inputs.ping: Add an option to specify packet size #9274

Merged
merged 2 commits into from May 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugins/inputs/ping/README.md
Expand Up @@ -70,6 +70,10 @@ native Go by the Telegraf process, eliminating the need to execute the system

## Use only IPv6 addresses when resolving a hostname.
# ipv6 = false

## Number of data bytes to be sent. Corresponds to the "-s"
## option of the ping command. This only works with the native method.
# size = 56
```

#### File Limit
Expand Down
11 changes: 11 additions & 0 deletions plugins/inputs/ping/ping.go
Expand Up @@ -73,6 +73,9 @@ type Ping struct {

// Calculate the given percentiles when using native method
Percentiles []int

// Packet size
Size int
}

func (*Ping) Description() string {
Expand Down Expand Up @@ -125,6 +128,10 @@ const sampleConfig = `

## Use only IPv6 addresses when resolving a hostname.
# ipv6 = false

## Number of data bytes to be sent. Corresponds to the "-s"
## option of the ping command. This only works with the native method.
# size = 56
`

func (*Ping) SampleConfig() string {
Expand Down Expand Up @@ -172,6 +179,10 @@ func (p *Ping) nativePing(destination string) (*pingStats, error) {
pinger.SetNetwork("ip6")
}

if p.Method == "native" {
pinger.Size = p.Size
sspaink marked this conversation as resolved.
Show resolved Hide resolved
}

pinger.Source = p.sourceAddress
pinger.Interval = p.calcInterval

Expand Down