-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[swss]: Start counter from swss container (#1875)
* sonic-quagga update. Don't spam with 'Vtysh connected from' message * Enable counters inside swss container. systemd is not flexible enough to follow our business rules
- Loading branch information
1 parent
3c33737
commit 10b4bbc
Showing
8 changed files
with
47 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python | ||
|
||
import swsssdk | ||
import time | ||
|
||
def enable_counter_group(db, name): | ||
info = {} | ||
info['FLEX_COUNTER_STATUS'] = 'enable' | ||
db.mod_entry("FLEX_COUNTER_TABLE", name, info) | ||
|
||
def enable_counters(): | ||
db = swsssdk.ConfigDBConnector() | ||
db.connect() | ||
enable_counter_group(db, 'PORT') | ||
enable_counter_group(db, 'QUEUE') | ||
enable_counter_group(db, 'PFCWD') | ||
|
||
def get_uptime(): | ||
with open('/proc/uptime') as fp: | ||
return float(fp.read().split(' ')[0]) | ||
|
||
def main(): | ||
# If the switch was just started (uptime less than 5 minutes), | ||
# wait for 3 minutes and enable counters | ||
# otherwise wait for 60 seconds and enable counters | ||
uptime = get_uptime() | ||
if uptime < 300: | ||
time.sleep(180) | ||
else: | ||
time.sleep(60) | ||
enable_counters() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters