This give me all interface
Code: Select all
{
:foreach id in=[interface find] do={
:local Name [interface get $id name]
:put "ifname=$Name"
}
}
In this case the SNMP idx = internal interface ID, but that is not the case normally. So how to tell from :put [/interface print oid as-value ] that I need interface with id *1, *2 etc? It seem not to work with loop.?:put [/interface print oid as-value ]
.id=*1;actual-mtu=.1.3.6.1.2.1.2.2.1.4.1;admin-status=.1.3.6.1.2.1.2.2.1.7.1;bytes-in=.1.3.6.1.2.1.31.1.1.1.6.1;bytes-out=.1.3.6.1
.2.1.31.1.1.1.10.1;comment=;discards-in=.1.3.6.1.2.1.2.2.1.13.1;discards-out=.1.3.6.1.2.1.2.2.1.19.1;errors-in=.1.3.6.1.2.1.2.2.1.
14.1;errors-out=.1.3.6.1.2.1.2.2.1.20.1;mac-address=.1.3.6.1.2.1.2.2.1.6.1;name=.1.3.6.1.2.1.2.2.1.2.1;oper-status=.1.3.6.1.2.1.2.
2.1.8.1;packets-in=.1.3.6.1.2.1.31.1.1.1.7.1;packets-out=.1.3.6.1.2.1.31.1.1.1.11.1;.id=*3;actual-mtu=.1.3.6.1.2.1.2.2.1.4.3;admin
-status=.1.3.6.1.2.1.2.2.1.7.3;bytes-in=.1.3.6.1.2.1.31.1.1.1.6.3;bytes-out=.1.3.6.1.2.1.31.1.1.1.10.3;comment=Remote Winbox conne
ction for FV155;discards-in=.1.3.6.1.2.1.2.2.1.13.3;discards-out=.1.3.6.1.2.1.2.2.1.19.3;errors-in=.1.3.6.1.2.1.2.2.1.14.3;errors-
out=.1.3.6.1.2.1.2.2.1.20.3;mac-address=.1.3.6.1.2.1.2.2.1.6.3;name=.1.3.6.1.2.1.2.2.1.2.3;oper-status=.1.3.6.1.2.1.2.2.1.8.3;pack
ets-in=.1.3.6.1.2.1.31.1.1.1.7.3;packets-out=.1.3.6.1.2.1.31.1.1.1.11.3;.id=*2;actual-mtu=.1.3.6.1.2.1.2.2.1.4.2;admin-status=.1.3
.6.1.2.1.2.2.1.7.2;bytes-in=.1.3.6.1.2.1.31.1.1.1.6.2;bytes-out=.1.3.6.1.2.1.31.1.1.1.10.2;comment=;discards-in=.1.3.6.1.2.1.2.2.1
.13.2;discards-out=.1.3.6.1.2.1.2.2.1.19.2;errors-in=.1.3.6.1.2.1.2.2.1.14.2;errors-out=.1.3.6.1.2.1.2.2.1.20.2;mac-address=.1.3.6
.1.2.1.2.2.1.6.2;name=.1.3.6.1.2.1.2.2.1.2.2;oper-status=.1.3.6.1.2.1.2.2.1.8.2;packets-in=.1.3.6.1.2.1.31.1.1.1.7.2;packets-out=.
1.3.6.1.2.1.31.1.1.1.11.2
Code should be some like this:
Code: Select all
{
:foreach id in=[/interface find] do={
:local Name [/interface get $id name]
:local Idx [/interface print oid as-value $id actual-mtu]
:local SNMPIdx [ do some extract to get the last number in $Idx to get the actual SNMPIdx]
:put "ifname=$Name SNMPIdx=$SNMPIdx"
}
}