Community discussions

MikroTik App
 
EMSergio
newbie
Topic Author
Posts: 30
Joined: Thu Sep 03, 2015 11:09 am

Mikrotik API “no such command” when trying to get count-only of PPP connections

Thu Sep 03, 2015 11:17 am

I am developing a service that counts the PPPoE users per MikroTik Device in the whole network every X minutes. I'm using the API build in Python3.

When I connect to a MKT, I can execute the command ppp active print count-only. In the API the language changes a bit. I can't execute that command. It tells me =message=no such command prefix. I've tried with /ppp/active/print/count-only but only works when I execute /ppp/active/print but that is not the result I want.

Thank you
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Mikrotik API “no such command” when trying to get count-only of PPP connections

Thu Sep 03, 2015 5:49 pm

"count-only" is an argument to "print", not a separate command.

So:
/ppp/active/print
=count-only=
 
User avatar
hknet
Member Candidate
Member Candidate
Posts: 126
Joined: Sun Jul 17, 2016 6:05 pm
Location: Vienna, Austria
Contact:

Re: Mikrotik API “no such command” when trying to get count-only of PPP connections

Sat Aug 06, 2016 8:20 pm

maybe some kind soul at MikroTik could update the wiki page http://wiki.mikrotik.com/wiki/Manual:API#Query_word to mention the count-only attribute to queries, it took me hours to figure this one out...
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Mikrotik API “no such command” when trying to get count-only of PPP connections

Sat Aug 06, 2016 9:47 pm

That section is not the place for it...

The API page already says
API closely follows syntax from command line interface (CLI).
and has examples that show that "attribute word" = "command argument".

And the print arguments are documented on the scripting page

I'm thinking maybe instead, the Attribute word section should specifically spell out that
  • In command sentences, attribute words are analogous to CLI arguments.
  • In reply sentences, attribute words are analogous to CLI properties.
So that people can more easily put two and two together.
 
PortalNET
Member Candidate
Member Candidate
Posts: 126
Joined: Sun Apr 02, 2017 7:24 pm

Re: Mikrotik API “no such command” when trying to get count-only of PPP connections

Thu Sep 30, 2021 5:17 am

Hi guys i know this is an old thread, but could someone post the php code, to print the ppp active secrets?

i have tried executing the cmd on the mikrotik cmd and it works

/ppp active print count-only and it prints out the number of the total pppoe clientes connected.. i need to output it to php form..
$stats = $API->comm('/ppp/active/print/count-only');
$meme = $stats['0'];

echo "<td>" . $meme['count-only'] . "</td>";

but its not working its not retrieving data at all surely my code is wrong.. i am using RouterOS 1.6
 
PortalNET
Member Candidate
Member Candidate
Posts: 126
Joined: Sun Apr 02, 2017 7:24 pm

Re: Mikrotik API “no such command” when trying to get count-only of PPP connections

Fri Oct 01, 2021 5:01 am

Hi guys just an update

managed to get it working with routerOS php api , my cmd was wrong obviously as shown on the previous post


working code
 if ($API->connect($iphost, $userhost, $pass, $port)) {
           
		    $ARRAY = $API->comm("/ppp/active/print", array("count-only"=> "",));
   
            print_r($ARRAY);

            $API->disconnect();

}

Who is online

Users browsing this forum: Mosfet and 50 guests