wireguard peers connection

Hello,

I’m trying to make a script polling every minute the last- handshake of each wireguard peer and retrieve the comment field of each peer.
I have put in the comment field the name of the peer.

here a part of the script:

:put $status;
:set status :local status [/interface/wireguard/peers/ get [find where last-handshake > 0s and last-handshake < 59s] comment];



I’m stuck here with this problems:

1-when there is no peer with the condition satisfied I see in the console no such item and nothing in $status.

  1. when one peer satisfy the condition , I receive

Len:
9
Typeof:
str
Status:
Felix gsm

… and it is what I expected.

3.when two or more peers satisfy the conditions I receive:

invalid internal item number

Is there a way to resolve the problems.

Thanks for your help.

Félix