public GetBulk ( Pdu pdu ) : AsnType>.Dictionary |
||
pdu | Pdu | Request Protocol Data Unit |
Результат | AsnType>.Dictionary |
public bool SnmpBulkGetTest(string host, string community, string[] oids) { try { SimpleSnmp snmp = new SimpleSnmp(host, community); if (!snmp.Valid) { return false; } Dictionary<Oid, AsnType> result = snmp.GetBulk(oids); if (result == null) { return false; } LogResult(result); return true; } catch (Exception) { return false; } }
private void SNMPGetInfo() { if (this.krbSNMP.Checked) { try { SimpleSnmp snmp = new SimpleSnmp(Properties.Settings.Default.ip, this.kcbCommunity.SelectedItem.ToString()); snmp.Retry = 5; snmp.Timeout = 60000; snmp.SuppressExceptions = false; string oid = Properties.Settings.Default.oid; Dictionary<Oid, AsnType> result = null; if (this.kcbMethod.SelectedItem.ToString() == "Get NEXT") { Pdu pdu = new Pdu(); pdu.Type = PduType.GetNext; pdu.VbList.Add(oid); result = snmp.GetNext(SnmpVersion.Ver1, pdu); } else if (this.kcbMethod.SelectedItem.ToString() == "GET") { // Create a request Pdu Pdu pdu = new Pdu(); pdu.Type = PduType.Get; pdu.VbList.Add(oid); result = snmp.GetNext(SnmpVersion.Ver1, pdu); } else if (this.kcbMethod.SelectedItem.ToString() == "Walk") { result = snmp.Walk(SnmpVersion.Ver2, oid); } else if (this.kcbMethod.SelectedItem.ToString() == "Get BULK") { //Using GetBulk Pdu pdu = new Pdu(); pdu.Type = PduType.GetBulk; pdu.VbList.Add(oid); pdu.NonRepeaters = 0; pdu.MaxRepetitions = Convert.ToInt32(this.krypTxtBxRepeaters.Text); result = snmp.GetBulk(pdu); } ktbResult.SuspendLayout(); ktbResult.Clear(); if (result == null) { ktbResult.AppendText("Request failed.\r\n"); } else { ktbResult.SuspendLayout(); foreach (KeyValuePair<Oid, AsnType> entry in result) { ktbResult.AppendText(String.Format("{0} = {1}: {2}\r\n", entry.Key.ToString(), SnmpConstants.GetTypeName(entry.Value.Type), entry.Value.ToString())); } ktbResult.ResumeLayout(); } } catch (Exception snmpEx) { ComponentFactory.Krypton.Toolkit.KryptonMessageBox.Show(snmpEx.Message, "SNMP Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } ktbResult.Focus(); ktbResult.SelectionStart = 0; ktbResult.SelectionLength = 0; ktbResult.ScrollToCaret(); ktbResult.ResumeLayout(); } }