BigAlambic
BigAlambic

Reputation: 11

Mikrotik - result of script job as var is empty

I need to now some info about LTE/3G connection from output of command with Zabbix. Routerboard is 6.47.7 version.

    [admin@Mikrotik_24] > interface lte info lte1 once 
           pin-status: ok
  registration-status: registered
        functionality: full
         manufacturer: "MikroTik"
                model: "R11e-LTE"
             revision: "MikroTik_CP_2.160.000_v008"
     current-operator: MTS
                  psc: 295
                  lac: 5205
       current-cellid: 241903616
    access-technology: 3G
       session-uptime: 21h3m18s
                 imei: 355654090621868
                 imsi: 250016652966098
                 uicc: 89701011266529660988
               earfcn: 10762
                 ecno: 0dB
                 rssi: -95dBm

For example "rssi", "access-technology", "uicc" and so on.

The problem with such command described by themselves - the data goes infinitely, and you cant catch it easy. https://wiki.mikrotik.com/wiki/Manual:Scripting_Tips_and_Tricks#Get_values_from_looped_interactive_commands_like_.22monitor.22

So I have a script to get some values as a global var.

/interface lte info lte1 once do={:global at $"access-technology" }

and ":put $at" in terminal works fine. But I think to take result with SNMP by executing another script to show this generated var $at. It is possible with OID they did for "script result" purpose. The question is how to output this var in script?

    [admin@Mikrotik_24] > /system script export compact 
# oct/31/2020 01:52:57 by RouterOS 6.47.7
# software id = PW8X-NNQ5
#
# model = RouterBOARD wAP R-2nD
/system script
add dont-require-permissions=no name=at owner=admin policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\
    "/interface lte info lte1 once do={:global at \$\"access-technology\" } \r\
    \n"
add dont-require-permissions=no name=at_result owner=admin policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":put \$at"


    [admin@Mikrotik_24] > :environment print   
at="3G"

[admin@Mikrotik_24] > /system script environment print 
 # NAME               VALUE                                                                
 0 at                 3G                                                                   
[admin@Mikrotik_24] > /system script run at_result     

[admin@Mikrotik_24] > 

You see, /system script run at_result is empty, but in terminal I can see it

[admin@Mikrotik_24] > :put $at
3G
[admin@Mikrotik_24] > 

Upvotes: 0

Views: 1569

Answers (1)

BigAlambic
BigAlambic

Reputation: 11

Ok. The right form of script var is

{
:global test
set $test "my data"
}

I have to declare it first.

Upvotes: -1

Related Questions