Login  
Search All Forums
Dart Home | PowerSNMP for .NET | Custom Development Reply | PowerSNMP for .NET Topics | Forums   
AuthorForum: PowerSNMP for .NET
Topic: SnmpSocket::GetTable returning 0 columns and 0 rows
euan.torano

From: Barnard Castle, United Kingdom
Posts: 4
Member Since: 08/04/22
posted August 4, 2022 7:11 AM

I'm trying to use PowerSNMP 6 in C# .NET 6 and .NET Framework 4.8, to talk to a Ruckus ZoneDirector Wi-Fi controller.

I'm trying to read entries from the "ruckusZDAPConfigTable" table, specifically he following columns:

- ruckusZDAPConfigMacAddress
- ruckusZDAPConfigDeviceName
- ruckusZDAPConfigDescription
- ruckusZDAPConfigLocation
- ruckusZDAPConfigIpAddress

My code looks like the following - it starts off by parsing the MIBs from the current working directory, and then tries using `SnmpSocket::GetTable` and then tries using a manual `GetBulkMessage` request:

----------
using System.Net;
using Dart.Snmp;
using IPEndPoint = Dart.Snmp.IPEndPoint;

const string community = "public";

License.Set(@"...");

using Manager snmpManager = new Manager();

using SnmpSocket snmpSocket = new SnmpSocket(snmpManager)
{
  ReceiveTimeout = 5000
};

IPEndPoint host = new IPEndPoint(IPAddress.Parse("10.0.0.2"), Agent.DefaultPort);

string[] mibFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.txt", SearchOption.TopDirectoryOnly);

foreach (string mibFile in mibFiles)
{
  using FileStream fs = File.OpenRead(mibFile);

  snmpManager.Mib.Parse(fs);
}

snmpManager.Mib.GenerateNodes();

Console.WriteLine("Getting table");
Console.WriteLine();

Variable[,] ifTable = snmpSocket.GetTable(snmpManager.Mib["ruckusZDAPConfigTable"].Oid, SnmpVersion.Two, community, null, host, 3, 500);

if (ifTable.GetLength(0) == 0)
{
  Console.Error.WriteLine("No rows in table");
}

if (ifTable.GetLength(1) == 0)
{
  Console.Error.WriteLine("No columns in table");
}

for (int i = 0; i < ifTable.GetLength(0); i++)
{
  if (i > 0)
  {
    Console.WriteLine();
  }

  Console.WriteLine($"Row #{i}");

  for (int j = 0; j < ifTable.GetLength(1); j++)
  {
    Variable v = ifTable[i, j];

    Console.WriteLine($"\t{v}");
  }
}

Console.WriteLine();
Console.WriteLine("Custom bulk request");
Console.WriteLine();

GetBulkMessage manualTableRequest = new GetBulkMessage
{
  Repetitions = 500,
  NonRepeaters = 0,
  Community = community,

};

manualTableRequest.Variables.Add(new Variable(snmpManager.Mib["ruckusZDAPConfigTable"]));
//manualTableRequest.Variables.Add(new Variable(snmpManager.Mib["ruckusZDAPConfigMacAddress"]));
//manualTableRequest.Variables.Add(new Variable(snmpManager.Mib["ruckusZDAPConfigDeviceName"]));
//manualTableRequest.Variables.Add(new Variable(snmpManager.Mib["ruckusZDAPConfigDescription"]));
//manualTableRequest.Variables.Add(new Variable(snmpManager.Mib["ruckusZDAPConfigLocation"]));
//manualTableRequest.Variables.Add(new Variable(snmpManager.Mib["ruckusZDAPConfigIpAddress"]));

ResponseMessage response = snmpSocket.GetResponse(manualTableRequest, host);

Console.WriteLine(response.ToString());
----------

The result always looks like the following (several result rows omitted from the bottom):

----------
Getting table

No rows in table
No columns in table

Custom bulk request

