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
“count-only” is an argument to “print”, not a separate command.
So:
/ppp/active/print
=count-only=
hknet
August 6, 2016, 5:20pm
3
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…
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.
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
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();
}