Skip to content

Commit f93cad1

Browse files
committed
Add tcp_attempt_fail percentage
1 parent a83f050 commit f93cad1

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

network/netstats/python_modules/netstats.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,27 @@ def get_tcploss_percentage(name):
107107
if pct < 0:
108108
print name + " is less 0"
109109
pct = 0
110-
except KeyError:
110+
except Exception:
111111
pct = 0.0
112112

113113
return pct
114114

115+
def get_tcpattemptfail_percentage(name):
116+
117+
# get metrics
118+
[curr_metrics, last_metrics] = get_metrics()
119+
120+
try:
121+
pct = 100 * (float(curr_metrics['data']['tcp']["attemptfails"]) - float(last_metrics["data"]['tcp']["attemptfails"])) / (float(curr_metrics['data']['tcp']['outsegs']) + float(curr_metrics['data']['tcp']['insegs']) - float(last_metrics['data']['tcp']['insegs']) - float(last_metrics['data']['tcp']['outsegs']))
122+
if pct < 0:
123+
print name + " is less 0"
124+
pct = 0
125+
except Exception:
126+
pct = 0.0
127+
128+
return pct
129+
130+
115131
def get_retrans_percentage(name):
116132

117133
# get metrics
@@ -122,7 +138,7 @@ def get_retrans_percentage(name):
122138
if pct < 0:
123139
print name + " is less 0"
124140
pct = 0
125-
except KeyError:
141+
except Exception:
126142
pct = 0.0
127143

128144
return pct
@@ -196,6 +212,15 @@ def metric_init(params):
196212
'groups' : 'tcpext'
197213
}))
198214

215+
descriptors.append(create_desc(Desc_Skel, {
216+
"name" : "tcpext_" + "tcpattemptfail_percentage",
217+
"call_back" : get_tcpattemptfail_percentage,
218+
"description": "TCP attemptfail percentage, tcpattemptfail / insegs + outsegs",
219+
"units" : "pct",
220+
'groups' : 'tcpext'
221+
}))
222+
223+
199224
descriptors.append(create_desc(Desc_Skel, {
200225
"name" : "tcp_" + "retrans_percentage",
201226
"call_back" : get_retrans_percentage,

0 commit comments

Comments
 (0)