I am trying to create a script for monitoring WireGuard peers in RouterOS v7.1, but the values I get from “/interface/wireguard/peers/get 0 last-handshake” are not refreshing unless I call “/interface/wireguard/peers/print” explicitly.
Steps to reproduce in a terminal:
[admin@MikroTik] > :put [/interface/wireguard/peers/get 0 last-handshake]
00:00:10
(wait for a few seconds, the value stays the same)
[admin@MikroTik] > :put [/interface/wireguard/peers/get 0 last-handshake]
00:00:10
(wait for a few seconds and run a print command, the value gets updated)
[admin@MikroTik] > /interface/wireguard/peers/print
Columns: INTERFACE, PUBLIC-KEY, ENDPOINT-ADDRESS
# INTERFACE PUBLIC-KEY ENDPOINT-ADDRESS
0 wireguard1 ...... ......
[admin@MikroTik] > :put [/interface/wireguard/peers/get 0 last-handshake]
00:00:30
Version number: v7.1 stable
I have one x86 router and one RB4011. This issue can be reproduced on both of them.
However I don’t know if it is by design that WireGuard peer status is only refreshed when the find or print command is executed.
If I do the same thing (using numerical index) on other interfaces, the data is refreshed timely: