Byron
October 2, 2023, 9:39am
1
Good Morning everyone.
Goal: use an specific OID in a function according to Device.Type in dude functions.
Problem: I can pull the [device.type] correctly but when I check it in a if statement i get “Parse Failed”. So I know my code is probably not correct.
My Code: if(device_property(“Type”)) = “Mimosa” ,oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”)
This basically should be a function that checks if a device.type (My custom type I have setup in dude) is equal to set string value. If they match then return a OID value.
Any help PLEASE, I have lookded everywhere with no luck.
Byron
October 2, 2023, 9:50am
2
I have also tried to see if string_size wont work either but it does not.
What I tried: if(string_size(device_property(“Type”))) = string_size(“Mimosa”),oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”),“”)
if(device_property(“Type”)) = “Mimosa” ,oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”)
=>
if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), “” )
if(string_size(device_property(“Type”))) = string_size(“Mimosa”),oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”),“”)
=>
if ( string_size(device_property(“Type”)) = string_size(“Mimosa”), oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), “” )
Byron
October 2, 2023, 9:53am
4
Hi Rextended
your code doesnt seem to work either.
not tested code
It just for put on evidence the wrong place of the “)”
Byron
October 2, 2023, 9:55am
7
Im going to try and see if it works on all my others and I will revert back with my findings.
Thank you SO much!
Byron
October 2, 2023, 10:07am
8
Rextended,
For my Mikrotik devices I get error " Expected end of command (Line 1 Column 14)
My Code: if ( device_property(“Type”) = “MikroTik”, ros_command(“:put /system resource get board-name”), “”)
Byron
October 2, 2023, 11:15am
9
My nested IF seems to be wrong. I cant find the syntax for this :c
Code:
if ( device_property(“Type”) = “Ubiquity”, oid(“2.840.10036.3.1.2.1.3.5”), “”),
if ( device_property(“Type”) = “MikroTik”, ros_command(“:put /system resource get board-name”), “”),
if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), “”),
if ( device_property(“Type”) = “BDcom”, “”,
“Fix ME”,)
Byron
October 2, 2023, 11:43am
10
Updated code:
if ( device_property(“Type”) = “Ubiquity”, oid(“2.840.10036.3.1.2.1.3.5”), “”,“”)
if ( device_property(“Type”) = “MikroTik”, ros_command(“:put [/system resource get board-name]”), “”,“”)
if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), “”,“”)
if ( device_property(“Type”) = “BDcom”, “”, “”)
Byron
October 2, 2023, 11:51am
11
in the nested IF:
There is a problem with matching device.type…
If I used the mimosa OID line, it gets used for all devices no matter the if condition??/ im confused why it does this.
Byron
October 2, 2023, 12:00pm
12
I have Also tried this:
if ( device_property(“Type”) = “MikroTik”, ros_command(“:put [/system resource get board-name]”), if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”), if ( device_property(“Type”) = “Ubiquity”, oid(“2.840.10036.3.1.2.1.3.5”), if ( device_property(“Type”) = “BDcom”, 0))))
Byron
October 2, 2023, 12:02pm
13
Ok this code only pulls the 1st if statement but if it the condition does not match it does not fall to the else statement?
if ( device_property(“Type”) = “MikroTik”, ros_command(“:put [/system resource get board-name]”),
if ( device_property(“Type”) = “Mimosa”, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”),
if ( device_property(“Type”) = “Ubiquity”, oid(“2.840.10036.3.1.2.1.3.5”),
if ( device_property(“Type”) = “BDcom”, “”,“”))))
Byron
October 3, 2023, 11:37am
14
Hi,
I dont know why this if is still not working. ive tried so much.
Code:
if ( device_property(“Type”) = 0, ros_command(“:put [/system resource get board-name]”),
if ( device_property(“Type”) = 1, oid(“iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0”),
if ( device_property(“Type”) = 2, oid(“2.840.10036.3.1.2.1.3.5”),“”)))
Byron
October 9, 2023, 6:47am
16
So the IF function is bugged according to MikroTik support.
Need to see what work around I can get instead.