Community discussions

MikroTik App
 
nowoxi
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Tue Aug 30, 2005 2:47 am
Location: nigeria

help with Dude and snmp

Sun Jan 03, 2010 10:52 am

Hi, i would appreciate if someone could tell me what code i could use to show the network address of my MT interfaces as part of the Label of a device getting the value from snmp.

Thank you
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: help with Dude and snmp

Mon Jan 04, 2010 4:46 pm

Right click on the device, select SNMP walk, wait for it to complete, search for the IP address of the interface you are interested in, Right click the line that contains the IP and select Copy OID, place it in the appearance of the device.

Here is how to display an oid as a label.
Temp: [oid("1.3.6.1.4.1.318.1.1.10.3.13.1.1.3.1")]
This is the temperature of an APC environment probe.
 
nowoxi
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Tue Aug 30, 2005 2:47 am
Location: nigeria

Re: help with Dude and snmp

Tue Jan 05, 2010 12:54 am

Hi,thanks alot for your response. What i just noticed about using an oid like this

1.3.6.1.2.1.4.20.1.1.192.168.50.62

is that the ip address is already there so its almost like i am manually adding the ip address myself if the ip changes or i apply this to another device it wont work (the ip is 192.168.50.62) is there a way i could add an oid that pics the interface and knows then the ip dynamically?

Once again thank you very much for your response it was very helpful
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: help with Dude and snmp

Tue Jan 05, 2010 4:33 pm

When you snmp walk a device you can put most of the OID in the OID field (top right) then click stop/start to view only the entries under that oid.
There are two places I found OIDs that contained ip addresses... You can then pick the address you want to display and it should be dynamic.

Filter your snmp walk to either one of these and see what you get.
1.3.6.1.2.1.85.1.2.1.4.224.0.1.39
1.3.6.1.3.61.1.1.2.1.2.2

IP:[oid("1.3.6.1.2.1.85.1.2.1.4.224.0.1.39.4")]
 
nowoxi
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Tue Aug 30, 2005 2:47 am
Location: nigeria

Re: help with Dude and snmp

Tue Jan 05, 2010 6:51 pm

Hi, thanks once again, ok so i tried your OIDs and they didn't work on my system but this is an OID with ip address of n my system

1.3.6.1.2.1.4.20.1.1.192.168.50.62

this one is for the mac address

1.3.6.1.2.1.4.20.1.3.192.168.50.62

i guess i have to ignore the last 4 sections that look like the ip address i want to see. I would appreciate if there is some hope and i should still try to find another way.

so do you know the programming language used in dude as i want to convert the network mask from 255.255.255.224 to /28 and i think i might need to use some function to read the value and convert it.
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: help with Dude and snmp

Wed Jan 06, 2010 2:09 am

Well bummer, Sorry I only have Cisco gear on my network. You can attempt to use the oid you found maybe with some futzing around with a function str_substr, I would try to SNMP walk the entire device again and see if you have a different OID that does what you want.

As for converting those masks you should be able to use a function somewhat like;
if (string_find (oid("1.1.1.1"), 255.255.255.224,) ,"/28",0)
if (string_find (oid("1.1.1.1"), 255.255.255.248,) ,"/29",0)

But there is no else function so you will have problems there as well...
You should be able to use an execute function to do a quick lookup to get your /28.

The dude is extremely flexible but many of the solutions are easier to do with an execute of some other tool or batch job.
 
nowoxi
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Tue Aug 30, 2005 2:47 am
Location: nigeria

Re: help with Dude and snmp

Wed Jan 06, 2010 9:44 am

I love your idea its simple i would go for that first lol but what i was planning to do is split up the 4 parts of the subnetmask change it into the number of bits then add it together to get the number like 255.255.255.224 would become A=255 B =255 C= 255 D= 224 then an if statement would convert A to 8 B to 8 C to 8 and D to say 4. Adding the 3 would give what i need.

I think i found elseif in functions in dude. Mikrotiks are about one of the most sophisticated i have on my network some satellite modems here and there but i hardly ever change the parameters.
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: help with Dude and snmp

Wed Jan 06, 2010 4:55 pm

When you open the functions panel and look through the list of functions do you see elseif in the list? I don't but that doesn't mean it doesn't exist...

Your break apart method would be interesting to implement and should work but there are no variables that I know of so you can't store values for later processing. I think it would be slick if you can do that in one statement.

