문제

I'm testing the SharpSNMP lib and playing a bit with the examples, the library is great but lacks of some documentation.

my question is how can i change the community where i am listening the traps because nothing in the examples makes me sense.

        if (args.Length != 0)
        {
            return;
        }

        Container = new UnityContainer().LoadConfiguration("snmptrapd");
        var users = Container.Resolve<UserRegistry>();
        users.Add(new OctetString("neither"), DefaultPrivacyProvider.DefaultPair);
        users.Add(new OctetString("authen"), new DefaultPrivacyProvider(new MD5AuthenticationProvider(new OctetString("authentication"))));
        users.Add(new OctetString("privacy"), new DESPrivacyProvider(new OctetString("privacyphrase"),
                                                                     new MD5AuthenticationProvider(new OctetString("authentication"))));

        var trapv1 = Container.Resolve<TrapV1MessageHandler>("TrapV1Handler");
        trapv1.MessageReceived += WatcherTrapV1Received;
        var trapv2 = Container.Resolve<TrapV2MessageHandler>("TrapV2Handler");
        trapv2.MessageReceived += WatcherTrapV2Received;
        var inform = Container.Resolve<InformRequestMessageHandler>("InformHandler");
        inform.MessageReceived += WatcherInformRequestReceived;
        using(var engine = Container.Resolve<SnmpEngine>())
        {
            engine.Listener.AddBinding(new IPEndPoint(IPAddress.Any, 162));
            engine.Start();
            Console.WriteLine("#SNMP is available at http://sharpsnmplib.codeplex.com");
            Console.WriteLine("Press any key to stop . . . ");
            Console.Read();
            engine.Stop();
        }
도움이 되었습니까?

해결책

The users are added to the user registry so if an SNMP v3 message (TRAP v2 or INFORM) the trap agent can handle it properly.

If in your scenarios you need to use other users, you can manually create them and then insert into the registry.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top