Community discussions

MikroTik App
telepro
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 68
加入: Sun Apr 03, 2011 7:50 pm

access to SSTP-Client Uptime

Wed Jul 25, 2018 8:43 pm

Is there a command line request that will return the uptime for an sstp-client (available on the winbox interface status page when the sstp VPN connection is operational). It shows the time that this particluar SSTP vpn connections has been operational.

Neither of these work:
:put [/interface sstp-client get [find interface=VPN-To-Host] uptime]
:put [/interface sstp-client get [find interface=VPN-To-Host] value-name=uptime]

Perhaps the uptime is available under another value-name?
Thanks in advance
Top
用户头像
dasiu
Trainer
Trainer
Posts: 231
加入: Fri Jan 30, 2009 11:41 am
Location:Reading, UK
Contact:

Re: access to SSTP-Client Uptime

Wed Jul 25, 2018 9:11 pm

Code:Select all
:put ([/interface sstp-client monitor VPN-To-Host once as-value]->"uptime")
Top
telepro
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 68
加入: Sun Apr 03, 2011 7:50 pm

Re: access to SSTP-Client Uptime

Wed Jul 25, 2018 11:53 pm

Thank you非常much. I don't believe I have seen this format described before.
So do i understand correctly:

/interface sstp-client monitor VPN-To-Host once creates and returns a text buffer Example:
;;; VPN Connection to LCD-RTR
status: connected
uptime: 39m52s
encoding: AES256-CBC
mtu: 1500
local-address: 10.221.0.80
remote-address: 10.221.0.1

adding the 'as-value' incorporates each row of text into an array of text strings in memory indexed by the headings (left of the ':')
and adding the ->"uptime" selects the row of the the array

Interesting to explore what all is available using that sequence.
Thanks again.
Top
用户头像
dasiu
Trainer
Trainer
Posts: 231
加入: Fri Jan 30, 2009 11:41 am
Location:Reading, UK
Contact:

Re: access to SSTP-Client Uptime

Thu Jul 26, 2018 12:19 am

adding the 'as-value' incorporates each row of text into an array of text strings in memory indexed by the headings (left of the ':')
and adding the ->"uptime" selects the row of the the array
So:
1. Adding "as-value" presents the results of print (and also monitor) commands in the "array" form. To check - please try this:
:put [/interface sstp-client monitor VPN-To-Host once as-value];
2. The format with semicolons creates an array. You can do for example:
:local book {"title"="Hamlet";"author"="Shakespeare";"pages"="251"};
:put ($book->"author");
- that's how you get the single value from the array.
3. Usually you can get single values with "get" - but those are only the values you can also "print". Here the uptime is one of the parameters that change every second and "print" doesn't show them, only "monitor" - so to see it you need to do:
/interface sstp-client monitor VPN-To-Host
4. As the above command keeps refreshing every second - we use "once" to show it only once:).
/interface sstp-client monitor VPN-To-Host once
And then - making the array from it (with as-value) and getting the element with -> - now you know the full story:).
Top
vogtdominik
刚刚加入了
Posts: 16
加入: Fri Mar 22, 2019 2:39 pm

Re: access to SSTP-Client Uptime

我4月6日2020 1:36 pm

For anyone looking this up in the future. It seems, that this does not work when running scripts via "import file" via API-command.

Can anyone confirm this? Does anyone have a solution to this?
Top
vogtdominik
刚刚加入了
Posts: 16
加入: Fri Mar 22, 2019 2:39 pm

Re: access to SSTP-Client Uptime

我4月6日2020 2:19 pm

Turns out there is a workaround. It really depends on your case though. I want to replace SSTP with L2TP and want to make sure, that the L2TP-Connection is working and then disable the SSTP-Connection.

If you answer the following questions with yes, this workaround should work for you:

- You want to run a script via "import file"?
- Your script contains monitoring commands (e.g. /interface sstp-client monitor my_sstp_interface as-value once) that your logic depends on, but it does not return any value inside the script?
- You are not depending on the results being returned as API-Response?

The workaround:

Instead of running the command via the imported file, you simply add a scheduler, that will run your command. After the command has been run, you can remove the scheduler. So in total it looks something like this:

# Import.rsc
Code:Select all
/系统调度程序添加名称= mySchedulerImport国米val=1m on-event=":local sstpConnected;\r\ \n[/interface sstp-client monitor my_sstp_interface_name once do={:set \$sstpConnected (\$status = \"connected\");}]\r\ \n\r\ \n:log info \$sstpConnected;\r\ \n\r\ \n/system scheduler remove mySchedulerImport" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=apr/06/2020 start-time=13:15:00
Make sure to replace "my_sstp_interface_name" with your interface-name.

Hope this helps someone in the future!
Top

Who is online

Users browsing this forum:kokobokoand 4 guests