Skip to content

Commit

Permalink
Enable sairedis counter thread in 3 minutes after SONiC was started (s…
Browse files Browse the repository at this point in the history
…onic-net#1813)

* Enable sairedis counter thread in 3 minutes after SONiC was started

* Enable all counters
  • Loading branch information
pavel-shirshov authored and lguohan committed Jun 26, 2018
1 parent 4eb866c commit 6568203
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
7 changes: 7 additions & 0 deletions files/build_templates/enable_counters.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Unit]
Description=Enable SONiC counters

[Service]
Type=oneshot
ExecStart=/bin/bash -c '/usr/bin/counterpoll queue enable ; /usr/bin/counterpoll port enable ; /usr/bin/pfcwd counter_poll enable'
RemainAfterExit=yes
9 changes: 9 additions & 0 deletions files/build_templates/enable_counters.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Delays the SONiC counters gathering until SONiC has started

[Timer]
OnBootSec=3min
Unit=enable_counters.service

[Install]
WantedBy=timers.target
7 changes: 2 additions & 5 deletions files/build_templates/snmp.service.j2
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[Unit]
Description=SNMP container
Requires=updategraph.service swss.service
After=updategraph.service swss.service
Requires=updategraph.service swss.service enable_counters.service
After=updategraph.service swss.service enable_counters.service

[Service]
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh attach
ExecStop=/usr/bin/{{docker_container_name}}.sh stop

[Install]
WantedBy=multi-user.target
9 changes: 9 additions & 0 deletions files/build_templates/snmp.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Delays snmp container until SONiC has started

[Timer]
OnBootSec=3min 30 sec
Unit=snmp.service

[Install]
WantedBy=timers.target
8 changes: 8 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /sys || true
sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys
{% endif %}

# Copy systemd timer configuration
# It implements delayed start of services
sudo cp $BUILD_TEMPLATES/enable_counters.timer $FILESYSTEM_ROOT/etc/systemd/system/
sudo cp $BUILD_TEMPLATES/enable_counters.service $FILESYSTEM_ROOT/etc/systemd/system/
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable enable_counters.timer
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable snmp.timer

sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get remove -y python-dev
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get autoremove -y
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-sairedis
2 changes: 1 addition & 1 deletion src/sonic-swss
2 changes: 1 addition & 1 deletion src/sonic-utilities

0 comments on commit 6568203

Please sign in to comment.