@@ -93,32 +93,32 @@ func processPingOutput(out string) (int, int, int, int, int, int, error) {
9393
9494 // stats data should contain 4 members: entireExpression + ( Send, Receive, Lost )
9595 if len (stats ) != 4 {
96- return 0 , 0 , 0 , 0 , 0 , 0 , err
96+ return 0 , 0 , 0 , - 1 , - 1 , - 1 , err
9797 }
9898 trans , err := strconv .Atoi (stats [1 ])
9999 if err != nil {
100- return 0 , 0 , 0 , 0 , 0 , 0 , err
100+ return 0 , 0 , 0 , - 1 , - 1 , - 1 , err
101101 }
102102 receivedPacket , err := strconv .Atoi (stats [2 ])
103103 if err != nil {
104- return 0 , 0 , 0 , 0 , 0 , 0 , err
104+ return 0 , 0 , 0 , - 1 , - 1 , - 1 , err
105105 }
106106
107107 // aproxs data should contain 4 members: entireExpression + ( min, max, avg )
108108 if len (aproxs ) != 4 {
109- return trans , receivedReply , receivedPacket , 0 , 0 , 0 , err
109+ return trans , receivedReply , receivedPacket , - 1 , - 1 , - 1 , err
110110 }
111111 min , err := strconv .Atoi (aproxs [1 ])
112112 if err != nil {
113- return trans , receivedReply , receivedPacket , 0 , 0 , 0 , err
113+ return trans , receivedReply , receivedPacket , - 1 , - 1 , - 1 , err
114114 }
115115 max , err := strconv .Atoi (aproxs [2 ])
116116 if err != nil {
117- return trans , receivedReply , receivedPacket , 0 , 0 , 0 , err
117+ return trans , receivedReply , receivedPacket , - 1 , - 1 , - 1 , err
118118 }
119119 avg , err := strconv .Atoi (aproxs [3 ])
120120 if err != nil {
121- return 0 , 0 , 0 , 0 , 0 , 0 , err
121+ return 0 , 0 , 0 , - 1 , - 1 , - 1 , err
122122 }
123123
124124 return trans , receivedReply , receivedPacket , avg , min , max , err
@@ -201,13 +201,13 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
201201 fields ["packets_received" ] = receivePacket
202202 fields ["percent_packet_loss" ] = lossPackets
203203 fields ["percent_reply_loss" ] = lossReply
204- if avg > 0 {
204+ if avg >= 0 {
205205 fields ["average_response_ms" ] = float64 (avg )
206206 }
207- if min > 0 {
207+ if min >= 0 {
208208 fields ["minimum_response_ms" ] = float64 (min )
209209 }
210- if max > 0 {
210+ if max >= 0 {
211211 fields ["maximum_response_ms" ] = float64 (max )
212212 }
213213 acc .AddFields ("ping" , fields , tags )
0 commit comments