Community discussions

MikroTik App
 
noob78
just joined
Topic Author
Posts: 8
Joined: Wed Jan 18, 2023 7:45 pm

Freezing Value when not logged in

Wed Jan 18, 2023 7:59 pm

Hello,
i'm trying to script a connection supervision. There for the lasd Handshake Value from the wg peer is read. The script works when i'm logged in with Winbox, but when i disconnect, after a random time this value freeze.
:local lastHandshake [/interface wireguard peers get "0" last-handshake];
:log info "WG-1 Last $lastHandshake";
This line creates a local value with the time. "0" is the number of the interface, the quotas are for tests, don't know maybe the number ist string or something else, but without quotas is the same problem. At the moment i just log the value for tests. The script is started by the scheduler every 2m5s. I can see it works when i'm logged in vie winbox, but when i disconnect, a random time later the value freeze (see in log when i connect after while in winbox). After login it works again. Any hints?

V7.7 on hAP ac2
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Freezing Value when not logged in

Thu Jan 19, 2023 12:28 pm

As already written thousands of times, the numbers to identify the peer only work from the terminal, it is normal that they don't work on scripts.
You must use the name of the peer, not the number obtained on the print (and not 0 just because it is the only peer)
 
noob78
just joined
Topic Author
Posts: 8
Joined: Wed Jan 18, 2023 7:45 pm

Re: Freezing Value when not logged in

Thu Jan 19, 2023 11:24 pm

Thank you very much. The peers in wireguard doesn't seem to have a name, so i used the following line which works.
/interface/wireguard
:local peer [peers/find public-key~"o1Y2.*"];
:local lastHandshake [peers get $peer last-handshake];

Who is online

Users browsing this forum: Bing [Bot], onnyloh and 19 guests