Beispiel #1
0
        public void testGetTable()
        {
            SNMP_Agent agent = new SNMP_Agent("localhost", "public");

            //tcpConnTable
            string oid = ".1.3.6.1.2.1.4.20.1";

            //IPAddress IP = IPAddress.Parse("127.0.0.1");

            var result = agent.GetTableRequest(SnmpVersion.Ver2, oid);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count != 0);

            //Wyświetlanie tabeli
            foreach (var key in result)
            {
                var dictionary = key.Value;

                foreach (var KEY in dictionary)
                {
                    Console.WriteLine("Column: " + KEY.Key + " Value: " + KEY.Value);
                }
            }
        }
Beispiel #2
0
        public Form1()
        {
            InitializeComponent();
            _Application = this;

            snmp_agent = new SNMP_Agent("127.0.0.1", "public");
            IP         = IPAddress.Parse("127.0.0.1");
            AddressTextBox.ReadOnly = true;

            OperationsComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            OperationsComboBox.Items.Add("Get");
            OperationsComboBox.Items.Add("Get Next");
            OperationsComboBox.Items.Add("Get Table");
            AddressTextBox.Text = "localhost";
            stopReciverToolStripMenuItem.Enabled = false;


            imageList.Images.Add(Properties.Resources.Folder);
            imageList.Images.Add(Properties.Resources.key);
            imageList.Images.Add(Properties.Resources.entry);
            imageList.Images.Add(Properties.Resources.listek);
            imageList.Images.Add(Properties.Resources.paper);
            imageList.Images.Add(Properties.Resources.table);

            mibElementsDictionary = new Dictionary <string, string>();
            loadMibTreeElements();

            initiationTrapSender();


            trapAgent = new TrapAgent();
        }
Beispiel #3
0
        public void setUp()
        {
            SNMP_Agent agent = new SNMP_Agent();

            Assert.AreEqual(agent.snmp.Community, "public");
            Assert.AreEqual(agent.snmp.PeerName, "localhost");
            Assert.IsTrue(agent.snmp.Valid);
        }
        public void TestGetRequest1()
        {
            SNMP_Agent agent = new SNMP_Agent();
            string     oid   = "1.3.6.1.2.1.2.2.1";

            var result = agent.GetRequest(SnmpVersion.Ver2, oid);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ContainsValue(new Oid(oid)));
        }
Beispiel #5
0
        public void testGetTable()
        {
            SNMP_Agent agent = new SNMP_Agent("127.0.0.1", "public");

            //tcpConnTable
            string oid = ".1.3.6.1.2.1.6.13";

            IPAddress IP = IPAddress.Parse("127.0.0.1");

            var result = agent.GetTableRequest(SnmpVersion.Ver2, oid);

            Assert.IsNotNull(result);
        }
Beispiel #6
0
        public void TestGetNextRequest1()
        {
            SNMP_Agent agent = new SNMP_Agent("127.0.0.1", "public");
            string     oid   = "1.3.6.1.2.1.2.2.1.17.1";
            IPAddress  IP    = IPAddress.Parse("127.0.0.1");

            var result = agent.GetNextRequest(SnmpVersion.Ver1, oid, IP);

            // Pdu class used for all requests
            Pdu pdu = new Pdu(PduType.GetNext);

            pdu.VbList.Add(oid); //sysDescr

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Version, SnmpVersion.Ver1);

            //VarBindListy pdu zwracanego i wygenerowanego w tym tescie powinny byc inne
            Assert.AreNotEqual(result.Pdu.VbList, pdu.VbList);

            Console.WriteLine(result.Pdu.VbList[0].Value.ToString());
        }