Skip to content

Commit d74e08f

Browse files
authored
Merge pull request #103 from vishnuchalla/threshold-line
Converting thresholds to line in telco plotly visuals
2 parents 69aaefa + f116849 commit d74e08f

File tree

2 files changed

+54
-56
lines changed

2 files changed

+54
-56
lines changed

backend/app/api/v1/endpoints/telco/telcoGraphs.py

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def process_json(json_data: dict):
2525

2626
def process_ptp(json_data: str):
2727
nic = json_data["nic"]
28-
ptp4l_max_offset = json_data["ptp4l_max_offset"]
28+
ptp4l_max_offset = json_data.get("ptp4l_max_offset", 0)
2929
if "mellanox" in nic.lower():
3030
defined_offset_threshold = 200
3131
else:
@@ -38,25 +38,25 @@ def process_ptp(json_data: str):
3838
"ptp": [
3939
{
4040
"name": "Data Points",
41-
"x": ["ptp4l_max_offset"],
42-
"y": [ptp4l_max_offset],
41+
"x": ["-inf", "ptp4l_max_offset", "inf"],
42+
"y": [0, ptp4l_max_offset, 0],
4343
"mode": "markers",
4444
"marker": {
4545
"size": 10,
4646
},
4747
"error_y": {
4848
"type": "data",
4949
"symmetric": "false",
50-
"array": [0],
51-
"arrayminus": [minus_offset]
50+
"array": [0, 0, 0],
51+
"arrayminus": [0, minus_offset, 0]
5252
},
5353

5454
},
5555
{
5656
"name": "Threshold",
57-
"x": ["ptp4l_max_offset"],
58-
"y": [defined_offset_threshold],
59-
"mode": "lines+markers",
57+
"x": ["-inf", "ptp4l_max_offset", "inf"],
58+
"y": [defined_offset_threshold, defined_offset_threshold, defined_offset_threshold],
59+
"mode": "lines",
6060
"line": {
6161
"dash": 'dot',
6262
"width": 3,
@@ -78,8 +78,8 @@ def process_reboot(json_data: str):
7878
defined_threshold = 20
7979
reboot_type = json_data["reboot_type"]
8080
for each_iteration in json_data["Iterations"]:
81-
max_minutes = max(max_minutes, each_iteration["total_minutes"])
82-
avg_minutes += each_iteration["total_minutes"]
81+
max_minutes = max(max_minutes, each_iteration.get("total_minutes", 0))
82+
avg_minutes += each_iteration.get("total_minutes", 0)
8383
avg_minutes /= len(json_data["Iterations"])
8484
if max_minutes > defined_threshold:
8585
minus_max_minutes = max_minutes - defined_threshold
@@ -108,7 +108,7 @@ def process_reboot(json_data: str):
108108
"name": "Threshold",
109109
"x": [reboot_type + "_" + "max_minutes", reboot_type + "_" + "avg_minutes"],
110110
"y": [defined_threshold, defined_threshold],
111-
"mode": "lines+markers",
111+
"mode": "lines",
112112
"marker": {
113113
"size": 15,
114114
},
@@ -131,9 +131,9 @@ def process_cpu_util(json_data: str):
131131
if each_scenario["scenario_name"] == "steadyworkload":
132132
for each_type in each_scenario["types"]:
133133
if each_type["type_name"] == "total":
134-
total_max_cpu = each_type["max_cpu"]
134+
total_max_cpu = each_type.get("max_cpu", 0)
135135
break
136-
total_avg_cpu = each_scenario["avg_cpu_total"]
136+
total_avg_cpu = each_scenario.get("avg_cpu_total", 0)
137137
break
138138
if total_max_cpu > defined_threshold:
139139
minus_max_cpu = total_max_cpu - defined_threshold
@@ -162,7 +162,7 @@ def process_cpu_util(json_data: str):
162162
"name": "Threshold",
163163
"x": ["total_max_cpu", "total_avg_cpu"],
164164
"y": [defined_threshold, defined_threshold],
165-
"mode": "lines+markers",
165+
"mode": "lines",
166166
"marker": {
167167
"size": 15,
168168
},
@@ -176,7 +176,7 @@ def process_cpu_util(json_data: str):
176176
}
177177

178178
def process_rfc_2544(json_data: str):
179-
max_delay = json_data["max_delay"]
179+
max_delay = json_data.get("max_delay", 0)
180180
defined_delay_threshold = 30.0
181181
minus_max_delay = 0.0
182182
if max_delay > defined_delay_threshold:
@@ -185,8 +185,8 @@ def process_rfc_2544(json_data: str):
185185
return {
186186
"rfc-2544": [
187187
{
188-
"x": ["max_delay"],
189-
"y": [max_delay],
188+
"x": ["-inf", "max_delay", "inf"],
189+
"y": [0, max_delay, 0],
190190
"mode": "markers",
191191
"marker": {
192192
"size": 10,
@@ -195,16 +195,16 @@ def process_rfc_2544(json_data: str):
195195
"error_y": {
196196
"type": "data",
197197
"symmetric": "false",
198-
"array": [0],
199-
"arrayminus": [minus_max_delay]
198+
"array": [0, 0, 0],
199+
"arrayminus": [0, minus_max_delay, 0]
200200
},
201201
"type": "scatter",
202202
},
203203
{
204-
"x": ["max_delay"],
205-
"y": [defined_delay_threshold],
204+
"x": ["-inf", "max_delay", "inf"],
205+
"y": [defined_delay_threshold, defined_delay_threshold, defined_delay_threshold],
206206
"name": "Threshold",
207-
"mode": "lines+markers",
207+
"mode": "lines",
208208
"marker": {
209209
"size": 15,
210210
},
@@ -228,8 +228,8 @@ def process_cyclictest(json_data: str):
228228
}
229229

230230
def process_deployment(json_data: str):
231-
total_minutes = json_data["total_minutes"]
232-
reboot_count = json_data["reboot_count"]
231+
total_minutes = json_data.get("total_minutes", 0)
232+
reboot_count = json_data.get("reboot_count", 0)
233233
defined_total_minutes_threshold = 180
234234
defined_total_reboot_count = 3
235235
minus_total_minutes = 0.0
@@ -244,25 +244,25 @@ def process_deployment(json_data: str):
244244
"total_minutes": [
245245
{
246246
"name": "Data Points",
247-
"x": ["total_minutes"],
248-
"y": [total_minutes],
247+
"x": ["-inf", "total_minutes", "inf"],
248+
"y": [0, total_minutes, 0],
249249
"mode": "markers",
250250
"marker": {
251251
"size": 10,
252252
},
253253
"error_y": {
254254
"type": "data",
255255
"symmetric": "false",
256-
"array": [0],
257-
"arrayminus": [minus_total_minutes]
256+
"array": [0, 0, 0],
257+
"arrayminus": [0, minus_total_minutes, 0]
258258
},
259259
"type": "scatter",
260260
},
261261
{
262262
"name": "Threshold",
263-
"x": ["total_minutes"],
264-
"y": [defined_total_minutes_threshold],
265-
"mode": "lines+markers",
263+
"x": ["-inf", "total_minutes", "inf"],
264+
"y": [defined_total_minutes_threshold, defined_total_minutes_threshold, defined_total_minutes_threshold],
265+
"mode": "lines",
266266
"marker": {
267267
"size": 15,
268268
},
@@ -276,25 +276,25 @@ def process_deployment(json_data: str):
276276
"total_reboot_count": [
277277
{
278278
"name": "Data Points",
279-
"x": ["reboot_count"],
280-
"y": [reboot_count],
279+
"x": ["-inf", "reboot_count", "inf"],
280+
"y": [0, reboot_count, 0],
281281
"mode": "markers",
282282
"marker": {
283283
"size": 10,
284284
},
285285
"error_y": {
286286
"type": "data",
287287
"symmetric": "false",
288-
"array": [0],
289-
"arrayminus": [minus_total_reboot_count]
288+
"array": [0, 0, 0],
289+
"arrayminus": [0, minus_total_reboot_count, 0]
290290
},
291291
"type": "scatter",
292292
},
293293
{
294294
"name": "Threshold",
295-
"x": ["reboot_count"],
296-
"y": [defined_total_reboot_count],
297-
"mode": "lines+markers",
295+
"x": ["-inf", "reboot_count", "inf"],
296+
"y": [defined_total_reboot_count, defined_total_reboot_count, defined_total_reboot_count],
297+
"mode": "lines",
298298
"marker": {
299299
"size": 15,
300300
},
@@ -315,34 +315,34 @@ def get_oslat_or_cyclictest(json_data: str):
315315
defined_latency_threshold = 20
316316
defined_number_of_nines_threshold = 100
317317
for each_test_unit in json_data["test_units"]:
318-
max_latency = max(max_latency, each_test_unit["max_latency"])
319-
min_number_of_nines = min(min_number_of_nines, each_test_unit["number_of_nines"])
318+
max_latency = max(max_latency, each_test_unit.get("max_latency", 0))
319+
min_number_of_nines = min(min_number_of_nines, each_test_unit.get("number_of_nines", 0))
320320
if max_latency > defined_latency_threshold:
321321
minus_max_latency = max_latency - defined_latency_threshold
322322

323323
return {
324324
"number_of_nines": [
325325
{
326326
"name": "Data Points",
327-
"x": ["min_number_of_nines"],
328-
"y": [min_number_of_nines],
327+
"x": ["-inf", "min_number_of_nines", "inf"],
328+
"y": [0, min_number_of_nines, 0],
329329
"mode": "markers",
330330
"marker": {
331331
"size": 10,
332332
},
333333
"error_y": {
334334
"type": "data",
335335
"symmetric": "false",
336-
"array": [0],
337-
"arrayminus": [min_number_of_nines - defined_number_of_nines_threshold]
336+
"array": [0, 0, 0],
337+
"arrayminus": [0, min_number_of_nines - defined_number_of_nines_threshold, 0]
338338
},
339339
"type": "scatter",
340340
},
341341
{
342342
"name": "Threshold",
343-
"x": ["min_number_of_nines"],
344-
"y": [defined_number_of_nines_threshold],
345-
"mode": "lines+markers",
343+
"x": ["-inf", "min_number_of_nines", "inf"],
344+
"y": [defined_number_of_nines_threshold, defined_number_of_nines_threshold, defined_number_of_nines_threshold],
345+
"mode": "lines",
346346
"marker": {
347347
"size": 15,
348348
},
@@ -356,25 +356,25 @@ def get_oslat_or_cyclictest(json_data: str):
356356
"max_latency": [
357357
{
358358
"name": "Data Points",
359-
"x": ["max_latency"],
360-
"y": [max_latency],
359+
"x": ["-inf", "max_latency", "inf"],
360+
"y": [0, max_latency, 0],
361361
"mode": "markers",
362362
"marker": {
363363
"size": 10,
364364
},
365365
"error_y": {
366366
"type": "data",
367367
"symmetric": "false",
368-
"array": [0],
369-
"arrayminus": [minus_max_latency]
368+
"array": [0, 0, 0],
369+
"arrayminus": [0, minus_max_latency, 0]
370370
},
371371
"type": "scatter",
372372
},
373373
{
374374
"name": "Threshold",
375-
"x": ["max_latency"],
376-
"y": [defined_latency_threshold],
377-
"mode": "lines+markers",
375+
"x": ["-inf", "max_latency", "inf"],
376+
"y": [defined_latency_threshold, defined_latency_threshold, defined_latency_threshold],
377+
"mode": "lines",
378378
"marker": {
379379
"size": 15,
380380
},

backend/app/services/splunk.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import orjson
22
from app import config
3-
from multiprocessing import Pool, cpu_count
4-
from concurrent.futures import ProcessPoolExecutor, as_completed
53
from splunklib import client, results
64

75

0 commit comments

Comments
 (0)