Community discussions

MikroTik App
 
Dude2048
Member Candidate
Member Candidate
Topic Author
Posts: 212
Joined: Thu Sep 01, 2016 4:04 pm

LTE RSRP to variable with foreach

Tue Nov 26, 2019 3:49 pm

Two LTE interfaces on a RBM33G.

I tried, with the script below, to extract the RSRP in a variable. But there is a strange reaction from RouterOS. In the first part it wil return with, say, index 4. The LTE interface can be asked out on the fourth position. If you look at the interfaces pane in Winbox, correct... But I want the "/interfaces lte". The second part uses the same command to extract the RSRP with position 4, but it is position 0 if you want anything meaningful. I have the idea that two different arrays are created. One from the /interfaces and one from the /interfaces lte.

 :foreach i in=[/interface lte find] do={:if ([:typeof [:find [/interface lte get $i name] "lte1"]]!="nil") do={:global "LTE01 RSRP Value" ([ / interface lte info [ :pick [ find ] $i ] once as-value ]->"rsrp")}}             

Does anyone have a good idea.
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1071
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: LTE RSRP to variable with foreach  [SOLVED]

Tue Nov 26, 2019 7:54 pm

I am not perfectly sure what you want to achieve... How about something like this?
:foreach Interface in=[/interface lte find] do={ :put ("RSRP value " . [/interface lte get $Interface name] . ": " . ([/interface lte info $Interface once as-value ]->"rsrp"))}
Output on my device is: RSRP value lte: -79

Of course my device has just one lte interface. With two interfaces you have two values... Do you want these values go into different variables?
 
Dude2048
Member Candidate
Member Candidate
Topic Author
Posts: 212
Joined: Thu Sep 01, 2016 4:04 pm

Re: LTE RSRP to variable with foreach

Wed Nov 27, 2019 3:04 am

I have two lte interfaces so yes, it should go into two different variables. It’s two o clock right now, I will test it some time in the morning. At first sight it solves the problem with the internal interface id’s.

Who is online

Users browsing this forum: No registered users and 30 guests