Community discussions

MikroTik App
 
dts
just joined
Topic Author
Posts: 8
Joined: Mon Nov 01, 2021 7:54 am

pptp Api

Mon Nov 01, 2021 8:05 am

Hello. I want to get pptp connection status information (connected, disconnected, terminating...). I send the command "Interface / pptp-client / monitor", and in response I get "no such command prefix". After the command "/ interface / print" I can't find the information I need. Can you please tell me which command will give me this information?
 
User avatar
MickeyT
Member Candidate
Member Candidate
Posts: 125
Joined: Tue Feb 18, 2020 7:06 am
Location: Australia

Re: pptp Api

Mon Nov 01, 2021 8:51 am

I'm not quite sure what information you're after. If your MikroTik is running as a PPTP server then try the command:
/interface pptp-server print

Otherwise, if your MikroTik is running as a PPTP client, try:
/interface pptp-client print

I hope this gives you the information you're after.
 
dts
just joined
Topic Author
Posts: 8
Joined: Mon Nov 01, 2021 7:54 am

Re: pptp Api

Mon Nov 01, 2021 8:55 am

the command "/ interface / pptp-client / print" shows this. but there is no connection status information.
Image


!re=
=.id=*D
=name=pptp-out_HMN
=max-mtu=1450
=max-mru=1450
=mrru=disabled
=connect-to=198.50.183.??
=user=89258560952???
=password=37??
=profile=default-encryption
=keepalive-timeout=60
=use-peer-dns=no
=add-default-route=true
=default-route-distance=10
=dial-on-demand=false
=allow=pap,chap,mschap1,mschap2
=running=true
=disabled=false
=comment=HMN
 
dts
just joined
Topic Author
Posts: 8
Joined: Mon Nov 01, 2021 7:54 am

Re: pptp Api

Mon Nov 01, 2021 9:04 am

in the terminal the command "/ interface pptp-client monitor 0" gives me the information I need. How to redo for api request?
Last edited by dts on Mon Nov 01, 2021 9:06 am, edited 1 time in total.
 
User avatar
MickeyT
Member Candidate
Member Candidate
Posts: 125
Joined: Tue Feb 18, 2020 7:06 am
Location: Australia

Re: pptp Api

Mon Nov 01, 2021 9:05 am

I just did a quick search and this link might help. The relevant part appears to be:
/interface pptp-client print detail
NB: The detail after the print.

Unfortunately, I don't have a running system to test it on at the moment.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5491
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: pptp Api

Mon Nov 01, 2021 9:06 am

Which ROS version are you using ?
From the message I assume you are running this from a script ?

There should also be a number to indicate which entry you want to monitor.
E.g. "/interface pptp-client monitor 0", that will show a constant monitoring for that entry.
Use "/interface pptp-client monitor 0 once" to have it monitor, well... once. For scripting purposes.
If you have multiple entries, you need to use find to get the right one.
Surely there will be other and more elegant solutions then my crude suggestions.
 
dts
just joined
Topic Author
Posts: 8
Joined: Mon Nov 01, 2021 7:54 am

Re: pptp Api

Mon Nov 01, 2021 9:12 am

ROS v6.49
I'm trying to use this instruction "https://wiki.mikrotik.com/wiki/Manual:API"
I don't understand how the command syntax "/ interface pptp-client monitor 0" will be correct
 
holvoetn
Forum Guru
Forum Guru
Posts: 5491
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: pptp Api

Mon Nov 01, 2021 9:41 am

In terminal it will work.
For scripting you need to add "once" since the script will not be able to handle the continuous info coming back.
That's why it only has to run ONCE.
/interface pptp-client monitor 0 once

API is another thing ...
 
holvoetn
Forum Guru
Forum Guru
Posts: 5491
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: pptp Api

Mon Nov 01, 2021 9:52 am

(never done any API programming but have programmed in quite some languages in the past, so I can understand most of what I see :) )

Terminal / scripting / API are 3 (related but different) things.
For API only /interface/pptp-client/print will work, as in : give you the required info.

Check this:
https://github.com/nunenuh/mikrotik-api ... Client.php

This piece of code should point you in the right direction, I think
/**
     * This method used for detail interface pptp-client
     * @param type $id string
     * @return type array
     */
    public function detail($id) {
        $sentence = new SentenceUtil();
        $sentence->fromCommand("/interface/pptp-client/print");
        $sentence->where(".id", "=", $id);
        $this->talker->send($sentence);
        $rs = $this->talker->getResult();
        $i = 0;
        if ($i < $rs->size()) {
            return $rs->getResultArray();
        } else {
            return "No Interface PPTP Client With This id = " . $id;
        }
    }
 
dts
just joined
Topic Author
Posts: 8
Joined: Mon Nov 01, 2021 7:54 am

Re: pptp Api

Mon Nov 01, 2021 6:26 pm

still it doesn’t work
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 897
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: pptp Api  [SOLVED]

Mon Nov 01, 2021 7:48 pm

>>> /interface/pptp-client/monitor
>>> =.id=pptp-out1
>>> =once=
<<< !re
<<< =status=disconnected
<<< 
<<< !done
<<< 
>>> /quit
<<< !fatal
<<< session terminated on request
<<< 
 
dts
just joined
Topic Author
Posts: 8
Joined: Mon Nov 01, 2021 7:54 am

Re: pptp Api

Mon Nov 01, 2021 8:00 pm

>>> /interface/pptp-client/monitor
>>> =.id=pptp-out1
>>> =once=
<<< !re
<<< =status=disconnected
<<< 
<<< !done
<<< 
>>> /quit
<<< !fatal
<<< session terminated on request
<<< 
Thanks a lot!!! May God grant you even more health!

Who is online

Users browsing this forum: No registered users and 31 guests