locked
How to use SNMP in C#

    Question

  • Hi people,

    I would like to create C# clients that will use SNMP to communicate to a C# manager and I would like to know what namespaces to call, what classes, etc. I have not been able to find C# examples on this (only WMI examples), so if anybody can give me some or give me guidance, I will really appreciate it.

    Also, as a general question, what will you people suggest, have the clients listenning/talking through a port and have a similar behaviour on the manager or use SNMP?

    Thank you!

    Sunday, March 12, 2006 6:28 PM

Answers

All replies

  • Hi Rijckewaert,

    Can you refer this article for more details about SNMP.

    http://www.codeproject.com/useritems/SNMPDLL.asp

    Cheer.

    Monday, March 13, 2006 4:24 AM
  • There are some nice libraries available, here is a little list:

    Monday, March 13, 2006 9:47 AM
    Moderator
  • Thank you people! I thought whenever I get a reply the system will let me know but it hasn't. I will let you know how it went.
    Thursday, March 23, 2006 11:41 PM
  • Thanks for your help, all the links have been very helpful but see, the more I look at SNMP I am not sure if it will do what I want to do.

    Basically, and this is more of a design question, I would like to send accross a network DataTables with some info. In a nutshell, I will have a server "listen" or "calling" machines asking them for these DataTables. Clients will "listen" to server calls or will send these DataTables when they think it is necesary.

    My initial thought was that I could add the DataTables as my Variable Binding List (VBL) in a SNMP packet and send them accross. Do you think this is possible? My other option is to open a port and listen on that port for requests from the server or clients or viceversa (now, I would have ot figure out that whole port thing ujst like SNMP). Even a third option is to have a database, have the clients store the info and then the server would pull it out from the database and show it in a comprehensive manner to the user. Could you please help me? I would really appreciate your help.

    Saturday, March 25, 2006 5:58 PM
  • A DataTable can easily be serialized to Xml or a Binary stream. I think that is the easiest way to design it.

    Just use TCP/IP and send the serialized DataTable to the caller.
    Tuesday, March 28, 2006 6:39 AM
    Moderator
  • Thank you, it looks like only TCP/IP will do the trick.
    Tuesday, March 28, 2006 9:44 PM
  • Hi,

    I would do the exactly the same,  how have you success ?

    Thanks !

    Monday, May 14, 2007 7:52 AM
  • Hi,

     

    I want to get the list of printers vailable in my network using SNMP by programming in C#.

    I dont know hoe to do it. Can anyone of you please help me?.

    Friday, April 25, 2008 11:30 AM
  • I'd like to announce a new open source project on this topic, #SNMP.

    http://www.codeplex.com/sharpsnmplib

    LeXtudio
    Wednesday, July 02, 2008 11:40 AM
  • If you don't care some fee, I suggest eMarkSnmp, http://www.emarksoft.com/snmp-examples/csharp-snmp-get.htm

    The sample code seems simple, you could even write some vbs to run it.

    set snmpSession = CreateObject("eMarkSnmp.SnmpSession")  
    set vb = CreateObject("eMarkSnmp.SnmpVarBind")  
     
        snmpSession.Open()  
          
        count = snmpSession.SnmpGet("127.0.0.1", "1.3.6.1.2.1.1.2.0")  
        MsgBox( "Get " & count & " varbinding(s)") 
          
    if count = 1 then  
        set vb = snmpSession.GetVarBind(1)
        Str = Str & "OID: " & vb.ObjectID & vblf 
            Str = Str & "String Value: " & vb.ToString() & vblf 
                Str = Str & "HexString: "& vb.ToHexString() & vblf 
    MsgBox(Str)

    end if  
     
    snmpSession.Close()


    Great, it works!

    Thursday, February 04, 2010 4:50 PM
  • Hi All !

    May be, I am to blind to see?? I am missing a reference to the most important snmp library, which is available for .Net.
    See here: http://sharpsnmplib.codeplex.com/
    [Sorry, do not know, how to create valid links herin].

    Best regards,
    --scamb
    Thursday, February 04, 2010 6:43 PM