Script to create /tool/graphs/interface - Help for dummy
Posted: Tue Feb 11, 2025 1:17 pm
I want to define the creation of graphs only for some types of interfaces (ethernet, vlan and bridge). A way to avoid PPP or similar graphs being created.
I actually really like the scripting syntax of RouterOS. But I'm not a programmer!
My way of thinking is linear, and that doesn't help me when it comes to finding solutions to small syntax rules.
But my brain gets stuck on what the syntax and logic of some recursions in RouterOS are.
I did some tests that obviously failed, but I'll bring them here to show how far I was able to get.
The following command gives me the arrays of interfaces I want.
So I thought if is a printed that variables in a loop, it would give something similar to previous:
But what I get as output is a single "true", even on a multivalued array.
And this is where I got stuck...
I imagined that I needed to do soothing like:
But this is obviously wrong!
Wrong because of the wrong use of syntax, and wrong because there is no "/interface/get".
Could anybody give me some help with this?
I actually really like the scripting syntax of RouterOS. But I'm not a programmer!
My way of thinking is linear, and that doesn't help me when it comes to finding solutions to small syntax rules.
But my brain gets stuck on what the syntax and logic of some recursions in RouterOS are.
I did some tests that obviously failed, but I'll bring them here to show how far I was able to get.
The following command gives me the arrays of interfaces I want.
Code: Select all
:put [/interface find type=ether]
:put [/interface find type=vlan]
:put [/interface find type=bridge]
Code: Select all
:foreach varinterfaceid in={/interface find type=ether} do={:put "$varinterfaceid" }
And this is where I got stuck...
I imagined that I needed to do soothing like:
Code: Select all
:foreach varinterfaceid in={/interface find type=ether} do={/tool/graphing/interface/add [/interface get [:put "$varinterfaceid"} name]
Wrong because of the wrong use of syntax, and wrong because there is no "/interface/get".
Could anybody give me some help with this?