add more logging to ping plugin
This commit is contained in:
parent
06e97756c8
commit
7651651867
|
|
@ -208,6 +208,7 @@ func (p *Ping) pingToURLNative(destination string, acc telegraf.Accumulator) {
|
|||
|
||||
stats, err := p.nativePingFunc(destination)
|
||||
if err != nil {
|
||||
p.Log.Errorf("ping failed: %s", err.Error())
|
||||
if strings.Contains(err.Error(), "unknown") {
|
||||
fields["result_code"] = 1
|
||||
} else {
|
||||
|
|
@ -224,12 +225,14 @@ func (p *Ping) pingToURLNative(destination string, acc telegraf.Accumulator) {
|
|||
}
|
||||
|
||||
if stats.PacketsSent == 0 {
|
||||
p.Log.Debug("no packets sent")
|
||||
fields["result_code"] = 2
|
||||
acc.AddFields("ping", fields, tags)
|
||||
return
|
||||
}
|
||||
|
||||
if stats.PacketsRecv == 0 {
|
||||
p.Log.Debug("no packets received")
|
||||
fields["result_code"] = 1
|
||||
fields["percent_packet_loss"] = float64(100)
|
||||
acc.AddFields("ping", fields, tags)
|
||||
|
|
|
|||
Loading…
Reference in New Issue