@@ -294,38 +294,27 @@ class Queuestat(object):
294
294
old_cntr = cnstat_old_dict .get (key )
295
295
if old_cntr is not None :
296
296
if self .voq :
297
- if not non_zero or ns_diff (cntr ['totalpacket' ], old_cntr ['totalpacket' ]) != '0' or \
297
+ if not non_zero or ns_diff (cntr ['totalpacket' ], old_cntr ['totalpacket' ]) != '0' or \
298
298
ns_diff (cntr ['totalbytes' ], old_cntr ['totalbytes' ]) != '0' or \
299
299
ns_diff (cntr ['droppacket' ], old_cntr ['droppacket' ]) != '0' or \
300
300
ns_diff (cntr ['dropbytes' ], old_cntr ['dropbytes' ]) != '0' or \
301
301
ns_diff (cntr ['creditWDpkts' ], old_cntr ['creditWDpkts' ]) != '0' :
302
- table .append ((port , cntr ['queuetype' ] + str (cntr ['queueindex' ]),
302
+ table .append ((port , cntr ['queuetype' ] + str (cntr ['queueindex' ]),
303
303
ns_diff (cntr ['totalpacket' ], old_cntr ['totalpacket' ]),
304
304
ns_diff (cntr ['totalbytes' ], old_cntr ['totalbytes' ]),
305
305
ns_diff (cntr ['droppacket' ], old_cntr ['droppacket' ]),
306
306
ns_diff (cntr ['dropbytes' ], old_cntr ['dropbytes' ]),
307
307
ns_diff (cntr ['creditWDpkts' ], old_cntr ['creditWDpkts' ])))
308
- elif not non_zero or cntr ['totalpacket' ] != '0' or cntr ['totalbytes' ] != '0' or \
309
- cntr ['droppacket' ] != '0' or cntr ['dropbytes' ] != '0' or cntr ['creditWDpkts' ] != '0' :
310
- table .append ((port , cntr ['queuetype' ] + str (cntr ['queueindex' ]),
311
- cntr ['totalpacket' ], cntr ['totalbytes' ],
312
- cntr ['droppacket' ], cntr ['dropbytes' ], cntr ['creditWDpkts' ]))
313
308
else :
314
- if not non_zero or ns_diff (cntr ['totalpacket' ], old_cntr ['totalpacket' ]) != '0' or \
309
+ if not non_zero or ns_diff (cntr ['totalpacket' ], old_cntr ['totalpacket' ]) != '0' or \
315
310
ns_diff (cntr ['totalbytes' ], old_cntr ['totalbytes' ]) != '0' or \
316
311
ns_diff (cntr ['droppacket' ], old_cntr ['droppacket' ]) != '0' or \
317
312
ns_diff (cntr ['dropbytes' ], old_cntr ['dropbytes' ]) != '0' :
318
- table .append ((port , cntr ['queuetype' ] + str (cntr ['queueindex' ]),
319
- ns_diff (cntr ['totalpacket' ], old_cntr ['totalpacket' ]),
320
- ns_diff (cntr ['totalbytes' ], old_cntr ['totalbytes' ]),
321
- ns_diff (cntr ['droppacket' ], old_cntr ['droppacket' ]),
322
- ns_diff (cntr ['dropbytes' ], old_cntr ['dropbytes' ])))
323
- elif not non_zero or cntr ['totalpacket' ] != '0' or cntr ['totalbytes' ] != '0' or \
324
- cntr ['droppacket' ] != '0' or cntr ['dropbytes' ] != '0' :
325
- table .append ((port , cntr ['queuetype' ] + str (cntr ['queueindex' ]),
326
- cntr ['totalpacket' ], cntr ['totalbytes' ],
327
- cntr ['droppacket' ], cntr ['dropbytes' ]))
328
-
313
+ table .append ((port , cntr ['queuetype' ] + str (cntr ['queueindex' ]),
314
+ ns_diff (cntr ['totalpacket' ], old_cntr ['totalpacket' ]),
315
+ ns_diff (cntr ['totalbytes' ], old_cntr ['totalbytes' ]),
316
+ ns_diff (cntr ['droppacket' ], old_cntr ['droppacket' ]),
317
+ ns_diff (cntr ['dropbytes' ], old_cntr ['dropbytes' ])))
329
318
if json_opt :
330
319
json_output [port ].update (build_json (port , table , self .voq ))
331
320
return json_output
@@ -346,8 +335,10 @@ class Queuestat(object):
346
335
for port in natsorted (self .counter_port_name_map ):
347
336
json_output [port ] = {}
348
337
cnstat_dict = self .get_cnstat (self .port_queues_map [port ])
349
-
350
- cnstat_fqn_file_name = cnstat_fqn_file + port
338
+ cache_ns = ''
339
+ if self .voq and self .namespace is not None :
340
+ cache_ns = '-' + self .namespace + '-'
341
+ cnstat_fqn_file_name = cnstat_fqn_file + cache_ns + port
351
342
if os .path .isfile (cnstat_fqn_file_name ):
352
343
try :
353
344
cnstat_cached_dict = json .load (open (cnstat_fqn_file_name , 'r' ))
@@ -378,7 +369,10 @@ class Queuestat(object):
378
369
379
370
# Get stat for the port queried
380
371
cnstat_dict = self .get_cnstat (self .port_queues_map [port ])
381
- cnstat_fqn_file_name = cnstat_fqn_file + port
372
+ cache_ns = ''
373
+ if self .voq and self .namespace is not None :
374
+ cache_ns = '-' + self .namespace + '-'
375
+ cnstat_fqn_file_name = cnstat_fqn_file + cache_ns + port
382
376
json_output = {}
383
377
json_output [port ] = {}
384
378
if os .path .isfile (cnstat_fqn_file_name ):
@@ -403,10 +397,13 @@ class Queuestat(object):
403
397
404
398
def save_fresh_stats (self ):
405
399
# Get stat for each port and save
400
+ cache_ns = ''
401
+ if self .voq and self .namespace is not None :
402
+ cache_ns = '-' + self .namespace + '-'
406
403
for port in natsorted (self .counter_port_name_map ):
407
404
cnstat_dict = self .get_cnstat (self .port_queues_map [port ])
408
405
try :
409
- json .dump (cnstat_dict , open (cnstat_fqn_file + port , 'w' ), default = json_serial )
406
+ json .dump (cnstat_dict , open (cnstat_fqn_file + cache_ns + port , 'w' ), default = json_serial )
410
407
except IOError as e :
411
408
print (e .errno , e )
412
409
sys .exit (e .errno )
0 commit comments