Community discussions

MikroTik App
 
User avatar
BlackRat
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 97
Joined: Sat Jul 21, 2012 8:37 am

API: Hot to get routerboard parameters

Sun Aug 22, 2021 7:14 pm

Hi.
I newbie in Perl and MikroTik::API.
I using Perl to get Routerboard parameters.
How can I get values of the /system routerboard print page?
Should I use 8 singe line queries or I can get all parameters in one query?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: API: Hot to get routerboard parameters

Sun Aug 22, 2021 8:03 pm

You can get all parameters by passing a list of parameter names.
You can find the parameter names (in general) by entering the get command at the command prompt, and using TAB to show the options:

/system routerboard get TAB
board-name factory-firmware model routerboard upgrade-firmware
current-firmware firmware-type revision serial-number value-name

So now you can pass those value names (not the name "value-name" of course) in a list to the 2nd parameter of the MikroTik::mtik_query function.
(A comma separated list like {'board-name','current-firmware'} )

Or, in fact, you can just pass an empty list {} and you will get all available values returned in the hash.
 
User avatar
BlackRat
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 97
Joined: Sat Jul 21, 2012 8:37 am

Re: API: Hot to get routerboard parameters

Sun Aug 22, 2021 9:01 pm

Ok.
I found one of the ways how to get it:
my ( $ret_get_props, @aoh_props ) = $api->query( '/system/routerboard/print',{} );
print "The router current-firmware is: $aoh_props[0]->{'current-firmware'}\n";
and we will get current-firmware of the routerboard...
print "The router model is: $aoh_props[0]->{'model'}\n";
prints model name of the routerboard, etc...
Thank you!
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: API: Hot to get routerboard parameters

Sun Aug 22, 2021 10:29 pm

Ok it looks like you use a different version of the Perl API.
I use the one from https://github.com/ellocofray/mikrotik-perl-api slightly modified because the login has changed.
It allows to retrieve a list of parameters, or "all" parameters of a certain object.

Who is online

Users browsing this forum: GoogleOther [Bot], rogerioqueiroz and 22 guests