Message Type: ResponseMessage
Time Received: 04/08/2022 12:09:07
SNMP Version: Two
Origin Address/Port: 10.0.0.2:161
Destination Address/Port: 0.0.0.0:56631
Community: mtspublic
Id: 2
Variable IIDs and Values:
  1.3.6.1.4.1.25053.1.4.1.1.1.15.1.0: 42
  1.3.6.1.4.1.25053.1.4.1.1.1.15.1.0: 42
  1.3.6.1.4.1.25053.1.4.1.1.1.15.1.0: 42
  1.3.6.1.4.1.25053.1.4.1.1.1.15.1.0: 42
  1.3.6.1.4.1.25053.1.4.1.1.1.15.1.0: 42
  1.3.6.1.4.1.25053.1.4.1.1.1.15.2.0: 113
  1.3.6.1.4.1.25053.1.4.1.1.1.15.2.0: 113
  1.3.6.1.4.1.25053.1.4.1.1.1.15.2.0: 113
  1.3.6.1.4.1.25053.1.4.1.1.1.15.2.0: 113
  1.3.6.1.4.1.25053.1.4.1.1.1.15.2.0: 113
  ...
----------

Ideally I'd like to use `SnmpSocket::GetTable()`, as it seems like parsing the result of this call would be much easier.

(Note, the commented out code was my attempt at only reading the desired columns, but I don't know if I understood the documentation properly regarding whether that is even possible... I unfortunately don't know the number of rows in the table ahead of time and need to get every row, but only 5 specific columns from every row)
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted August 4, 2022 1:18 PM

Hello,

Are you able to retrieve one of the basic tables, such as ifTable?

Variable[,] table = managerSocket.GetTable(manager1.Mib.GetByNodeName(NodeName.ifTable).Oid, SnmpVersion.Two, "public", null, myAgentAddress, 0);

http://dotnet.dart.com/help/psnet/webframe.html#Dart.Snmp~Dart.Snmp.SnmpSocket~GetTable(String,String).html
euan.torano

From: Barnard Castle, United Kingdom
Posts: 4
Member Since: 08/04/22
posted August 4, 2022 1:49 PM

Yes, requesting one of the basic tables works fine - that was the first thing I tested :)

I also attempted to submit a support ticket earlier using the online form, but wasn't sure if that had gone through as there wasn't any kind of success or error message shown that I could see.

I can share Wireshark captures and/or MIB files if need be as I have both readily available.
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted August 4, 2022 2:06 PM

Hello,

Can you provide the complete log (sent and received) from when trying to use GetTable(), and when trying your custom Bulk request? If you can't share it in the forum, please send it into support@dart.com.

//Call file.Close() when the app shuts down
FileStream file = new FileStream("log.txt", FileMode.Append, FileAccess.Write);

private void manager1_Log(object sender, LogEventArgs e)
{
  //Write SNMP packets to a file
  string label = (e.Message.Origin == null) ? "\r\nSent:\r\n" : "\r\nReceived:\r\n";
  file.Write(System.Text.Encoding.Default.GetBytes(label), 0, label.Length);
  file.Write(e.Message.EncodedMessage, 0, e.Message.EncodedMessage.Length);
}
euan.torano

From: Barnard Castle, United Kingdom
Posts: 4
Member Since: 08/04/22
posted August 5, 2022 3:59 AM

No problem, I'll send an email shortly with the log file that has been created, my program's code, a Wireshark capture, and a capture of the stdout from the program.
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted August 5, 2022 4:01 PM

Hello,

GetTable() doesn't return the table, as there appears to be nothing under it.

Your GetBulk request of
1.3.6.1.4.1.25053.1.2.2.4.1.1.1
returns a first IID of
1.3.6.1.4.1.25053.1.4.1.1.1.15.1.0
which is not under the specified table, therefore all variables (not under the table OID) within the response are discarded.

The wireshark log shows us sending the same request (with the only difference of message id), and receiving the same response.
euan.torano

From: Barnard Castle, United Kingdom
Posts: 4
Member Since: 08/04/22
posted August 8, 2022 4:50 AM

Aha, thanks for that! It seems the client we're working with have updated the firmware on their controller and Ruckus have changed the MIBs with the new firmware. This just happened to coincide with us updating to the current version of PowerSNMP which led to our confusion.
Reply | PowerSNMP for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX