Skip to content

Commit

Permalink
add some more ping metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Jun 21, 2022
1 parent 8671425 commit 6701e97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ tar zcvf categraf.tar.gz categraf conf
- [ ] k8s solution
- [x] [kubernetes](inputs/kubernetes)
- [x] [kube_state_metrics](inputs/kube_state_metrics)
- [x] [nginx vts](inputs/nginx_vts)
- [x] [nginx_vts](inputs/nginx_vts)
- [ ] mongodb
- [ ] rocketmq
- [ ] activemq
Expand Down
11 changes: 11 additions & 0 deletions inputs/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,18 @@ func (ins *Instance) gather(slist *list.SafeList, target string) {
return
}

// Set TTL only on supported platform. See golang.org/x/net/ipv4/payload_cmsg.go
switch runtime.GOOS {
case "aix", "darwin", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
fields["ttl"] = stats.ttl
}

//nolint:unconvert // Conversion may be needed for float64 https://github.com/mdempsky/unconvert/issues/40
fields["percent_packet_loss"] = float64(stats.PacketLoss)
fields["minimum_response_ms"] = float64(stats.MinRtt) / float64(time.Millisecond)
fields["average_response_ms"] = float64(stats.AvgRtt) / float64(time.Millisecond)
fields["maximum_response_ms"] = float64(stats.MaxRtt) / float64(time.Millisecond)
fields["standard_deviation_ms"] = float64(stats.StdDevRtt) / float64(time.Millisecond)
}

type pingStats struct {
Expand Down

0 comments on commit 6701e97

Please sign in to comment.