How Can i find SNMP enabled devices types

by 
 on 24-Feb-2009 08:22 AM.
  in  OEMs & Developers 
Hi All,

Is there any possibilities to find the particular devices type like routers,switches,printers or host machines...

i.e : OID - 1.7.0 returns a service value.

Can i use above for find the particular device type..because this returns a unique value for particular device type.

Note : I am using Adventnet SNMP .net API

Please suggest me..

Thanks,
Sabari.
  • No status
Hi Sabari,

To find the device types after discovering the device, You need to query the device with OID 's given in order to find the device types.

Switch :-
If the device is a Switch, it should respond for the OID ".1.3.6.1.2.1.17.1.2.0" and ".1.3.6.1.2.1.4.1.0" value will be 2.

Router:-
If the device is a Router, it should respond the OID ".1.3.6.1.2.1.4.1.0" value as 1.

Printer :-
If the device is Printer, it should respond for the OID ".1.3.6.1.2.1.43.5.1.1.1.1" .

Hope this Helps.

Thanks,
Babji.
Hi babji,

Thanks for ur infomation.

Regards,
Sabari.
Hi babji,

I could not understand...please give me if u have any sample code ..

Regards,
Sabari.
Dear Sabari,

After discovery of the devices, Send the SNMP Requests to each device with different OID's mentioned in my above reply.
i.e For Example, if a device is discovered with ip address 192.168.111.120 .
To know the type of device, Suppose you need to find out of printer, router & Switch.
Implement as below:
1. Send a SNMP get request to the discovered device(1.e, 192.168.111.120 ) with printer OID i.e, .1.3.6.1.2.1.43.5.1.1.1.1 ,
If a valid response is received, then the device is a printer.
2. In case of not getting valid response for first request, Send another get request with OID's ".1.3.6.1.2.1.17.1.2.0" or ".1.3.6.1.2.1.4.1.0", it should respond for the OID ".1.3.6.1.2.1.17.1.2.0" and ".1.3.6.1.2.1.4.1.0" value will be 2. Then, the device is Switch.
3. If device is not giving any valid response for above request check by sending a get request with OID ".1.3.6.1.2.1.4.1.0" , it should respond with a value with "1". Then, the device is a Router.

Implement as above to know the device type for each device.
To know how to send SNMP get Request to a device, please refer the link below:
http://www.adventnet.com/products/net-snmp/help/developing_management_applications/snmp_operations/snmp_get.html

Hope this is clear.

Thanks,
Babji.
Hi babji,

Thanks for your code.

Regards,
Sabari.
Hi Babji,

  I have used above method to get device types.but unfortunately i am not able to get any proper output from that code.

If i Send a SNMP get request to the discovered device with printer OID i.e, .1.3.6.1.2.1.43.5.1.1.1.1,then i will get the value (counter : 30) if the device is printer or else i will get Null Value (NullObj:Null).

If i send a SNMP get request to the discovered device with Router OID i.e, .1.3.6.1.2.1.4.1.0 ,then i will get the below values

  • If the device is PC,then the value is (Integer : 2)
  • If the device is Printer ,then the value is (Integer : 1)

Please Suggest..herewith i have attached my code below,

My Code :

     
                        SnmpAPI api2 = new SnmpAPI();

                        SnmpSession session2 = new SnmpSession(api2);

                        session2.Open();



                        SnmpPDU pdu2 = new SnmpPDU();



                        UDPProtocolOptions option2 = new UDPProtocolOptions("<Remote Machine IP>");

                        pdu2.ProtocolOptions = option2;

                        pdu2.Command = SnmpAPI.GET_REQ_MSG;

                        SnmpOID oid2 = new SnmpOID(".1.3.6.1.2.1.4.1.0");

                        pdu2.AddNull(oid2);
                        SnmpPDU result2 = session2.SyncSend(pdu2);

                        MessageBox.Show(result2.PrintVarBinds());

                        session2.Close();

                        api2.Close();






Hi,

To discover the type of device through SNMP, the device must have a SNMP agent running on it .

Here is the link below which has the information about the criteria to discover the corresponding device type .

http://www.adventnet.com/products/webnms/help/developer_guide/discovery/discovery_process/device_specific_discovery/disc_device_intro.html

So, To find the type of the device perform SNMP operations with OID's given in the above link, depending on the results device type can be detected.

Hope this helps.

Thanks,
Babji.
Hi babj,

How are you?

I already discovered SNMP devices in my network.Now i have the list of SNMP enabled devices IP's,but i could not differentiate the devices like routers,switches,printers,PC's.

but below code i have used for getting the device types,but i can't.

i already explained to you for my last conversation.

If you have any sample codes,please share with me.

herewith i have attached the code for your reference.
SnmpAPI api2 = new SnmpAPI();

                        SnmpSession session2 = new SnmpSession(api2);

                        session2.Open();



                        SnmpPDU pdu2 = new SnmpPDU();



                        UDPProtocolOptions option2 = new UDPProtocolOptions("<Remote Machine IP>");

                        pdu2.ProtocolOptions = option2;

                        pdu2.Command = SnmpAPI.GET_REQ_MSG;

                        SnmpOID oid2 = new SnmpOID(".1.3.6.1.2.1.4.1.0");

                        pdu2.AddNull(oid2);
                        SnmpPDU result2 = session2.SyncSend(pdu2);

                        MessageBox.Show(result2.PrintVarBinds());

                        session2.Close();

                        api2.Close();



Regards,
Sabari

Post Actions
Statistics
  • 8
     Replies
  • 1242
     Views
  • 0
     Followers
Tags for the post
No tags available for this topic.
© 2009 Corp. All rights reserved. Trademarks | Privacy Policy | Site Map | Contact Us | Careers

Edit Link Delete Link

Edit Link Delete Link

LoadingImage