RouterOS PHP API class

I’ve create Yet Another PHP RouterOS PHP API:
http://svn.osk-net.pl/svn/rosapi/trunk

Documentation:
http://svn.osk-net.pl/svn/rosapi/trunk/documentation.html

Doxygen documentation:
http://svn.osk-net.pl/svn/rosapi/trunk/doxygen/annotated.html

SVN:
http://svn.osk-net.pl/svn/rosapi

The main purpose of another RouterOS PHP API class it to simplify configuration update processes. Example: We have about 20 access points and for each of them we have connected about 20 wds links. Using automatic configuration process we can store information about all wds links in one place. It can be MySQL database.

Using set of configuration files router’s can be divided into function groups (ie. router, main-access-point, client-access-point, switch) and be configured from central server automatically. ONLY changed configuration will be updated, so in most cases no configuration will change.

Created WIKI page: http://wiki.mikrotik.com/wiki/RouterOS_PHP_class

Version 0.2.

  • added callbacks
  • simple btest example using callbacks to run many simultaneous tests
  • updated documentation

I’ve made my http://ayufan.eu/local/src/rosapi/trunk/btest_example.php even more powerful. It’s script that can run many simultaneous bandwidth-tests. It’s supports only transmit mechanism, because there is a bug with btest that you cant specify different receive and transmit limits. It can be used to check network latencies under heavy load. Uses ncurses to show results :slight_smile:

Syntax is very simple:

php btest_example.php <login>:<password>@<host> <destination1>@<speed>@<protocol>...



<host> - source host from which to run btests
<speed> - maximum speed in format: 1k, 1M, 1G
<protocol> - protocol to be used: it can be tcp:<connection_count> or udp:<packet_size>
  tcp - use tcp with 1 connection
  tcp:20 - use tcp with 20 connections
  udp:1400 - use udp with packet size 1400

great class, thank you

I know that, I use it to, to manage many routerboards :slight_smile:
Latest version is always on SVN. Check Logs to see what changed.

Updated my original posts and added doxygen documentation.

Kamil

Is there no need to logout from API session in your script ?

for now there is no disconnect method, php recycles all sockets when finishes.

Hi all

Is it possible to use the where section in the command as in the terminal?
/interface/wireless/registration-table/print stats where mac-address=00:0C:42:61:75:23

Thank you

Janos Prepuk

http://wiki.mikrotik.com/wiki/API#Queries

PHP recycles sockets, but i see a long list of active admins in my ROS,

it’s a bug. upgrade your ROS to the latest version

I do have the same problem with 3.28. With never versions everything is OK.

If you use connection for example in function:

function do_sth() {
 $conn = RotuerOS::connect("192.168.1.1", "admin", "");
 $conn->getall("/interface/wireless");
}

PHP will automatically close that connection when leaves function.
So there is no need for separate method for disconnect :slight_smile:
You can also use:

  unset($conn);

Kamil

actually, 3.27 and 3.28 should not have this problem %) AFAIR, 3.24 has it

Hello i use this api but , I can’t run the following code;

$conn->getall("/ip/hotspot/active/print");

i want to get online hotspot users list but doesnt work and gives the following error

trap[/ip/hotspot/active/print/getall]: no such command

someone can help me pls.

hello i have a problem i use this api class;

i want to see online hotspot users list and use following code

$conn->getall("/ip/hotspot/active/print");

but doesnt work and give following error
trap[/ip/hotspot/active/print/getall]: no such command

How can I solve this problem?

huh… seems like that function appends ‘/getall’ to the command. try

$conn->getall("/ip/hotspot/active");

if you are testing something and get some problems, use python API, as there can everything be done, what can be done using API.

in this case you would know then, that problem is with PHP API, not API itself.

I didn’t have any problem with my PHP API class. I have been using it for about 1 year with simple features as well as with differencing synchronization.

ayufan,

I just have to say thank you. This is really great work, with excellent documentation. I’m going to start digging in to use for some upcoming projects.