PowerSNMP for .NET
Walk(String,SnmpVersion,String,Security,IPEndPoint,Int32) Method
Example 




The root OID.
SnmpVersion to use.
Community string to use. "public" is a typical value.
Security parameters for SnmpVersion.Three. Can be null.
The IPEndPoint of the agent.
The number of times to retry a request if it times out waiting for a response.
Performs a series of blocking requests to walk a mib.
Syntax
Public Overloads Function Walk( _
   ByVal rootOid As String, _
   ByVal version As SnmpVersion, _
   ByVal community As String, _
   ByVal security As Security, _
   ByVal agentEP As IPEndPoint, _
   ByVal retries As Integer _
) As VariableList
Dim instance As SnmpSocket
Dim rootOid As String
Dim version As SnmpVersion
Dim community As String
Dim security As Security
Dim agentEP As IPEndPoint
Dim retries As Integer
Dim value As VariableList
 
value = instance.Walk(rootOid, version, community, security, agentEP, retries)

Parameters

rootOid
The root OID.
version
SnmpVersion to use.
community
Community string to use. "public" is a typical value.
security
Security parameters for SnmpVersion.Three. Can be null.
agentEP
The IPEndPoint of the agent.
retries
The number of times to retry a request if it times out waiting for a response.

Return Value

A List of variables under rootOid.
Remarks

This method walks the MIB by sending a GetNextMessage for each element under the root oid. Returns after the complete subtree has been retrieved or any single request exceeds the value of the Socket.ReceiveTimeout property. If retries is greater than 0, each retry must timeout before a timeout exception occurs. The time required to complete this request is a function of the number of available instance Id's (IID's) under the root oid.

Example
The following example demonstrates how to walk a MIB and display the response variables.
private void button1_Click(object sender, EventArgs e)
{
    //Perform MIB walk on a worker thread
    manager1.Start(walkMib, manager1.Mib.GetByNodeName(NodeName.system).Oid);
}

private void walkMib(SnmpSocket managerSocket, object state)
{
    //The state contains the OID to walk (in this case, the system group)
    string oid = state as string;

    //Walk the MIB from the specified root OID
    VariableList variables = managerSocket.Walk(oid, myAgentAddress);

    //Marshal variables returned to the UI thread using the Walk event
    manager1.Marshal(oid, variables, "", null);
}

private void manager1_Walk(object sender, WalkEventArgs e)
{
    //Populate a treeview control with the returned variables
    e.Variables.Populate(tvwVariables, e.Oid, manager1.Mib);
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    'Perform MIB walk on a worker thread
    manager1.Start(AddressOf walkMib, manager1.Mib.GetByNodeName(NodeName.system).Oid)
End Sub

Private Sub walkMib(ByVal managerSocket As SnmpSocket, ByVal state As Object)
    'The state contains the OID to walk (in this case, the system group)
    Dim oid As String = TryCast(state, String)

    'Walk the MIB from the specified root OID
    Dim variables As VariableList = managerSocket.Walk(oid, myAgentAddress)

    'Marshal variables returned to the UI thread using the Walk event
    manager1.Marshal(oid, variables, "", Nothing)
End Sub

Private Sub manager1_Walk(ByVal sender As Object, ByVal e As WalkEventArgs)
    'Populate a treeview control with the returned variables
    e.Variables.Populate(tvwVariables, e.Oid, manager1.Mib)
End Sub
See Also

Reference

SnmpSocket Class
SnmpSocket Members
Overload List

6.1.1.2
PowerSNMP for .NET Documentation Version 7.0
© 2023 Dart Communications. All Rights Reserved.
Send comments on this topic