Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Create a bgp-neighbor stats and mount result to metal-core #352

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions partition/roles/metal-core/files/bgp-neighbor-stats.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Collect BGP Neighbor statistics

[Service]
Type=simple
ExecStart=/usr/bin/bgp-neighbor-stats.sh
robertvolkmann marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 12 additions & 0 deletions partition/roles/metal-core/files/bgp-neighbor-stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -o errexit

tmpfile=$(mktemp /var/run/bgp-neighbors/bgp-neighbors.XXXXXX)
destfile=/var/run/bgp-neighbors/bgp-neighbors.json

/usr/bin/vtysh -c "show ip bgp vrf all neighbors json" > "${tmpfile}"

rm -f "${destfile}"
robertvolkmann marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be removed, otherwise there might be a short period of time where no file is present

mv "${tmpfile}" "${destfile}"
rm -f "${tmpfile}"
9 changes: 9 additions & 0 deletions partition/roles/metal-core/files/bgp-neighbor-stats.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Collect BGP Neighbor statistics

[Timer]
OnCalendar=*:0/2
robertvolkmann marked this conversation as resolved.
Show resolved Hide resolved
Persistent=false

[Install]
WantedBy=timers.target
2 changes: 1 addition & 1 deletion partition/roles/metal-core/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
- name: Reload systemd daemon
ansible.builtin.systemd:
daemon_reload: true
daemon_reload: true
40 changes: 40 additions & 0 deletions partition/roles/metal-core/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,46 @@
- frr-reload.service
when: metal_stack_switch_os_is_sonic

- name: create bgp-neighbor-stats directory
file:
path: /var/run/bgp-neighbors
state: directory
robertvolkmann marked this conversation as resolved.
Show resolved Hide resolved
owner: root
group: root
mode: "0755"

- name: create bgp-neighbor-stats.sh
copy:
src: bgp-neighbor-stats.sh
dest: /usr/bin/bgp-neighbor-stats.sh
owner: root
group: root
mode: "0755"

- name: create bgp-neighbor-stats.service
copy:
src: bgp-neighbor-stats.service
dest: /etc/systemd/system/bgp-neighbor-stats.service
owner: root
group: root
mode: "0644"
robertvolkmann marked this conversation as resolved.
Show resolved Hide resolved
notify: Reload systemd daemon

- name: create bgp-neighbor-stats.timer
copy:
src: bgp-neighbor-stats.timer
dest: /etc/systemd/system/bgp-neighbor-stats.timer
owner: root
group: root
mode: "0644"
notify: Reload systemd daemon

- name: bgp-neighbor-stats.timer must be enabled and running
systemd:
name: bgp-neighbor-stats.timer
enabled: yes
state: started

- name: deploy metal-core
include_role:
name: ansible-common/roles/systemd-docker-service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
- "{{ metal_core_grpc_cert_dir }}:/certs/grpc:ro"
{% for volume_mount in metal_core_additional_volume_mounts %}
- {{ volume_mount }}
{% endfor %}
{% endfor %}
- /var/run/bgp-neighbors:/var/run/bgp-neighbors