WireGuard peer last handshake time is not refreshing in RouterOS v7.1

Hi,

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.

Works for me if done right:

:put [ /interface/wireguard/peers/get ([ find ]->0) last-handshake ];

Give find proper parameters to get information from specific peer.

You should never ever use numerical index in scripts, that depends on print.

Thanks! The find command works for me.

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:

[admin@MikroTik] > :put [/interface/ethernet/get 0 tx-packet]
11 279 649

[admin@MikroTik] > :put [/interface/ethernet/get 0 tx-packet]
11 279 652