From: "Nicolás Brailovsky" Date: 2009-10-02T00:00:45+09:00 Subject: Re: Problems with SNMP --0016e6d644f5aeaaed0474e0e87e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2009/10/1 Rocir Santiago > Hi, Nicol=E1s. > > Thanks for the reply. My switch works fine with SNMP. It's 3com Baseline > Switch 2226 Plus. Problem is though it may support SNMP protocol it sure won't support all th= e options (OIDs) the RFC defines. Some switches do support listing known devices, some don't. > My doubt it's about the ruby code to find the MAC > address of each computer "pluged" in my switch. I can figure out some > examples at the doc page of this lib. But when I just try to get the > ifPhysAddress, the application raises an error and I don't know why. > My experience with SNMP si mostly in C++, not Ruby, but it may be helpful t= o know which exception is your application raising. It may be because the OID is not supported (no such instance exception) or because it's not defined i= n your code. To assert if the switch does support this OID try using snmpget from console, not from within a program. BTW, if I remember correctly ifPhysAddress will give you the iface's mac internal to the switch, not the mac of the device in that port (there may b= e many known macs per port too). Regards, --=20 Nicol=E1s Brailovsky - http://nicolasb.com.ar/ > > Here is the code: > > _________ > require 'snmp' > > ifTable_columns =3D ["ifIndex", "ifDescr", "ifInOctets", "ifOutOctets", > "ifPhysAddress"] > SNMP::Manager.open(:Host =3D> 'xxx.xxx.xxx.xxx') do |manager| > manager.walk(ifTable_columns) do |row| > row.each { |vb| print "\t#{vb.value}" } > puts > end > end > _________ > > I just added the ifPhysAddress to the example in the site. If I just > remove the ifPhysAddress, it works fine. > > > Nicol=E1s Brailovsky wrote: > > Rocir, you should first check if your switch supports this > > functionality. If > > it does I'd try to do an snmpwalk through the complete table to find an > > OID > > providing a list of known mac addresses, which will most likely be > > grouped > > by interface (port). > > > > This link may come in handy: http://www.oid-info.com/index.htm > > > > Regards > > > > -- > > Nicol=E1s Brailovsky > > - http://nicolasb.com.ar/ > > - http://monosinfinitos.com.ar/ > > > > 2009/10/1 Rocir Santiago > > -- > Posted via http://www.ruby-forum.com/. > > --0016e6d644f5aeaaed0474e0e87e--