PowerSNMP for .NET
GetBulkMessage Class
Members  Example 




The GetBulkMessage class can be used to request large amounts of information from SNMP version 2/3 agents.
Object Model
GetBulkMessage ClassDecodingException ClassVariableCollection ClassVariable Class
Syntax
<SerializableAttribute()>
Public Class GetBulkMessage 
   Inherits RequestMessage
Dim instance As GetBulkMessage
[Serializable()]
public class GetBulkMessage : RequestMessage 
[Serializable()]
public __gc class GetBulkMessage : public RequestMessage 
[Serializable()]
public ref class GetBulkMessage : public RequestMessage 
Remarks

For a higher-level method designed for retrieving a whole table using GetBulk requests, use SnmpSocket.GetTable().

GetBulkMessage derives from the RequestMessage class. It is typically used by an SNMP manager to request repetitive row (table) information from an SNMP agent. The agent will typically respond by constructing and sending the manager a ResponseMessage that can be very large.

Serializable using BinaryFormatter and XmlSerializer.

Example
The following example demonstrates how to send a GetBulk request and display the response.
private void button1_Click(object sender, EventArgs e)
{
    //Create and send request on a worker thread
    manager1.Start(sendRequest, manager1.Mib.CreateVariable(NodeName.system));
}

private void sendRequest(SnmpSocket managerSocket, object state)
{
    //Create GetBulk request
    GetBulkMessage request = new GetBulkMessage();

    //Retrieve the next 6 objects after 'system'
    //This means creating a GetBulk message with a single variable and Repetitions set to 6.
    request.Repetitions = 6;
    request.Variables.Add(state as Variable);

    //Send request and get response
    //Response will include next 6 supported objects, which should be sysDescr, sysObjectID, 
    //sysUpTime, sysContact, sysName, and sysLocation
    ResponseMessage response = managerSocket.GetResponse(request, myAgentAddress);

    //Marshal response to the UI thread using the Message event
    manager1.Marshal(new ResponseMessage[] { response }, "", null);
}

private void manager1_Message(object sender, Dart.Snmp.MessageEventArgs e)
{
    //Fires on the UI thread
    //Display info about the variables in the response
    ResponseMessage response = (ResponseMessage)e.Messages[0];
    foreach (Variable v in response.Variables)
        label1.Text += v.Id + ": " + v.Value.ToString() + Environment.NewLine;
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    'Create and send request on a worker thread
    manager1.Start(AddressOf sendRequest, manager1.Mib.CreateVariable(NodeName.system))
End Sub

Private Sub sendRequest(ByVal managerSocket As SnmpSocket, ByVal state As Object)
    'Create GetBulk request
    Dim request As New GetBulkMessage()

    'Retrieve the next 6 objects after 'system'
    'This means creating a GetBulk message with a single variable and Repetitions set to 6.
    request.Repetitions = 6
    request.Variables.Add(TryCast(state, Variable))

    'Send request and get response
    'Response will include next 6 supported objects, which should be sysDescr, sysObjectID, 
    'sysUpTime, sysContact, sysName, and sysLocation
    Dim response As ResponseMessage = managerSocket.GetResponse(request, myAgentAddress)

    'Marshal response to the UI thread using the Message event
    manager1.Marshal(New ResponseMessage() { response }, "", Nothing)
End Sub

Private Sub manager1_Message(ByVal sender As Object, ByVal e As Dart.Snmp.MessageEventArgs)
    'Fires on the UI thread
    'Display info about the variables in the response
    Dim response As ResponseMessage = CType(e.Messages(0), ResponseMessage)
    For Each v As Variable In response.Variables
        label1.Text &= v.Id & ": " & v.Value.ToString() & Environment.NewLine
    Next v
End Sub
Inheritance Hierarchy

System.Object
   Dart.Snmp.MessageBase
      Dart.Snmp.StandardMessage
         Dart.Snmp.RequestMessage
            Dart.Snmp.GetBulkMessage

See Also

Reference

GetBulkMessage Members
Dart.Snmp Namespace

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