lextudio / sharpsnmplib

Sharp SNMP Library- Open Source SNMP for .NET
https://sharpsnmp.com
MIT License
356 stars 152 forks source link

polling SNMP #675

Closed lextudio-support closed 4 hours ago

lextudio-support commented 4 hours ago

I'm a newbie to this SNMP world.

I'm trying to setup a routine in C# where the server/manager could poll and get the statuses. I tried to find something related in the discussions list, but didn't find anything helping.

This is what I've done so far,

            IEnumerable<IModule> modules = Parser.Compile(@"C:\temp\sample.mib");

            DefaultObjectRegistry.Instance.Import(modules);
            DefaultObjectRegistry.Instance.Refresh();

            string moduleName = string.Empty;
            foreach (IModule module in modules)
            {
                moduleName = module.Name;
                break;
            }

            uint[] id = DefaultObjectRegistry.Instance.Translate(moduleName + "::" + name);

            var snmpTrapsConfiguration = (SnmpTrapsConfigurationSection)ConfigurationManager.GetSection("snmpTraps");
            var address = IPAddress.Parse(snmpTrapsConfiguration.Recipient);
            var community = new OctetString(snmpTrapsConfiguration.CommunityName);
            var enterprise = new ObjectIdentifier(snmpTrapsConfiguration.Enterprise);

            Messenger.Get(VersionCode.V2, new IPEndPoint(address, 162), community,  new List<Variable>(), 0);

Starting from the first line, I get errors. I've read up about SNMP; MIB and Polling, so I know how these things work in theory but unable to write a piece of code for snmp polling.

Here's the sample MIB that I created.

https://www.dropbox.com/s/wi1jy6nzh4kajpe/sample.mib

Thanks,

Nick

Original Reported Date: 2012-09-25T00:57:55.173-07:00 Original CodePlex Discussion Thread ID: 396781

lextudio-support commented 4 hours ago

Copied from CodePlex without authors:

What you asked has already been covered in previous threads, so please spare some time reading them. Lex

Original Posted Date: 2012-09-25T22:42:20.977-07:00

lextudio-support commented 4 hours ago

Marked as Answer Date: 2013-10-06T04:11:35.787-07:00