Author | Forum: PowerSNMP for .NET Topic: MibNode.ComposedSyntax - table entry case seems to have been modified... |
craigd From: Belair, Australia Posts: 7 Member Since: 05/10/16 |
posted May 10, 2016 6:38 AM I am evaluating PowerSnmp and I'm looking to find a way to convert a table's indexes to use as a concatenated key in a database (rather than storing it raw). Working from a table node, down to the entry node, I've noticed that the table node references "SEQUENCE OF xxxxx". I can parse the entry name but it would appear as though the first character has been capitalised. This means the entry cannot be used as an index for lookup. I am pretty sure there should be an easier way to establish the values of the keys to a table than as per below, but keen to get an understanding as to how this works. var syntax = tableNode.ComposedSyntax; var match = Regex.Match(tableNode.ComposedSyntax, "SEQUENCE OF (\\w+)"); if (match.Success) { var entry = managerMain.Mib[Char.ToLowerInvariant(m.Groups[1].Value[0]) + m.Groups[1].Value.Substring(1)]; ... } For reference, I am using h3cDot11APObjectTable from H3C-DOT11-APMT-MIB. |
craigd From: Belair, Australia Posts: 7 Member Since: 05/10/16 |
posted May 10, 2016 7:11 AM Sorry - still trying to get my head around all of this. I've just realised my error. The details are exactly as parsed...just not easy to infer the row index values. |
Nick B (Admin) From: Utica, NY USA Posts: 619 Member Since: 05/25/10 Extra Support Options Custom Application Development |
posted May 10, 2016 9:53 AM Hello, It sounds like you're trying to get the definitions of the table columns; if that's correct, MibNodes.GetTableColumns() can be used to easily get the columnar MibNodes assoicated with a table: http://www.dart.com/help/psnet/webframe.html#Dart.Snmp~Dart.Snmp.MibNodes~GetTableColumns.html |
craigd From: Belair, Australia Posts: 7 Member Since: 05/10/16 |
posted May 11, 2016 1:59 AM All good with the columns. It is just that the "table" only returns the non-key data. As the key of te row is embedded in the oid, I am trying to work out how to get the key values easily (without having to reinvent the wheel an parse the oid octets manually). Thanks |
Nick B (Admin) From: Utica, NY USA Posts: 619 Member Since: 05/25/10 Extra Support Options Custom Application Development |
posted May 11, 2016 10:33 AM Hello, Once you've got the column MibNodes, you can strip out their OID from the table cell's IID to get the row indexer. |
craigd From: Belair, Australia Posts: 7 Member Since: 05/10/16 |
posted May 13, 2016 5:42 PM Got it. Thanks |
craigd From: Belair, Australia Posts: 7 Member Since: 05/10/16 |
posted May 14, 2016 3:34 AM OK - sorry having hunted for this and not managed to find anything generic that can help, if the row index contains a multi-part indexer, is there a generic way to pull the field values out of what left once you take away the row column oid. I suspect it is a matter of parsing the octet stream and reconstituting variables based on the number of index entries one by one. Let's say it consists of a serial number and an integer. Is there a library call somewhere that can can use the MIB definitions of the columns to parse it out, or does this have to be written from scratch? |
Nick B (Admin) From: Utica, NY USA Posts: 619 Member Since: 05/25/10 Extra Support Options Custom Application Development |
posted May 16, 2016 10:49 AM Hello, Can you provide an example of what you have, and what you're looking to get? |
craigd From: Belair, Australia Posts: 7 Member Since: 05/10/16 |
posted May 17, 2016 5:17 AM I'll summarise some of the entries from relevant MIBs below. I am trying to create a DataTable and populate it for ANY table oid that is known - with primary key variables also included (and these are actual columns, not just a concatenated key). What I get back from a GetTable on h3cDot11APRadioTable below is Variable[10,23] (ie 5 access points with 2 radios each, and 23 columns. The first column (ie column 0) is h3cDot11AdminStatus. after stripping back the oid info, I am left with an encoded string that is the serial number of the access point encoded with the string length as the first byte (ie abc = 3.65.66.67) followed by the radio number (.1). I can't understand how to generically parse the Iid based on the string that is returned after the column oid has been stripped away. A different vendor actually returns all columns as in addition to the Iid. Does your library provide a way to parse based on the types documented in the Mib as per below? H3cDot11ObjectIDType ::= TEXTUAL-CONVENTION STATUS current DESCRIPTION "Represents AP identifier value type." SYNTAX OCTET STRING(SIZE(0..127)) H3cDot11RadioScopeType ::= TEXTUAL-CONVENTION STATUS current DESCRIPTION "Represents radio value scope." SYNTAX Integer32 h3cDot11APRadioTable OBJECT-TYPE SYNTAX SEQUENCE OF H3cDot11APRadioEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "The table will describe the radio information of AP. The AP here will be in running status." ::= { h3cDot11APObjectGroup 3 } h3cDot11APRadioEntry OBJECT-TYPE SYNTAX H3cDot11APRadioEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "Each entry contains the information of each radio of a specific AP." INDEX { h3cDot11CurAPID, h3cDot11RadioID } ::= { h3cDot11APRadioTable 1 } H3cDot11APRadioEntry ::= SEQUENCE { h3cDot11CurAPID H3cDot11ObjectIDType, h3cDot11RadioID H3cDot11RadioScopeType, h3cDot11AdminStatus TruthValue, h3cDot11OperStatus TruthValue, h3cDot11Channel H3cDot11ChannelScopeType, h3cDot11TxPowerLevel H3cDot11TxPwrLevelScopeType, h3cDot11APRadioIfIndex Integer32, h3cDot11AntennaGain Integer32, h3cDot11MaxBandwidth Integer32, h3cDot11ResourceUseRatio Integer32, h3cDot11RadioModeSupport Unsigned32, h3cDot11TxPowerLevel2 INTEGER, h3cDot11PowerMgmtStatus TruthValue, h3cDot11ChannelSwitchTimes Counter32, h3cDot11AntennaType OCTET STRING, h3cDot11DiversitySelectionRx TruthValue, h3cDot11MaxTxPwrLvl OCTET STRING, h3cDot11PwrAttRange Integer32, h3cDot11AvgRxSignalStrength Integer32, h3cDot11HighestRxSignalStrength Integer32, h3cDot11LowestRxSignalStrength Integer32, h3cDot11RadioIfUpdownTimes Counter32, h3cDot11RadioIfLastChange TimeTicks, h3cDot11RadioModeSupport2 Unsigned32 } h3cDot11CurAPID OBJECT-TYPE SYNTAX H3cDot11ObjectIDType MAX-ACCESS not-accessible STATUS current DESCRIPTION "To uniquely identify a AP in running status." ::= { h3cDot11APRadioEntry 1 } h3cDot11RadioID OBJECT-TYPE SYNTAX H3cDot11RadioScopeType MAX-ACCESS accessible-for-notify STATUS current DESCRIPTION "Represents each radio." ::= { h3cDot11APRadioEntry 2 } |
Nick B (Admin) From: Utica, NY USA Posts: 619 Member Since: 05/25/10 Extra Support Options Custom Application Development |
posted May 17, 2016 2:34 PM Hello, It sounds like you're only trying to convert the IMPLIED indexer IID for your variables into its string representation. Our component does not currently have built-in functionality for this, but I went ahead and wrote this snippet for you (and I've entered a feature request for this); I tested it with your provided example (*columnOid*.3.65.66.67.1); if it doesn't 100% address your situation, it should demonstrate the fundamentals sufficiently: private string ConvertIid(string columnOid, string iid) { string indexer = iid.Replace(columnOid, ""); string[] indexerSubIds = indexer.Split(new string[] {"."}, StringSplitOptions.RemoveEmptyEntries); int impliedCount = Convert.ToInt32(indexerSubIds[0]); string[] impliedContent = new List<string>(indexerSubIds).GetRange(1, impliedCount).ToArray(); string remainder = ""; if (indexerSubIds.Length > impliedCount + 1) remainder = String.Join(".", new List<string>(indexerSubIds).GetRange(1 + impliedCount, indexerSubIds.Length - (1 + impliedCount)).ToArray()); byte[] impliedBytes = new byte[impliedCount]; for (int i = 0; i <= impliedCount - 1; i++) impliedBytes[i] = (byte)Convert.ToInt32(impliedContent[i]); return columnOid + System.Text.Encoding.Default.GetString(impliedBytes) + "." + remainder; } ------ |
craigd From: Belair, Australia Posts: 7 Member Since: 05/10/16 |
posted May 19, 2016 6:15 PM I appreciate the assistance. Of course that works for this specific example, but I suspect you've answered my question unfortunately. It doesn't look like your product has the ability to do this based purely on the Mib defintion. If I wanted a user to select the table that they want to monitor, and populate a database table with each of the column values, and have columns in the database that are primary keys based on the index, then I'm going to have to manually investigate how the data is returned from the device and have a routine set up to handle every unique situation. I'll have to keep looking for a solution. Product seemed to be pretty good in the other aspects I have reviewed, but without the ability to do this reliably for any table, my idea is not viable. |
Jamie Powell (Admin) From: Rome, NY USA Posts: 448 Member Since: 03/13/07 Extra Support Options Custom Application Development |
posted May 20, 2016 11:29 AM Craig, Thank you for your reply. An email has been sent to you with some additional information. Please let me know if you have not received it and I will be happy to resend. Best regards, Jamie |
Reply | PowerSNMP for .NET Topics | Forums |
This site is powered by
![]() |