Author | Forum: PowerSNMP for .NET Topic: Length of parameter "startIndex" |
ChristianPf From: Ravensburg, Germany Posts: 4 Member Since: 08/02/11 |
posted August 2, 2011 8:48 AM I use your framework developing my own SNMP-Agent and test it with your Sample-Manager. If I query a table my agent will submit all entries correct using the method shown in your Agent-Sample. After submitting the next MIB-Entry after the table the manager shows the following error message: startIndex must not be longer than the length of string. Unfortunately I cant find any way to modify this parameter neither in the samples nor in the help. What do I have to do to repair this bug? Another question: Wich OID should GetRespond answer in case of "EndOfMIB"? |
Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted August 2, 2011 3:37 PM Before we go any further, it sounds like you are trying to create your own Agent control instead of using the Agent Class that comes with PowerSNMP, is that the case? If it is the case do you mind if I ask why the Agent that is included is insufficient for your needs? |
ChristianPf From: Ravensburg, Germany Posts: 4 Member Since: 08/02/11 |
posted August 3, 2011 3:05 AM I use the Agent class of PowerSNMP. Maybe I just haven't discovered the needed functions of the class. But if I am right when I get a GetNextMessage I have to use the GetNext-Method of the VariableList-property of the Agent class instance to get the variable I have to respond with. This is my GetNextMessage-Handler: GetNextMessage message = (GetNextMessage)request; if ((message.Variables == null) | (message.Variables.Count == 0)) { response.ErrorIndex = 0; response.ErrorStatus = ErrorStatus.WrongLength; break; } for (int i = 0; i < message.Variables.Count; i++) { String currentID = message.Variables[i].Id; //Es wird eine neue Variable nach denselben Regeln wie bei GetMessage erzeugt, //nur mit der ID der nächsten Variable im Baum Variable nextVar = agent.Variables.GetNext(currentID); if (nextVar == null) { response.ErrorIndex = i; response.ErrorStatus = ErrorStatus.NoSuchName; break; } response.Variables.Add(nextVar); |
ChristianPf From: Ravensburg, Germany Posts: 4 Member Since: 08/02/11 |
posted August 3, 2011 4:35 AM I found out that this is an exception thrown by the getTable-Method. Maybe there is something wrong in my table initialisation. If I create a new Variable in my the Agent VariableList for a standard scalar object its Id is the OID followed by ".0" (the Iid). If i create new Variables for a table (e.g. the sysORTable in the system tree) i have to create the following: sysORTable : 1.3.6.1.2.1.1.9 : noValue : Table sysOREntry : 1.3.6.1.2.1.1.9.1 : noValue : Entry sysORIndex : 1.3.6.1.2.1.1.9.1.1 : noValue : Column sysORID : 1.3.6.1.2.1.1.9.1.2 : noVlaue : Column sysORDescr : 1.3.6.1.2.1.1.9.1.3 : noValue : Column sysORUpTime : 1.3.6.1.2.1.1.9.1.4 : noValue : Column Integer : 1.3.6.1.2.1.1.9.1.1.1 : Value : Row Integer : 1.3.6.1.2.1.1.9.1.1.2 : Value : Row Id : 1.3.6.1.2.1.1.9.1.2.1 : Value : Row Id : 1.3.6.1.2.1.1.9.1.2.2 : Value : Row OctetString : 1.3.6.1.2.1.1.9.1.3.1 : Value : Row OctetString : 1.3.6.1.2.1.1.9.1.3.2 : Value : Row TimeTicks : 1.3.6.1.2.1.1.9.1.4.1 : Value : Row TimeTicks : 1.3.6.1.2.1.1.9.1.4.2 : Value : Row Is that correct or did i misunderstood something in the concept of MIB-Tables? |
Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted August 3, 2011 5:03 PM All that GetTable does is send a lot of get next messages to populate the table, so it is possible that the table error is being caused by the response you are constructing for the get next messages. Have you tried using the Agent.GetDefaultResponse Method? It should create a ready to send response message for you. |
ChristianPf From: Ravensburg, Germany Posts: 4 Member Since: 08/02/11 |
posted August 4, 2011 3:12 AM I tried CreateDefaultResponse before, but I got the same error message. Then I found out, that I am not allowed to create variables of the table and the columns itself. According to my last post the correct initialisation is just the following: Integer : 1.3.6.1.2.1.1.9.1.1.1 : Value : Row Integer : 1.3.6.1.2.1.1.9.1.1.2 : Value : Row Id : 1.3.6.1.2.1.1.9.1.2.1 : Value : Row Id : 1.3.6.1.2.1.1.9.1.2.2 : Value : Row OctetString : 1.3.6.1.2.1.1.9.1.3.1 : Value : Row OctetString : 1.3.6.1.2.1.1.9.1.3.2 : Value : Row TimeTicks : 1.3.6.1.2.1.1.9.1.4.1 : Value : Row TimeTicks : 1.3.6.1.2.1.1.9.1.4.2 : Value : Row If I query the table now, it works properly. But if I try to query just one column, I get the same error message like before. Is this something that isnt allowed in SNMP or is this just not implemented in your Free Manager? |
Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted August 5, 2011 4:24 PM You can't get a single column but you can get a cell for example if you want to get the SysOrUptime for the first entry in the table then you would need to query 1.3.6.1.2.1.1.9.1.4.1, the 4 being the column and the 1 being the row trying to query 1.3.6.1.2.1.1.9.1.4 should return a NoSuchObject for a Get Message, that is what I get when I enter the incorrect OID as a Query. The only time I was able to get the error message that you are describing is when I tried to use GetTable on an OID that wasn't a table. For example trying to use Get table on OID 1.3.6.1.2.1.1 resulted in an error. You should take a look at the Agent sample that is included with the product as it demonstrates how to set up a custom table and also how to add entries to that table. You want to look at where it adds entries to the table as that is what you need to be doing on the Agent because the SysORTable itself is already defined in the Agent. |
Reply | PowerSNMP for .NET Topics | Forums |
This site is powered by
![]() |