Were you able to find a different OID with just the IP in it?

When I am searching for something I usually delete one branch off the OID at a time to find out what my system supports.
try 1.3.6.1.3.61.1.1.2.1.2
then 1.3.6.1.3.61.1.1.2.1
then 1.3.6.1.3.61.1.1.2
then 1.3.6.1.3.61.1.1
You can see that the above branch is internet.experimental so I would not be surprised if it doesn't exist on Mikrotik.
There might be a way to extend the SNMP table on a Mikrotik router but I doubt that as well.

I am surprised that 1.3.6.1.2.1.85.1.2.1.4.224.0.1.39 is not supported but it is dod.internet.mgmt. If I am reading that correctly dod is department of defense?? If you don't see the text for the OID you are browsing you can add the MIB to the files folder but I would only do this if you really need the text, why increase the footprint of the dude. I have included screen shots of some snmpwalks...
oids.png
oids1.png
oids2.png
You do not have the required permissions to view the files attached to this post.
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: help with Dude and snmp

Wed Jan 06, 2010 4:58 pm

Oh doh all them start dod.something :)
 
nowoxi
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Tue Aug 30, 2005 2:47 am
Location: nigeria

Re: help with Dude and snmp

Wed Jan 06, 2010 10:43 pm

if you look into the functions you will see ... if and else if like the cpu usage function and some other ones. I attached shots of an snmpwalk with the oid you used . its so different lol.

I haven't found any oid that can do that in Mikrotik for now. I wish it was simpler (dont we all)
snmpwalk.jpg
snmpwalk2.jpg
You do not have the required permissions to view the files attached to this post.
 
nowoxi
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Tue Aug 30, 2005 2:47 am
Location: nigeria

Re: help with Dude and snmp

Thu Jan 07, 2010 1:47 am

hey look what i did i was able to reduce the netmask with this 3 functions

nmaskD
string_substring(oid("1.3.6.1.2.1.4.20.1.3.192.168.50.62"),12,3)

nmask4

if (
nmaskD() = 255,8,

if (
nmaskD() = 254,7,
if (
nmaskD() = 252,6,
if (
nmaskD() = 248,5,
if (
nmaskD() = 240,4,
if (
nmaskD() = 224,3,
if (
nmaskD() = 192,2,
if (
nmaskD() = 128,1,
if (
nmaskD() = 0,0,""

)
)
)
)
)
)
)
)
)


nmask
sum(nmask1()+nmask2()+nmask3()+nmask4())

so i had 4 copies of nmaskD and nmask4

it worked fine only that that was was for just 1 subnet imagine i have 500nodes(which i dont) i would need to write 9 x 500 = 4500 functions (there is no way am doing that). So do you know away to put a paramter into a function when calling it and how to refer to the input that way i can have one function and apply it to the 500 node and there you have it a good solution lol(if it was possible)
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: help with Dude and snmp

Thu Jan 07, 2010 5:00 pm

That is some good code, I don't know how to do what you ask...

I know you can load a bunch of oids into an array with oid_column then you can process the array. I would figure out how to execute a VB script or even a batch job and pass the contents of oid_column("1.3.6.1.2.1.4.20.1"). That would get you all the IP addresses and the subnet masks, then you will have a much easier time processing and formating.

I don't know exactly what you are trying to do? You want to put all the IP addresses and subnet masks in a device label?

Below is all the router addresses, no subnet mask.
IP: [Device.AddressesCommaList]

HTH,
SD
 
nowoxi
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Tue Aug 30, 2005 2:47 am
Location: nigeria

Re: help with Dude and snmp

Thu Jan 07, 2010 5:50 pm

wow... look at that this IP: [Device.AddressesCommaList] was there and i was using snmp. the only thing am stuck with now(always stuck i dont know why) is that it seems to all present the first IP of the box do you know why? With this i would have 1 function for each device which will put all the IP addresses and subnet masks in their device label.
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: help with Dude and snmp

Thu Jan 07, 2010 6:35 pm

is that it seems to all present the first IP of the box do you know why?
I am not sure what you mean...

Doesn't it display all addresses?

IP: [Device.AddressesCommaList] is actually obtained by SNMP it is just obfuscated.
There is a lot of Device.stuff like Device.FirstAddress. I don't know where to find a list of them.

Who is online

Users browsing this forum: svmk and 6 guests