MikroTik Scripting - Filtros de consulta (find - where)
Prezados,
Pelos testes que fiz, detectei uma falha em filtros de consulta, aplicados à propriedade de modo de proteção, em interfaces bridge, no MikroTik RouterOS.
O problema pode ser reproduzido em qualquer versão do MikroTik RouterOS, entre 5.14 e 5.21. Não testei em versões anteriores, pois são muito ultrapassadas, de uso não recomendado.
O código abaixo demonstra, de forma básica, o problema existente.
Código :
#Add 3 bridges, with protocol mode none, stp and rstp, respectively.
/interface bridge add name=MYBRIDGE-A protocol-mode=none comment="Temp"
/interface bridge add name=MYBRIDGE-B protocol-mode=stp comment="Temp"
/interface bridge add name=MYBRIDGE-C protocol-mode=rstp comment="Temp"
Código :
#Enumerate each interface. Teorically work, but not work :(
foreach X in=[ /interface bridge find where protocol-mode=none ] do={:put ([/interface bridge get $X name ] ) }
foreach X in=[ /interface bridge find where protocol-mode=stp ] do={:put ([/interface bridge get $X name ] ) }
foreach X in=[ /interface bridge find where protocol-mode=rstp ] do={:put ([/interface bridge get $X name ] ) }
Código :
#Print each interface found, filtered by protocol-mode. Teorically work, but not work :(
/interface bridge print where protocol-mode=none
/interface bridge print where protocol-mode=stp
/interface bridge print where protocol-mode=rstp
Como demonstrado acima, o resultado de cada consulta não condiz com o filtro aplicado, seja "find", seja "where", em versões anteriores ao MikroTik RouterOS 5.21, inclusive.
Já abri um chamado de suporte na MikroTik, entretanto, não tive resposta até o momento.
Desejo saber se em seus ativos que rodam MikroTik RouterOS, entre 5.14 e 5.21, esse problema também acontece.
Grato,
Trober
Re: MikroTik Scripting - Filtros de consulta (find - where)
Obrigado Trober por compartilhar!
Abs.
Re: MikroTik Scripting - Filtros de consulta (find - where)
Copio, anotado e ligado no descrito
Obrigado por sua contribuicao
Re: MikroTik Scripting - Filtros de consulta (find - where)
Bom dia amigo.
Tente esse código.
Código PHP:
#Enumerate each interface. Teorically work, but not work :(
foreach X in=[ /interface bridge find where protocol-mode="none" ] do={:put ([/interface bridge get $X name ] ) }
foreach X in=[ /interface bridge find where protocol-mode="stp" ] do={:put ([/interface bridge get $X name ] ) }
foreach X in=[ /interface bridge find where protocol-mode="rstp" ] do={:put ([/interface bridge get $X name ] ) }
Acredito que o problema seja apenas referenciar o valor de protocol-mode entre aspas.
Abraço
Re: MikroTik Scripting - Filtros de consulta (find - where)
Citação:
Postado originalmente por
gamineiro
Bom dia amigo.
Bom dia Gabriel :)
Citação:
Postado originalmente por
gamineiro
Tente esse código.
Código :
#Enumerate each interface. Teorically work, but not work :(
foreach X in=[ /interface bridge find where protocol-mode="none" ] do={:put ([/interface bridge get $X name ] ) }
foreach X in=[ /interface bridge find where protocol-mode="stp" ] do={:put ([/interface bridge get $X name ] ) }
foreach X in=[ /interface bridge find where protocol-mode="rstp" ] do={:put ([/interface bridge get $X name ] ) }
Acredito que o problema seja apenas referenciar o valor de
protocol-mode entre aspas.
Deu certo!!! :D
Mas convenhamos, que porquice a MikroTik fez. Fugiu ao padrão de usar aspas somente em strings com espaços. Prova disso é que o autocompletar aceita dessa forma, sem as aspas. Outra prova, são os exemplos abaixo:
Código :
#Double quotes no required (example 1).
/ip address add address=9.9.9.1/32 interface=MYBRIDGE-A
/ip address add address=9.9.9.2/32 interface=MYBRIDGE-B
/ip address add address=9.9.9.3/32 interface=MYBRIDGE-C
/ip address print where interface=MYBRIDGE-A
/ip address print where interface=MYBRIDGE-B
/ip address print where interface=MYBRIDGE-C
Aspas duplas não são requeridas. De igual forma no exemplo abaixo.
Código :
#Double quotes no required (example 2).
/interface bridge print where comment=Temp
Enfim, faltou homogeneidade nos filtros.
Farei um complemento ao chamado aberto, informando a sua análise. Dessa forma, talvez corrijam isso para o MikroTik RouterOS 5.22 :)
Citação:
Postado originalmente por
gamineiro
Abraço
Abraço!
Trober