Skip to content

Commit

Permalink
Create a bgp-neighbor stats and mount result to metal-core (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Jan 23, 2025
1 parent 724c4d1 commit e57245c
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 2 deletions.
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
11 changes: 11 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,11 @@
#!/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}"

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
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
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"
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
3 changes: 2 additions & 1 deletion partition/roles/metal-core/templates/metal-core-volumes.j2
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

0 comments on commit e57245c

Please sign in to comment.