@@ -257,21 +257,41 @@ def get_delta(name):
257257 return delta
258258
259259
260- def get_tcploss_vs_packets (name ):
260+ def get_tcploss_percentage (name ):
261261
262262 # get metrics
263263 [curr_metrics , last_metrics ] = get_metrics ()
264264
265- index_pkts = stats_pos ["tcpext" ]["tcphphits" ]
265+ index_outsegs = stats_pos ["tcp" ]["outsegs" ]
266+ index_insegs = stats_pos ["tcp" ]["insegs" ]
266267 index_loss = stats_pos ["tcpext" ]["tcploss" ]
267268
268269 try :
269- pct = 100 * (float (curr_metrics ['data ' ][index_loss ]) - float (last_metrics ['data ' ][index_loss ])) / (float (curr_metrics ['data ' ][index_pkts ]) - float (last_metrics ['data ' ][index_pkts ]))
270+ pct = 100 * (float (curr_metrics ['tcpext ' ][index_loss ]) - float (last_metrics ['tcpext ' ][index_loss ])) / (float (curr_metrics ['tcp ' ][index_outsegs ]) + float ( curr_metrics [ 'tcp' ][ index_insegs ]) - float (last_metrics ['tcp ' ][index_insegs ]) - float ( last_metrics [ 'tcp' ][ index_outsegs ]))
270271 if pct < 0 :
271272 print name + " is less 0"
272273 pct = 0
273274 except KeyError :
274- pct = 0.0
275+ pct = 0.0
276+
277+ return pct
278+
279+ def get_retrans_percentage (name ):
280+
281+ # get metrics
282+ [curr_metrics , last_metrics ] = get_metrics ()
283+
284+ index_outsegs = stats_pos ["tcp" ]["outsegs" ]
285+ index_insegs = stats_pos ["tcp" ]["insegs" ]
286+ index_retrans = stats_pos ["tcp" ]["retranssegs" ]
287+
288+ try :
289+ pct = 100 * (float (curr_metrics ['tcp' ][index_retrans ]) - float (last_metrics ['tcp' ][index_retrans ])) / (float (curr_metrics ['tcp' ][index_outsegs ]) + float (curr_metrics ['tcp' ][index_insegs ]) - float (last_metrics ['tcp' ][index_insegs ]) - float (last_metrics ['tcp' ][index_outsegs ]))
290+ if pct < 0 :
291+ print name + " is less 0"
292+ pct = 0
293+ except KeyError :
294+ pct = 0.0
275295
276296 return pct
277297
@@ -307,12 +327,19 @@ def metric_init(params):
307327 'groups' : group
308328 }))
309329
310- # descriptors.append(create_desc(Desc_Skel, {
311- # "name" : NAME_PREFIX + "tcploss_percentage",
312- # "call_back" : get_tcploss_vs_packets,
313- # "description": "TCP percentage loss, tcploss / tcphphits",
314- # "units" : "pct"
315- # }))
330+ descriptors .append (create_desc (Desc_Skel , {
331+ "name" : "tcpext_" + "tcploss_percentage" ,
332+ "call_back" : get_tcploss_percentage ,
333+ "description" : "TCP percentage loss, tcploss / insegs + outsegs" ,
334+ "units" : "pct"
335+ }))
336+
337+ descriptors .append (create_desc (Desc_Skel , {
338+ "name" : "tcp_" + "retrans_percentage" ,
339+ "call_back" : get_retrans_percentage ,
340+ "description" : "TCP retrans percentage, retranssegs / insegs + outsegs" ,
341+ "units" : "pct"
342+ }))
316343
317344 return descriptors
318345
0 commit comments