Skip to content

Commit a9fb9ca

Browse files
authored
Merge pull request #160 from mssonicbld/sonicbld/202412-merge
```<br>* 235bd65 - (HEAD -> 202412) Merge branch '202411' of https://github.com/sonic-net/sonic-utilities into 202412 (2025-03-25) [Sonic Automation] * 3cfd9a6 - (origin/202411) Fixed the issues with sonic-clear queuecounter for egress queue and voq (#3816) (2025-03-25) [mssonicbld]<br>```
2 parents 7f57f41 + 235bd65 commit a9fb9ca

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

scripts/queuestat

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -294,38 +294,27 @@ class Queuestat(object):
294294
old_cntr = cnstat_old_dict.get(key)
295295
if old_cntr is not None:
296296
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 \
298298
ns_diff(cntr['totalbytes'], old_cntr['totalbytes']) != '0' or \
299299
ns_diff(cntr['droppacket'], old_cntr['droppacket']) != '0' or \
300300
ns_diff(cntr['dropbytes'], old_cntr['dropbytes']) != '0' or \
301301
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']),
303303
ns_diff(cntr['totalpacket'], old_cntr['totalpacket']),
304304
ns_diff(cntr['totalbytes'], old_cntr['totalbytes']),
305305
ns_diff(cntr['droppacket'], old_cntr['droppacket']),
306306
ns_diff(cntr['dropbytes'], old_cntr['dropbytes']),
307307
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']))
313308
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 \
315310
ns_diff(cntr['totalbytes'], old_cntr['totalbytes']) != '0' or \
316311
ns_diff(cntr['droppacket'], old_cntr['droppacket']) != '0' or \
317312
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'])))
329318
if json_opt:
330319
json_output[port].update(build_json(port, table, self.voq))
331320
return json_output
@@ -346,8 +335,10 @@ class Queuestat(object):
346335
for port in natsorted(self.counter_port_name_map):
347336
json_output[port] = {}
348337
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
351342
if os.path.isfile(cnstat_fqn_file_name):
352343
try:
353344
cnstat_cached_dict = json.load(open(cnstat_fqn_file_name, 'r'))
@@ -378,7 +369,10 @@ class Queuestat(object):
378369

379370
# Get stat for the port queried
380371
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
382376
json_output = {}
383377
json_output[port] = {}
384378
if os.path.isfile(cnstat_fqn_file_name):
@@ -403,10 +397,13 @@ class Queuestat(object):
403397

404398
def save_fresh_stats(self):
405399
# 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 + '-'
406403
for port in natsorted(self.counter_port_name_map):
407404
cnstat_dict = self.get_cnstat(self.port_queues_map[port])
408405
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)
410407
except IOError as e:
411408
print(e.errno, e)
412409
sys.exit(e.errno)

0 commit comments

Comments
 (0)