Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[show priority-group drop counters] Add user info output when user want to check PG counters and polling are disabled #1678

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion scripts/pg-drop
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ try:
except KeyError:
pass

from swsscommon.swsscommon import SonicV2Connector
from swsscommon.swsscommon import ConfigDBConnector, SonicV2Connector

STATUS_NA = 'N/A'

Expand All @@ -47,6 +47,9 @@ class PgDropStat(object):
self.counters_db = SonicV2Connector(host='127.0.0.1')
self.counters_db.connect(self.counters_db.COUNTERS_DB)

self.configdb = ConfigDBConnector()
self.configdb.connect()

dropstat_dir = get_dropstat_dir()
self.port_drop_stats_file = os.path.join(dropstat_dir, 'pg_drop_stats')

Expand Down Expand Up @@ -212,6 +215,13 @@ class PgDropStat(object):
sys.exit(e.errno)
print("Cleared PG drop counter")

def check_if_stats_enabled(self):
pg_drop_info = self.configdb.get_entry('FLEX_COUNTER_TABLE', 'PG_DROP')
if pg_drop_info:
status = pg_drop_info.get("FLEX_COUNTER_STATUS", 'disable')
if status == "disable":
print("Warning: PG counters are disabled. Current stats may be outdated. Use 'counterpoll pg-drop enable' to enable polling")

def main():
parser = argparse.ArgumentParser(description='Display PG drop counter',
formatter_class=argparse.RawTextHelpFormatter,
Expand Down Expand Up @@ -240,6 +250,7 @@ pg-drop -c clear
if command == 'clear':
pgdropstat.clear_drop_counts()
elif command == 'show':
pgdropstat.check_if_stats_enabled()
pgdropstat.print_all_stat(COUNTER_TABLE_PREFIX, "pg_drop" )
else:
print("Command not recognized")
Expand Down