Giter VIP home page Giter VIP logo

gosmi's Introduction

gosmi

Starting with v0.2.0, this library is native Go and no longer a wrapper around libsmi. The implementation is currently very close, but may change in the future.

For the native implementation, two additional components have been added:

  • SMIv1/2 parser in parser
  • libsmi-compatible Go implementation in smi

Usage

On Ubuntu for v0.1.0 and below: $ sudo apt-get install libsmi2-dev

Examples

Examples can now be found in:

gosmi's People

Contributors

sleepinggenius2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gosmi's Issues

Panic from CreateTypeFromNode

Hi

What a great library! Thank you!

I've come across a panic in C.GoString initiated from this line in CreateTypeFromNode

if format := C.GoString(smiNode.format); format != "" {

There is no check for smiNode.format being a null pointer (in smi.h the field is char *format inside SmiNode).

I suspect that the next part of this function which similarly calls C.GoString(smiNode.units) is susceptible to a similar problem.

I was parsing IF-MIB when this panic arose.

Regards
Bruce

Parse error

Hi

Using two well-known ITU-T ASN.1 modules:

... I am unable to load said modules using the cmd/smi/main.go example file.

This has been tried by combining the above two files into one (and swapping the order), as well as keeping them separate. In the case of separation, we receive lots of "cannot import" messages but I believe that behavior may be expected due to the nature of how these two modules relate to one another.

The error:

Parse file: /var/lib/snmp/mibs/ietf/PKIX-93:36:6: no match found for .

I know it is reading the file, as I can see the offending line (on my concatenated copy, its line 36):

(WITH COMPONENTS {
   ...,                <-- THE FIRST PERIOD IS WHAT IT IS COMPLAINING ABOUT
   authorityCertIssuer        PRESENT,
   authorityCertSerialNumber  PRESENT
 } |
 WITH COMPONENTS {
   ...,
   authorityCertIssuer        ABSENT,
   authorityCertSerialNumber  ABSENT
 })

I realize these aren't "MIBs" per se, but they still contain valid ASN.1 that, by all rites, should be OK to parse.

I can even take these modules, concatenate them together and parse them via OSS Nokalva's ASN.1 Playground (see here). This includes STRICT checking enabled.

I have no issues parsing my /var/lib/snmp/mibs/ietf, /var/lib/snmp/mibs/iana folder contents, aside from a few known (and accurate) reports of invalid SNMP MIBs present on certain GNU OS releases throughout the years (e.g: SNMPv2-TC). Such cases I could confidently disregard as a result.

I am thus wondering if:

  • If this is considered a bug in gosmi terms -or- if you believe this violates the precepts and goals upon which gosmi was designed, and ...
  • If this can be worked around

Thank you

subcon42

PS --
For reference, here is "healthy" output from the aforementioned OSS Nokalva ASN.1 Playground "concatenated parse job":

OSS ASN-1Step Version 9.0.2
Copyright (C) 2019 OSS Nokalva, Inc.  All rights reserved.
This product is licensed for use by "OSS Nokalva, Inc."

C0043I: 0 error messages, 0 warning messages and 0 informatory messages issued.

ASN1STEP: List of valid unreferenced and/or user-defined PDU numbers and associated PDU names:

       1  AuthorityKeyIdentifier
       2  KeyIdentifier
       3  SubjectKeyIdentifier
       4  KeyUsage
       5  KeyPurposeId
       6  PrivateKeyUsagePeriod
       7  CertificatePoliciesSyntax
       8  PolicyInformation
       9  CertPolicyId
      10  PolicyQualifierInfo
      11  PolicyMappingsSyntax
      12  GeneralNames
      13  GeneralName
      14  EDIPartyName
      15  AttributesSyntax
      16  BasicConstraintsSyntax
      17  NameConstraintsSyntax
      18  GeneralSubtrees
      19  GeneralSubtree
      20  BaseDistance
      21  PolicyConstraintsSyntax
      22  SkipCerts
      23  CRLNumber
      24  CRLReason
      25  HoldInstruction
      26  CRLDistPointsSyntax
      27  DistributionPoint
      28  DistributionPointName
      29  ReasonFlags
      30  IssuingDistPointSyntax
      31  BaseCRLNumber
      32  AuthorityInfoAccessSyntax
      33  AccessDescription
      34  CPSuri
      35  UserNotice
      36  NoticeReference
      37  DisplayText
      38  Certificate
      39  UniqueIdentifier
      40  Version
      41  CertificateSerialNumber
      42  Validity
      43  Time
      44  SubjectPublicKeyInfo
      45  Extensions
      46  Extension
      47  CertificateList
      48  CRLExtensions
      49  CRLExtension
      50  EntryExtensions
      51  EntryExtension
      52  AlgorithmIdentifier
      53  Dss-Sig-Value
      54  DomainParameters
      55  ValidationParms
      56  Dss-Parms
      57  Attribute
      58  AttributeTypeAndValue
      59  Name
      60  RDNSequence
      61  RelativeDistinguishedName
      62  ID
      63  PHGString
      64  ORAddress
      65  BuiltInStandardAttributes
      66  CountryName
      67  AdministrationDomainName
      68  NetworkAddress
      69  X121Address
      70  TerminalIdentifier
      71  PrivateDomainName
      72  OrganizationName
      73  NumericUserIdentifier
      74  PersonalName
      75  OrganizationalUnitNames
      76  OrganizationalUnitName
      77  BuiltInDomainDefinedAttributes
      78  BuiltInDomainDefinedAttribute
      79  ExtensionAttributes
      80  ExtensionAttribute
      81  CommonName
      82  TeletexCommonName
      83  TeletexOrganizationName
      84  TeletexPersonalName
      85  TeletexOrganizationalUnitNames
      86  TeletexOrganizationalUnitName
      87  PDSName
      88  PhysicalDeliveryCountryName
      89  PostalCode
      90  PhysicalDeliveryOfficeName
      91  PhysicalDeliveryOfficeNumber
      92  ExtensionORAddressComponents
      93  PhysicalDeliveryPersonalName
      94  PhysicalDeliveryOrganizationName
      95  ExtensionPhysicalDeliveryAddressComponents
      96  UnformattedPostalAddress
      97  StreetAddress
      98  PostOfficeBoxAddress
      99  PosteRestanteAddress
     100  UniquePostalName
     101  LocalPostalAttributes
     102  PDSParameter
     103  ExtendedNetworkAddress
     104  PresentationAddress
     105  TerminalType
     106  TeletexDomainDefinedAttributes
     107  TeletexDomainDefinedAttribute
     108  CommonName-WITH-SYNTAX
     109  CountryName-WITH-SYNTAX
     110  DnQualifier-WITH-SYNTAX
     111  GenerationQualifier-WITH-SYNTAX
     112  GivenName-WITH-SYNTAX
     113  Initials-WITH-SYNTAX
     114  LocalityName-WITH-SYNTAX
     115  Name-WITH-SYNTAX
     116  OrganizationName-WITH-SYNTAX
     117  OrganizationalUnitName-WITH-SYNTAX
     118  StateOrProvinceName-WITH-SYNTAX
     119  Surname-WITH-SYNTAX
     120  Title-WITH-SYNTAX
     121  ExtendedKeyUsage-SYNTAX
     122  InvalidityDate-SYNTAX
     123  RsaPublicKey-PARMS
     124  RsaSHA-1-PARMS
     125  RsaMD5-PARMS

panic: interface conversion: interface {} is nil, not []uint8

Hi,

Over in Telegraf, we had a report in influxdata/telegraf#15200 of a panic with gosmi. Specifically, it looks like a nil value causes the panic when trying to type assert.

Code

https://github.com/sleepinggenius2/gosmi/blob/v0.4.4/models/format_bits.go#L31

octets := value.([]byte)

Panic

panic: interface conversion: interface {} is nil, not []uint8
goroutine 642 [running]:
github.com/sleepinggenius2/gosmi/models.GetEnumBitsFormatted({0x0?, 0x0?}, 0x90?, 0xc00221da20?)
        /home/builds/go/pkg/mod/github.com/sleepinggenius2/gosmi@v0.4.4/models/format_bits.go:31 +0x598
github.com/sleepinggenius2/gosmi/models.Type.FormatValue({0xb, 0x1, {0x0, 0x0}, 0xc002112340, {0x0, 0x0}, {0x22a2cb2, 0x4}, {0x3939620, ...}, ...}, ...)
        /home/builds/go/pkg/mod/github.com/sleepinggenius2/gosmi@v0.4.4/models/format.go:163 +0x23c
github.com/sleepinggenius2/gosmi/models.Node.FormatValue(...)
        /home/builds/go/pkg/mod/github.com/sleepinggenius2/gosmi@v0.4.4/models/format.go:127
github.com/influxdata/telegraf/plugins/inputs/snmp.(*gosmiTranslator).SnmpFormatEnum(0xc0004c6037?, {0xc002143230?, 0x265ed10?}, {0x0, 0x0}, 0x0)
        /data/agent/workspace/MSE-aragorn-publish/build/telegraf/plugins/inputs/snmp/gosmi.go:139 +0x338

Expected Behavior

Ideally, a user should not see a panic if at all possible. A type assertion should safely check the value to avoid the runtime panic.

Parse Module: Unexpected

I am getting a Parse Module error when trying to parse my mib files.

Parse module: /var/lib/mibs/ietf/DPI20-MIB:9:4: unexpected "ibm" (expected ";")
Parse module: /var/lib/mibs/ietf/HPR-MIB:494:30: unexpected "HprRtpCounter" (expected "}")
Parse module: /var/lib/mibs/ietf/SNMPv2-PDU:73:1: unexpected "max-bindings" (expected "END")
Parse module: /var/lib/mibs/ietf/TCPIPX-MIB:63:12: unexpected "tcpIpxConnLocalPort" (expected "}")

Would it be helpful to link my mib files?

Any ideas on how to fix this or why this is happening would be greatly appreciated.

oid with numbers and letters

I am using GetNode to find node with letters and numbers in the oid (ex .iso.2.3 or RFC1213-MIB::sysUpTime.0) but I am always getting could not find node. Is there a different function I should use?

Couldn't get enough nodes in the MIB file

Hi @sleepinggenius2,

I tried to call gosmi.GetModule() on IEEE8021-TC-MIB but it didn't return me the node "ieee802dot1mibs" for some reason. It leads to some nodes in IEEE8021-Q-BRIDGE-MIB are missing too.

Could you please help me to have a look? I attached the MIB files for you to debug. Hope it would help.

Thanks in advance
Tam

mibs.zip

Ask for an update in parser module cause parser fails to parse hex string in INTEGER syntax

Hi there,

It's me again. I've faced a rare MIB file that contains hex string under Integer syntax type. Would it be much trouble for you to update the parser module to be something like this?

Value string `parser:"\"(\" @( \"-\"? Int ) \")\""`

Value string              `parser:"\"(\" @( \"-\"? Int | HexString ) \")\""`

Please find the line 111 in the attached as a reference. This MIB can be found online from here too under the name "AprisaXECardType".

I look forward to hearing from you soon.
Cheers.
4RF-APRISAXE-TC.zip

GetIndex

I am having an error when calling gosmi.GetIndex() saying it is not declared by gosmi. Can you please provide an example of how to use GetIndex().

Unable to get OID for some nodes

Given the following files comverse-comone-mib.my and comverse-textual-notation.my

When doing

func main() {
	gosmi.Init()
	gosmi.SetPath("../../mibs")
	module, _ := gosmi.LoadModule("comverse-comone-mib.my")
	m, _ := gosmi.GetModule(module)
	trapNodes := m.GetNodes(types.NodeNotification)
	for _, node := range trapNodes {
		log.Printf("Trap %s::%s [%s]\n", module, node.Name, node.Oid)
	}
}

I'm getting this result:

2022/01/28 17:04:55 Trap COMVERSE-COMONE::upAlarmListRebuild []
2022/01/28 17:04:55 Trap COMVERSE-COMONE::upAlarmNew []
2022/01/28 17:04:55 Trap COMVERSE-COMONE::upAlarmChange []
2022/01/28 17:04:55 Trap COMVERSE-COMONE::upAlarmClear []

It's strange gosmi is able to find the nodes, but doesn't have the associated OID with them..

Bug/Leaneancy: MODULE-IDENTITY being defined twice skips half the file

Hello there!

Technically, there should only be one MODULE-IDENTITY according to libsmi:

# via snmilint:
./ZYXEL-ES-COMMON:40: {module-identity-multiple} more than one MODULE-IDENTITY clause in SMIv2 MIB

You can see the double definition here: https://github.com/senpro-it/mibs/blob/main/dist/ZYXEL-ES-COMMON#L31-L47

This means, that sysProductSerialNumber can not be resolved:

# @var SMIPATH : absolute path to senpro-it/mibs/dist
# ../../gosmi/gosmi -d -p $SMIPATH -m ZYXEL-ES-COMMON sysProductSerialNumber
Loaded module ZYXEL-ES-COMMON
Search path: /mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist:/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist
Loaded modules:
  <well-known> ()
  SNMPv2-SMI (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/SNMPv2-SMI)
  ZYXEL-ES-SMI (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/ZYXEL-ES-SMI)
  SNMPv2-TC (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/SNMPv2-TC)
  IANAifType-MIB (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/IANAifType-MIB)
  SNMPv2-MIB (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/SNMPv2-MIB)
  IF-MIB (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/IF-MIB)
  BRIDGE-MIB (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/BRIDGE-MIB)
  P-BRIDGE-MIB (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/P-BRIDGE-MIB)
  ZYXEL-ES-COMMON (/mnt/c/Users/ingwersenk.SENPRO/OneDrive - senpro.de/Documents/Code/mibs/dist/ZYXEL-ES-COMMON)
[{"Access":"ReadOnly","Decl":"ObjectType","Description":"The searial number of this device.","Kind":"Scalar","Name":"sysProductSerialNumber","Oid":null,"OidLen":0,"Status":"Current","Type":{"BaseType":"OctetString","Decl":"TextualConvention","Description":"Represents textual information taken from the NVT ASCII\ncharacter set, as defined in pages 4, 10-11 of RFC 854.\nTo summarize RFC 854, the NVT ASCII repertoire specifies:\n- the use of character codes 0-127 (decimal)\n- the graphics characters (32-126) are interpreted as\nUS ASCII\n- NUL, LF, CR, BEL, BS, HT, VT and FF have the special\nmeanings specified in RFC 854\n- the other 25 codes have no standard interpretation\n- the sequence 'CR LF' means newline\n- the sequence 'CR NUL' means carriage-return\n- an 'LF' not preceded by a 'CR' means moving to the\nsame column on the next line.\n- the sequence 'CR x' for any x other than LF or NUL is\nillegal.  (Note that this also means that a string may\nend with either 'CR LF' or 'CR NUL', but not with CR.)\nAny object defined using this syntax may not exceed 255\ncharacters in length.","Enum":null,"Format":"255a","Name":"DisplayString","Ranges":[{"BaseType":"Unsigned32","MinValue":0,"MaxValue":255}],"Reference":"","Status":"Current","Units":""},"SmiType":{"BaseType":"OctetString","Decl":"TextualConvention","Description":"Represents textual information taken from the NVT ASCII\ncharacter set, as defined in pages 4, 10-11 of RFC 854.\nTo summarize RFC 854, the NVT ASCII repertoire specifies:\n- the use of character codes 0-127 (decimal)\n- the graphics characters (32-126) are interpreted as\nUS ASCII\n- NUL, LF, CR, BEL, BS, HT, VT and FF have the special\nmeanings specified in RFC 854\n- the other 25 codes have no standard interpretation\n- the sequence 'CR LF' means newline\n- the sequence 'CR NUL' means carriage-return\n- an 'LF' not preceded by a 'CR' means moving to the\nsame column on the next line.\n- the sequence 'CR x' for any x other than LF or NUL is\nillegal.  (Note that this also means that a string may\nend with either 'CR LF' or 'CR NUL', but not with CR.)\nAny object defined using this syntax may not exceed 255\ncharacters in length.","Enum":null,"Format":"255a","Name":"DisplayString","Ranges":[{"BaseType":"Unsigned32","MinValue":0,"MaxValue":255}],"Reference":"","Status":"Current","Units":""}}]
# ../../gosmi/gosmi -p $SMIPATH -m ZYXEL-ES-COMMON sysProductSerialNumber | jq "."
[
  {
    "Access": "ReadOnly",
    "Decl": "ObjectType",
    "Description": "The searial number of this device.",
    "Kind": "Scalar",
    "Name": "sysProductSerialNumber",
    "Oid": null,
    "OidLen": 0,
    "Status": "Current",
    "Type": {
      "BaseType": "OctetString",
      "Decl": "TextualConvention",
      "Description": "Represents textual information taken from the NVT ASCII\ncharacter set, as defined in pages 4, 10-11 of RFC 854.\nTo summarize RFC 854, the NVT ASCII repertoire specifies:\n- the use of character codes 0-127 (decimal)\n- the graphics characters (32-126) are interpreted as\nUS ASCII\n- NUL, LF, CR, BEL, BS, HT, VT and FF have the special\nmeanings specified in RFC 854\n- the other 25 codes have no standard interpretation\n- the sequence 'CR LF' means newline\n- the sequence 'CR NUL' means carriage-return\n- an 'LF' not preceded by a 'CR' means moving to the\nsame column on the next line.\n- the sequence 'CR x' for any x other than LF or NUL is\nillegal.  (Note that this also means that a string may\nend with either 'CR LF' or 'CR NUL', but not with CR.)\nAny object defined using this syntax may not exceed 255\ncharacters in length.",
      "Enum": null,
      "Format": "255a",
      "Name": "DisplayString",
      "Ranges": [
        {
          "BaseType": "Unsigned32",
          "MinValue": 0,
          "MaxValue": 255
        }
      ],
      "Reference": "",
      "Status": "Current",
      "Units": ""
    },
    "SmiType": {
      "BaseType": "OctetString",
      "Decl": "TextualConvention",
      "Description": "Represents textual information taken from the NVT ASCII\ncharacter set, as defined in pages 4, 10-11 of RFC 854.\nTo summarize RFC 854, the NVT ASCII repertoire specifies:\n- the use of character codes 0-127 (decimal)\n- the graphics characters (32-126) are interpreted as\nUS ASCII\n- NUL, LF, CR, BEL, BS, HT, VT and FF have the special\nmeanings specified in RFC 854\n- the other 25 codes have no standard interpretation\n- the sequence 'CR LF' means newline\n- the sequence 'CR NUL' means carriage-return\n- an 'LF' not preceded by a 'CR' means moving to the\nsame column on the next line.\n- the sequence 'CR x' for any x other than LF or NUL is\nillegal.  (Note that this also means that a string may\nend with either 'CR LF' or 'CR NUL', but not with CR.)\nAny object defined using this syntax may not exceed 255\ncharacters in length.",
      "Enum": null,
      "Format": "255a",
      "Name": "DisplayString",
      "Ranges": [
        {
          "BaseType": "Unsigned32",
          "MinValue": 0,
          "MaxValue": 255
        }
      ],
      "Reference": "",
      "Status": "Current",
      "Units": ""
    }
  }
]

However, snmpget has no problem fetching it:

# @var $SNMPFLAGS : Authentication params
# snmpget $SNMPFLAGS -M $SMIPATH 10.100.0.242:161 ZYXEL-ES-COMMON::sysProductSerialNumber.0 -On
.1.3.6.1.4.1.890.1.15.3.1.12.0 = STRING: S232L25001215
# snmpget $SNMPFLAGS -M $SMIPATH 10.100.0.242:161 ZYXEL-ES-COMMON::sysProductSerialNumber.0
ZYXEL-ES-COMMON::sysProductSerialNumber.0 = STRING: S232L25001215

Could you look into that?

Thank you and kind regards!

Invalid text declaration

I'm trying to generate files with mib2go (v0.2.0). I think some types are dropped by the clause below, everything is fine if I comment it out.

if parentType.Decl == types.DeclTextualConvention {
// This is invalid
break
}

Here is an example of a field that is not found when loading the RMON2-MIB. LastCreateTime has TimeStamp as a parent type with a textual convention.

$ ./mib2go generate -d mibs -M /<redacted>/snmp-mibs RMON2-MIB
2020/09/11 11:23:33 [I] Setting path /<redacted>/snmp-mibs
2020/09/11 11:23:33 [E] Module RMON2-MIB: Type not found for node etherStatsCreateTime

RMON2-MIB (LAST-UPDATED "9605270000Z")

IMPORTS TEXTUAL-CONVENTION, RowStatus, DisplayString, TimeStamp FROM SNMPv2-TC
etherStatsCreateTime OBJECT-TYPE
    SYNTAX     LastCreateTime
    MAX-ACCESS read-only
    STATUS     current
    DESCRIPTION
        "The value of sysUpTime when this control entry was last
        activated. This can be used by the management station to
        ensure that the table has not been deleted and recreated
        between polls."
    ::= { etherStats2Entry 2 }


LastCreateTime ::= TEXTUAL-CONVENTION
    STATUS current
    DESCRIPTION
        "This TC describes an object that stores the last time its
        entry was created.

        This can be used for polling applications to determine that an
        entry has been deleted and re-created between polls, causing
        an otherwise undetectable discontinuity in the data."
    SYNTAX TimeStamp

SNMPv2-TC

TimeStamp ::= TEXTUAL-CONVENTION
    STATUS       current
    DESCRIPTION
            "The value of the sysUpTime object at which a specific
            occurrence happened.  The specific occurrence must be
            defined in the description of any object defined using this
            type."
    SYNTAX       TimeTicks

I have the same issues with LLDP-MIB (revision 200505060000Z): LLDP-MIB::lldpRemTimeMark -> RMON2-MIB::TimeFilter -> SNMPv2-SMI::TimeTicks.

These are very common MIBs so I'm probably doing something wrong. What am I missing?

syscall.Time_t undefined in GOOS==windows

Hello @sleepinggenius2 !!!

Thank you, for your big work!
I found a small incompatibility with windows OS:
the type syscall.Time_t is undefined under windows, can you type it as int64 (or more concrete type)?

Also, can you move structs types from model.go to another package?
It prevents a dependency from CGO if a program only wants to load produced JSON from the file.

Have a nice day!
@malexzx

How to get a node's OBJECTS?

I'm trying to use gosmi to parse/process all traps and their objects. But the node doesn't seem to hold this info.

linkDown NOTIFICATION-TYPE
    OBJECTS { ifIndex, ifAdminStatus, ifOperStatus }
    STATUS  current
    DESCRIPTION
            "A linkDown trap signifies that the SNMP entity, acting in
            an agent role, has detected that the ifOperStatus object for
            one of its communication links is about to enter the down
            state from some other state (but not from the notPresent
            state).  This other state is indicated by the included value
            of ifOperStatus."
    ::= { snmpTraps 3 }

Results in this json:

{
	"Access": "Unknown",
	"Decl": "NotificationType",
	"Description": "A linkDown trap signifies that the SNMP entity, acting in\nan agent role, has detected that the ifOperStatus object for\none of its communication links is about to enter the down\nstate from some other state (but not from the notPresent\nstate).  This other state is indicated by the included value\nof ifOperStatus.",
	"Kind": "Notification",
	"Name": "linkDown",
	"Oid": [1,3,6,1,6,3,1,1,5,3],
	"OidLen": 10,
	"Status": "Current",
	"Type": null,
	"SmiType": null
}

How would it be possible to get the OBJECTS?

Exception thrown if MIB file contains more than two modules in the same file

JUNIPER-WX-MIB.zip
Hi there,

You've written such a wonderful app which saves me a lot of time if I have to do it by my own. Everything works like a charm except two following issues.

One is it throws an exception of "unexpected token" if the MIB file contains more than one module.
I tried to load module with both gosmi.LoadModule() and parser.ParseFile() functions but it returns the same exception. I'm wondering if we can have any work around to fix this issue? Attached is the MIB file I'm talking about.

The other one is it it failed to load module if the MIB file defines the default value is DEFVAL { { } } with the error "branch ()? was accepted but did not progress the lexer".

I look forward to hearing from you soon.
Kind regards,
Tam Pham

Is it Windows compatible?

Getting "panic: Body: Identity: Oid: SubIdentifiers: can not parse into empty struct parser.SubIdentifier" when running example from cmd/parse.

smi.GetParentNode() seems to always return the Node and not the Parent

Hi,
I'm using smi.GetParentNode() and it always seems to return the same node that I pass it as a parameter instead of that node's parent.

e.g. The following code

node, _ := gosmi.GetNodeByOID(oid)
log.Printf("node name: %s::%s of %s", GetModule().Name, node.Name, node.Kind)
parent := gosmi.CreateNode(smi.GetParentNode(node.GetRaw()))
log.Printf("parent name: %s::%s of %s", parent.GetModule().Name, parent.Name, parent.Kind)

produces the output

bug 2021/03/20 13:08:47 node name: IF-MIB::ifPhysAddress of Scalar
bug 2021/03/20 13:08:47 parent name: IF-MIB::ifPhysAddress of Scalar

when I'm expecting it to produce the output

bug 2021/03/20 13:08:47 node name: IF-MIB::ifPhysAddress of Scalar
bug 2021/03/20 13:08:47 parent name: IF-MIB::ifEntry of Column

I couldn't help but notice that the smi.GetParentNode() function searches for the given node a lot, but never actually dereferences the Parent field. That's probably the problem. Those data structures are sufficiently complicated that I can't work out what the correct fix is. (Any data structure in any programming language that handles ASN.1 source seems to be complicated).

Cheers

MIB parser breaks on unexpected whitespace

I encountered over a dozen Cisco MIB files that this parser fails to parse. (All Cisco MIBs can be downloaded in a zip file from their site, but I will include some examples in this post.)

Note: I had been using a slightly older version of gosmi, so I just updated to v0.4.2, but it still has the same issues.

Example 1:
CISCO-AAA-SERVER-MIB has some tabs in unexpected places, and the tab between "OBJECT" and "IDENTIFIER" breaks the parser (replace all instances of that tab with a space, and it parses successfully):

cAAAServerMIBObjects\t OBJECT\tIDENTIFIER ::= { ciscoAAAServerMIB 1 }

Example 2:
DS3-MIB has some line-feeds in unexpected places, and they break the parser (clean up the line-feeds, and it parses successfully):

             ds3Conformance OBJECT IDENTIFIER ::= { ds3 14 }

             ds3Groups      OBJECT IDENTIFIER ::= {
             ds3Conformance 1 } ds3Compliances OBJECT
             IDENTIFIER ::= { ds3Conformance 2 }

It's been a while (1991) since I've had to write my own parser/compiler, but unless the language definition prohibits it, the parser is supposed to be able to handle unusual whitespace like this.

Thanks in advance,
Sean

CISCO-AAA-SERVER-MIB.txt
DS3-MIB.txt

gosmi Load modules not loading mib files properly and giving oid's as blank

I have been trying to use gosmi for parsing mib's in my code. I have few mib's with me from which 2 mib's are parsing properly and giving proper parsed modules with all the data. but there are few mib's which are getting loaded without any error but when I try to print the nodes from loded module, i see oid's are coming as blank. it is a valid mib but still failing to get parsed in gosmi.
below is the code as well as output :
`package main

import (
"fmt"
"os"
"path/filepath"

"github.com/sleepinggenius2/gosmi"

)

func main() {

var folder string = "/root/testgosmi/mibs"
// Initialize the parser
gosmi.Init()
gosmi.SetPath(folder)
var files []string

err := filepath.Walk(folder, func(path string, info os.FileInfo, err error) error {
	if info.IsDir() {
		return nil
	}
	files = append(files, path)
	return nil
})
if err != nil {
	fmt.Println(err)
}

for _, file := range files {
	filename := filepath.Base(file)
	modulename, err := gosmi.LoadModule(filename)
	if err != nil {
		fmt.Printf("Failed to load MIB module: %v\n", err)
		return
	}
	fmt.Println(modulename)
}

loadedModules := gosmi.GetLoadedModules()
fmt.Println("Loaded modules:")
for _, loadedModule := range loadedModules {
	fmt.Println(loadedModule.Name, loadedModule.Path)
	nodes := loadedModule.GetNodes()
	for _, node := range nodes {
		fmt.Println(node.Name)
		fmt.Println(node.Oid)
	}
}

}
`

output for a successfully parsed mib:
Loaded modules: <well-known> TRIMBLE-MIB /root/testgosmi/mibs/TRIMBLE-MIB.mib trimble 1.3.6.1.4.1.46285 trimbleTiming 1.3.6.1.4.1.46285.1 trimbleTBlt 1.3.6.1.4.1.46285.1.1

output for mib which is giving error:
`TRAP-MIB /root/dummytrap/mibs/test.mib
Traps

MIBNotifObjects

TrapTimeStamp

TrapSeverity

TrapFunctionalArea

`

if you see in above output only node names are getting printed and oid's are coming as blank. so I want able to use GetNodeByOID function in order to fetch node data from above parsed mib.
It would be helpful to know if there is anything i am doing wrong. I tried to parse the same mib using Parser and it works for both mib files but as it dosent have GetNodeByOID i wanted to continue with smi parser.

resolve OIDs with indexes

Hi,

I'm trying to resolve OIDs that are table rows with multiple indexes but I can't figure out how to do that with gosmi.
I attempted to write my own function that calls GetNodeByOID, find the corresponding parent table, then its indexes with GetIndex, and resolve the OID suffixes from those but it seems suboptimal. Did I miss something? is there a better/native way to do that?
I expected something returning a SmiNode and a list or a map of indexes as SmiNode and their associated values.

Also, I can't seem to find how to access the parsed SYNTAX of a node, especially the DisplayString which is mandatory to know how to decode the oid suffix, for example in MPLS-MIB::mplsLspInfoState which used MPLS-MIB::mplsLspInfoName as index (a DisplayString (SIZE (1..64)))

Any hint would be appreciated

OSIX mib only partially loaded

Hi, I have a mib loading problem again:

package main

import (
	"log"

	"github.com/sleepinggenius2/gosmi"
	"github.com/sleepinggenius2/gosmi/types"
)

func main() {
	gosmi.Init()
	gosmi.SetPath("../../mibs")
	//_, _ = gosmi.LoadModule("OSIX-MIB")
	//_, _ = gosmi.LoadModule("OSIX-XSENSE-MIB")
	module, _ := gosmi.LoadModule("OSIX-XSENSE-MIB-TRAPS")
	m, _ := gosmi.GetModule(module)
	trapNodes := m.GetNodes(types.NodeNotification)
	for _, node := range trapNodes {
		log.Printf("Trap %s::%s [%s]\n%+v\n", module, node.Name, node.Oid, node.GetRaw())
	}
}

Running this only shows the first trap node:

2022/02/21 14:55:48 Trap OSIX-XSENSE-MIB-TRAPS::physicalStateChange [1.3.6.1.4.1.10034.0.1000]
&{Name:physicalStateChange OidLen:9 Oid:1.3.6.1.4.1.10034.0.1000 Decl:TrapType Access:Unknown Status:Unknown Format: Value:{BaseType:Unknown Len:0 Value:<nil>} Units: Description:Signifies that a state change has occurred in the 
            physical layer. The new state is indicated by xvarEventType. Reference: IndexKind:Unknown Implied:false Create:false NodeKind:Notification}

Also tried with the commented lines, but that didn't improve anything. Do you have a clue?
These are the mibs: osix-mibs.zip

Can't parse CISCO-STACK-MIB::sysErrDisableTimeoutEnable DEFVAL

The error is:

CISCO-STACK-MIB:1730:20: branch (<ident>)? was accepted but did not progress the lexer at .../CISCO-STACK-MIB:1730:20

The part that fails is: DEFVAL { { } }

The syntax of the object is BITS which means that the expected default is no bit set

testing the sample main.go file under cmd/smi example but facing Null oid error

When we try to test out the example go code to load a module from mib and inspect the nodes, we only null being shown as the oid for the nodes. Tried with sample mibs in this repo as well as some standard mibs. Can you point if there is any issue in the way the go code is executed ?

go run main.go -d -m FIZBIN-MIB -p .
Loaded module FIZBIN-MIB
Search path: /home/cloud-user/kaushik/workspace/gosmi
Loaded modules:
()
FIZBIN-MIB (/home/cloud-user/kaushik/workspace/gosmi/FIZBIN-MIB.mib)
{"Module":{"ContactInfo":"Marshall T. Rose\n\t Postal: Dover Beach Consulting, Inc.\n\t 420 Whisman Court\n\t Mountain View, CA 94043-2186\n\t US\n\t Tel: +1 415 968 1052\n\t Fax: +1 415 968 2510\n\t E-mail: [email protected]","Description":"The MIB module for entities implementing the xxxx\n\t protocol.","Language":"SMIv2","Name":"FIZBIN-MIB","Organization":"IETF SNMPv2 Working Group","Path":"/home/cloud-user/kaushik/workspace/gosmi/FIZBIN-MIB.mib","Reference":""},"Nodes":[{"Access":"Unknown","Decl":"ValueAssignment","Description":"","Kind":"Node","Name":"entityMIBTrapPrefix","Oid":null,"OidLen":0,"Status":"Unknown","Type":null,"SmiType":null},{"Access":"Unknown","Decl":"NotificationType","Description":"An entConfigChange trap is sent when the value of\nentLastChangeTime changes. It can be utilized by an NMS to\ntrigger logical/physical entity table maintenance polls.\nAn agent must not generate more than one entConfigChange\n'trap-event' in a five second period, where a 'trap-event'\nis the transmission of a single trap PDU to a list of\ntrap destinations. If additional configuration changes\noccur within the five second 'throttling' period, then\nthese trap-events should be suppressed by the agent. An\nNMS should periodically check the value of\nentLastChangeTime to detect any missed entConfigChange\ntrap-events, e.g. due to throttling or transmission loss.","Kind":"Notification","Name":"entConfigChange","Oid":null,"OidLen":0,"Status":"Current","Type":null,"SmiType":null}],"Types":[{"BaseType":"OctetString","Decl":"TextualConvention","Description":"Represents media- or physical-level addresses.","Enum":null,"Format":"1x:","Name":"PhysAddress","Ranges":[],"Reference":"","Status":"Current","Units":""}]}[root@vm-10-75-112-164 gosmi]#
[root@vm-10-75-112-164 gosmi]#
[root@vm-10-75-112-164 gosmi]#

-p -> pointing to directory where the mib file is placed
-m -> FIZBIN-MIB is the module name of the sample mib present in this repo.

why is the oid is null and length shown as 0 ?

I am getting out of memory while parsing the Mib and the error is as follows,runtime: VirtualAlloc of 173408256 bytes failed with errno=1455

hi ,
I am getting out of memory while parsing the Mib and the error is as follows

INSPUR_EXT_MIB_1.0.0.zip

         gosmi.Init()
	gosmi.AppendPath("E:\\dev\\go\\gosmi-0.4.4\\mibs")
	module, _ := gosmi.LoadModule("INSPUR_EXT_MIB_1.0.0.MIB")
	m, _ := gosmi.GetModule(module)
	trapNodes := m.GetNodes()
	for _, node := range trapNodes {
	     fmt.Println(fmt.Sprintf("Trap %s::%s [%s]\n%+v\n", module, node.Name, node.Oid, node.GetRaw()))
          }

runtime: VirtualAlloc of 173408256 bytes failed with errno=1455
fatal error: out of memory

runtime stack:
runtime.throw(0x3e8505, 0xd)
D:/Go/src/runtime/panic.go:1117 +0x79
runtime.sysUsed(0xc01ea58000, 0xa560000)
D:/Go/src/runtime/mem_windows.go:83 +0x22e
runtime.(*mheap).allocSpan(0x4e1d40, 0x52b0, 0x0, 0x1d14fdcc5c8)
D:/Go/src/runtime/mheap.go:1271 +0x3b1
runtime.(*mheap).alloc.func1()
D:/Go/src/runtime/mheap.go:910 +0x5f
runtime.systemstack(0x0)
D:/Go/src/runtime/asm_amd64.s:379 +0x6b
runtime.mstart()
D:/Go/src/runtime/proc.go:1246

goroutine 1 [running]:
runtime.systemstack_switch()
D:/Go/src/runtime/asm_amd64.s:339 fp=0xc0005119f8 sp=0xc0005119f0 pc=0x2e5c40
runtime.(*mheap).alloc(0x4e1d40, 0x52b0, 0x100, 0xc000511a98)
D:/Go/src/runtime/mheap.go:904 +0x88 fp=0xc000511a48 sp=0xc0005119f8 pc=0x2a7648
runtime.(*mcache).allocLarge(0x1d128a20598, 0xa560000, 0xc000120001, 0x2)
D:/Go/src/runtime/mcache.go:224 +0x9e fp=0xc000511aa0 sp=0xc000511a48 pc=0x2978fe
runtime.mallocgc(0xa560000, 0x3dec20, 0x1, 0xc00000cc60)
D:/Go/src/runtime/malloc.go:1078 +0x965 fp=0xc000511b28 sp=0xc000511aa0 pc=0x28e0c5
runtime.growslice(0x3dec20, 0xc01660c000, 0x11a3bb, 0x11a3bb, 0x11a3bc, 0x2, 0xc00035f2b0, 0xe)
D:/Go/src/runtime/slice.go:230 +0x209 fp=0xc000511b90 sp=0xc000511b28 pc=0x2ca9a9
github.com/sleepinggenius2/gosmi.SmiModule.GetNodes(0x0, 0x0, 0x0, 0x0, 0x1, 0xc0001c5ec0, 0xe, 0x0, 0x0, 0xc000016c80, ...)
E:/dev/go/gosmi-0.4.4/module.go:45 +0x20b fp=0xc0
00511cc0 sp=0xc000511b90 pc=0x3a32ab
main.main()
E:/dev/go/gosmi-0.4.4/cmd/test/main.go:25 +0x246 fp=0xc000511f88 sp=0xc000511cc0 pc=0x3a4606
runtime.main()
D:/Go/src/runtime/proc.go:225 +0x256 fp=0xc000511fe0 sp=0xc000511f88 pc=0x2b9ff6
runtime.goexit()
D:/Go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc000511fe8 sp=0xc000511fe0 pc=0x2e7ae1

smi.GetNode returns Kind: NodeScalar instead of NodeColumn for a table's subtree

I'm parsing a MIB for a networking device and the table columns are reporting back as Kind: Scalar instead of Column.
I'm not sure if the MIB is bad, or I am misusing the library, so any input is greatly appreciated.

Here's some relevant information about my setup:
Go version: 1.16.3
gosmi version: 0.4.3

Here's a gist of how I'm getting the nodes:
https://gist.github.com/Metalgrid/3e9f95d2ae19009075db9a10de20ae5d

and the MIB files in question (it has a bunch of imports so I've included all of them)
mibs.zip

Just to clarify, everything works properly if I look at a standard table, e.g. ifXTable works properly, but the one that I'm interested in tmnxSubMgmtGpIfStatsTable returns all Scalar values.

P.S. Thank you for the amazing library! :)

Relaxed mode for parsing invalid MIBs

Librenms got a decent collection of MIBs from various vendors, some more broken than others.

It might be of interest to add a "relaxed mode" for common problems, such as the ones with invalid dates: unexpected "201506080000A" (expected <extutctime> ...)

$ git clone https://github.com/librenms/librenms.git /tmp/librenms
$ find /tmp/librenms/mibs/ -type f | xargs -P0 -n1 ./parse 1>/dev/null
2022/06/03 16:22:32 Parse file: /tmp/librenms/mibs/SNMPv2-TC-v1:121:1: unexpected token "SNMPv2-CONF-v1"
2022/06/03 16:22:33 Parse file: /tmp/librenms/mibs/allied/AT-DOS-MIB:72:11: unexpected "/" (expected "(" ...)
2022/06/03 16:22:35 Parse file: /tmp/librenms/mibs/eltek/VALERE-DC-POWER-MIB:2460:30: unexpected "bdtAlarmPresent" (expected "}")
2022/06/03 16:22:37 Parse file: /tmp/librenms/mibs/cisco/CISCOSB-PBR-MIB:13:22: unexpected "201506080000A" (expected <extutctime> ...)
2022/06/03 16:22:39 Parse file: /tmp/librenms/mibs/cisco/CISCOSB-ROUTEMAP-MIB:12:22: unexpected "201506080000A" (expected <extutctime> ...)
2022/06/03 16:22:39 Parse file: /tmp/librenms/mibs/imco/IMCO-BIG-MIB:12202:2: unexpected "aSupply1UnitAny" (expected "}")
2022/06/03 16:22:40 Parse file: /tmp/librenms/mibs/cisco/CISCOSB-SYSMNG-MIB:16:22: unexpected "201010310000a" (expected <extutctime> ...)
2022/06/03 16:22:43 Parse file: /tmp/librenms/mibs/endrun/TEMPUSLXUNISON-MIB:285:7: unexpected "1" (expected "}")
2022/06/03 16:22:43 Parse file: /tmp/librenms/mibs/aerohive/AH_TRAP_MIB:37:21: unexpected "8021" (expected "}")
2022/06/03 16:22:44 Parse file: /tmp/librenms/mibs/riedo/NETTRACK-E3METER-CTR-SNMP-MIB:466:3: unexpected "1" (expected "}")
2022/06/03 16:22:44 Parse file: /tmp/librenms/mibs/terra/TERRA-PRODUCTS-MIB:18:9: unexpected "REVISION" (expected <assign> ...)
2022/06/03 16:22:44 Parse file: /tmp/librenms/mibs/ekinops/EKINOPS-MGNT2-NMS-MIB:357:4: unexpected "undefinedError" (expected "}")
2022/06/03 16:22:44 Parse file: /tmp/librenms/mibs/terra/TERRA-DEFINITIONS-MIB:20:9: unexpected "REVISION" (expected <assign> ...)
2022/06/03 16:22:44 Parse file: /tmp/librenms/mibs/transition/TN-OTDR-MIB:690:13: unexpected "1" (expected <ident>)
2022/06/03 16:22:45 Parse file: /tmp/librenms/mibs/transition/TN-LLDP-EXT-MIB:23:21: unexpected "2013030251930Z" (expected <extutctime> ...)
2022/06/03 16:22:47 Parse file: /tmp/librenms/mibs/juniper/JUNIPER-WX-MIB:241:1: unexpected token "JUNIPER-WX-GLOBAL-TC"
2022/06/03 16:22:49 Parse file: /tmp/librenms/mibs/riello/RIELLOMDU-MIB:216:109: unexpected "Imminent" (expected <assign> ...)
2022/06/03 16:22:49 Parse file: /tmp/librenms/mibs/poweralert/TRIPPLITE-12X:45:5: unexpected "Corrected spelling errors" (expected "DESCRIPTION" ...)
2022/06/03 16:22:51 Parse file: /tmp/librenms/mibs/eds/EDS-MIB:1352:23: unexpected "," (expected (<octetstring> | <objectidentifier> | <ident>) ...)
2022/06/03 16:22:57 Parse file: /tmp/librenms/mibs/hp/HP-SN-MIBS:74:1: unexpected token "HP-SN-AGENT-MIB"
2022/06/03 16:23:07 Parse file: /tmp/librenms/mibs/linksys/LINKSYS-SYSMNG-MIB:16:22: unexpected "201010310000a" (expected <extutctime> ...)
2022/06/03 16:23:08 Parse file: /tmp/librenms/mibs/linksys/LINKSYS-MODEL-MIB:3554:1: no match found for
2022/06/03 16:23:10 Parse file: /tmp/librenms/mibs/fs/GBNPlatformOAM-MIB:954:16: unexpected "10" (expected "}")
2022/06/03 16:23:16 Parse file: /tmp/librenms/mibs/dragonwave/HORIZON-ODU-MIB:204:7: unexpected "hc40-57-qpsk" (expected "}")
2022/06/03 16:23:18 Parse file: /tmp/librenms/mibs/delta/DeltaUPS-MIB:205:12: unexpected "3" (expected "}")
2022/06/03 16:23:18 Parse file: /tmp/librenms/mibs/fs/FS-MIB:18630:78: unexpected "cpemac" (expected "}")
2022/06/03 16:23:21 Parse file: /tmp/librenms/mibs/zyxel/ZYXEL-NWA-SERIES_v1-4-2:104:4: unexpected "success" (expected "}")
2022/06/03 16:23:23 Parse file: /tmp/librenms/mibs/tplink/TPLINK-SYSINFO-MIB:115:16: unexpected "{" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:23 Parse file: /tmp/librenms/mibs/proware/proware-SNMP-MIB:94:17: unexpected "{" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:23 Parse file: /tmp/librenms/mibs/zyxel/ZYXEL-GS4012F-MIB:7529:22: unexpected "mandatory" (expected ("current" | "deprecated" | "obsolete") ...)
2022/06/03 16:23:23 Parse file: /tmp/librenms/mibs/edgecos/ECS4100-52T-MIB:10879:4: unexpected "radiusServerType" (expected "}")
2022/06/03 16:23:23 Parse file: /tmp/librenms/mibs/ibm/IBM-NetFinity-Text-Alert-MIB:132:1: no match found for
2022/06/03 16:23:25 Parse file: /tmp/librenms/mibs/ibm/IBMIROCAUTH-MIB:426:19: no match found for .
2022/06/03 16:23:28 Parse file: /tmp/librenms/mibs/zyxel/IES5206-MIB:10374:17: unexpected "{" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:33 Parse file: /tmp/librenms/mibs/arris/d5/ARRIS-D5-SLOT-EXT-MIB:50:34: unexpected "(" (expected "END")
2022/06/03 16:23:37 Parse file: /tmp/librenms/mibs/perle/PERLE-IOLAN-SDS-MIB:657:6: unexpected "Description" (expected <assign> ...)
2022/06/03 16:23:38 Parse file: /tmp/librenms/mibs/junos/JUNIPER-WX-MIB:241:1: unexpected token "JUNIPER-WX-GLOBAL-TC"
2022/06/03 16:23:41 Parse file: /tmp/librenms/mibs/dlink/DLINKSW-NETWORK-ACCESS-MIB:487:44: unexpected "xffffffff" (expected ")")
2022/06/03 16:23:42 Parse file: /tmp/librenms/mibs/teldat/TELDAT-MON-INTERF-WLAN-MIB:42:10: unexpected "mandatory" (expected ("current" | "deprecated" | "obsolete") ...)
2022/06/03 16:23:43 Parse file: /tmp/librenms/mibs/dell/DELLEMC-OS10-CHASSIS-MIB:137:13: unexpected "os10ChassisProductBase" (expected "}")
2022/06/03 16:23:44 Parse file: /tmp/librenms/mibs/bdcom/NMS-CARD-SYS-MIB:70:23: unexpected "`" (expected (<octetstring> | <objectidentifier> | <ident>) ...)
2022/06/03 16:23:44 Parse file: /tmp/librenms/mibs/bdcom/NMS-CHASSIS:822:25: unexpected "TLB-modification-exception" (expected "}")
2022/06/03 16:23:45 Parse file: /tmp/librenms/mibs/cambium/800/CAMBIUM-PTP800-MIB:34:70: no match found for .
2022/06/03 16:23:45 Parse file: /tmp/librenms/mibs/calix/E7-TC:348:9: unexpected "ontAutoQuarantine" (expected "}")
2022/06/03 16:23:46 Parse file: /tmp/librenms/mibs/calix/E7-Calix-MIB:28:5: unexpected "E7OperStatus" (expected "FROM" ...)
2022/06/03 16:23:47 Parse file: /tmp/librenms/mibs/fortinet/FORTINET-FORTIGATE-MIB:9462:33: unexpected "1" (expected "}")
2022/06/03 16:23:48 Parse file: /tmp/librenms/mibs/brocade/FOUNDRY-SN-ROUTER-TRAP-MIB:439:1: no match found for
2022/06/03 16:23:48 Parse file: /tmp/librenms/mibs/calix/E5-120-MIB:7822:18: unexpected "{" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:49 Parse file: /tmp/librenms/mibs/calix/E5-121-MIB:7932:18: unexpected "{" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:50 Parse file: /tmp/librenms/mibs/screenos/NETSCREEN-TRAP-MIB:189:9: unexpected "low-memory" (expected "}")
2022/06/03 16:23:51 Parse file: /tmp/librenms/mibs/junose/broken/Juniper-Accounting-CONF:250:13: unexpected "DESCRIPTION" (expected <assign> ...)
2022/06/03 16:23:51 Parse file: /tmp/librenms/mibs/junose/broken/Juniper-ATM-1483-Profile-CONF:101:13: unexpected "juniAtm1483ProfileGroup4" (expected "STATUS" ...)
2022/06/03 16:23:51 Parse file: /tmp/librenms/mibs/junose/broken/Juniper-Internet-CONF:1593:18: unexpected "INCLUDES" (expected "{" ...)
2022/06/03 16:23:52 Parse file: /tmp/librenms/mibs/junose/JUNIPER-WX-MIB:241:1: unexpected token "JUNIPER-WX-GLOBAL-TC"
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-SYSTEM-ACCESS-MIB:528:6: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-SYSLOG-MIB:339:14: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-MPLS-RSVP-MIB:308:6: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-CPU-MAC-FILTER:195:14: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBIQUOSS-EPON-SERVICE-POLICY-GROUP-MIB:354:16: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-CFM-MIB:2551:9: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-OSPF-MIB:332:6: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-QOS-MIB:166:7: unexpected "(" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBIQUOSS-EPON-SOFTWARE-MANAGEMENT-GROUP-MIB:580:16: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-MPLS-MIB:667:6: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-INTERFACE-MIB:1092:4: unexpected "(" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-ARP-MIB:248:4: unexpected "(" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBIQUOSS-EPON-PON-MAC-GROUP-MIB:3155:16: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBIQUOSS-EPON-ONTMANAGER-GROUP-MIB:178:5: unexpected "(" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBIQUOSS-EPON-PM-MIB:487:9: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBIQUOSS-EPON-MIB:1286:9: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-ERPS-MIB:795:21: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-MPLS-PW-MIB:655:6: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-AUTO-RESET-MIB:505:14: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-ENTITY-ALARM-MIB:287:22: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-REDUNDANCY-MIB:697:22: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBIQUOSS-EPON-PON-PROFILE-GROUP-MIB:3812:16: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-SLD-MIB:314:9: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:53 Parse file: /tmp/librenms/mibs/ubiquoss/UBIQUOSS-EPON-PM-GROUP-MIB:3038:16: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:54 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-DOT1BRIDGE-MIB:200:24: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:54 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-NTP-MIB:196:21: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:54 Parse file: /tmp/librenms/mibs/ubiquoss/UBQS-ACCESS-LIST-MIB:259:4: unexpected "(" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:54 Parse file: /tmp/librenms/mibs/extreme/Brocade-TC:89:1: unexpected token "BROCADE-PRODUCTS-MIB"
2022/06/03 16:23:55 Parse file: /tmp/librenms/mibs/dasan/SLE-ISIS-MIB:29:4: unexpected "REVISION" (expected <assign> ...)
2022/06/03 16:23:56 Parse file: /tmp/librenms/mibs/dasan/DASAN-SWITCH-MIB:3511:5: unexpected "{" (expected ("ACCESS" | "MAX-ACCESS") ...)
2022/06/03 16:23:56 Parse file: /tmp/librenms/mibs/dasan/DASAN-NOTIFICATION:1216:13: unexpected "}" (expected <ident> ...)
2022/06/03 16:23:56 Parse file: /tmp/librenms/mibs/extreme/EXTREME-BASE-MIB:356:1: unexpected token "EXTREME-SYSTEM-MIB"
2022/06/03 16:23:57 Parse file: /tmp/librenms/mibs/dasan/SLE-VRRP-MIB:29:4: unexpected "REVISION" (expected <assign> ...)
2022/06/03 16:23:59 Parse file: /tmp/librenms/mibs/dasan/SLE-EPON-MIB:31:17: unexpected "" (expected <extutctime> ...)
2022/06/03 16:24:00 Parse file: /tmp/librenms/mibs/huawei/HUAWEI-SLOG-EUDM-MIB:113:19: unexpected "0" (expected "}")
2022/06/03 16:24:00 Parse file: /tmp/librenms/mibs/huawei/HUAWEI-MGMD-STD-MIB:747:5: unexpected "?" (expected "}")
2022/06/03 16:24:05 Parse file: /tmp/librenms/mibs/himoinsa/DISMUNTELv00-MIB:1294:1: unexpected token "cj"
2022/06/03 16:24:08 Parse file: /tmp/librenms/mibs/4rf/4RF-COMMON-TC:22:5: unexpected "Integer32" (expected "FROM" ...)
2022/06/03 16:24:08 Parse file: /tmp/librenms/mibs/4rf/4RF-APRISAXE-TC:111:45: unexpected "'E0'H" (expected <int>)

how to find node with OID?

hi,
I'm trying to get a node by its OID.
A mib file is passed in and the module is loaded fine. It returns the json object that contains the loaded module and nodes. It works if I get the node by name (i.e., call GetNode()), but GetNodeByOID() always fails.
For example, with OID 1.3.6.1.4.1.5655.1.3, it failed after traverse to the second number - 3.
How should I use GetNodeByOID() ? Thanks

Issue reading Dell/EMC MIB files

Good day. First off, let me just say THANK YOU. This module is amazing and is helping out immensely with a project that I am working on. I have thrown a couple of MIBs at the library and it has worked exactly as I would expect. However I have come across a vendor whos MIBS do not seem to work. I have validated the MIBs with "snmptranslate" and they do work, but gosmi is not able to get the same data out of them.

An example MIB can be found here: http://doc.isilon.com/ECS/3.1/AdminGuide/ecs_r_snmp_oids_and_definition_of_enterprise_mib_ecs_mib.html
Interestingly I have tried multiple MIBs from this vendor and they all seem to exhibit the same problem.

If I use snmptranslate I get valid data back for a lookup of OIDs. For example ".1.3.6.1.4.1.1139.102.1.1", however if I use the example code cmd/smi the only thing I get is the very beginning of the tree "1,3,6,1,4,1,1139" and it stops there. Given that other vendors MIBS are working just fine, I am guessing there is something different/special about this EMC one.

Any thoughts on what might be going on, or how to approach trying to figure it out. I am still a Go novice but willing to help and learn.

MIB files not getting parsed completely

Hi, I am trying to load a mib file and try parsing it and print the type of the node using SmiNode.Type field. But every time the type is <nil> when trying to print it. Note: The SmiNode is not nil but SmiNode.Type is <nil> here. I am not getting the issue here. Is something to do with the way I am loading the mib files or it is to do with the mib itself?

I am trying to load the modules as below:

func initGosmi() {
	MibFilesPath := "C:\\Users\\sn\\Downloads\\mibs"
	Modules := "COMMON-DEFINITION,ALARM-IRP,SNMPv2-CONF,SNMPv2-SMI,SNMPv2-TC"

	var mibFiles []string = strings.Split(MibFilesPath, ",")
	var modules []string = strings.Split(Modules, ",")
	gosmi.Init()
	for _, path := range mibFiles {
		gosmi.AppendPath(path)
	}

	for _, module := range modules {
		_, err := gosmi.LoadModule(module)
		if err != nil {
			fmt.Printf("Init Error: %s\n", err)
		}
	}
}

Below is the definition of the node from the mib file:

From ALARM-IRP.mib file

        nAlarmEntry OBJECT-TYPE
        SYNTAX       NAlarmEntry
        MAX-ACCESS   not-accessible
        STATUS       current
        DESCRIPTION
                "One entry in the alarm table holds one active alarm."
        INDEX { nAlarmId }
        ::= { nAlarmTable 1 }

	NAlarmEntry ::= SEQUENCE {
	                 nAlarmId                  NAlarmId,
	                 nAlarmText                NAlarmText
        }

	nAlarmText OBJECT-TYPE
	        SYNTAX      NAlarmText
	        MAX-ACCESS  read-only
	        STATUS      current
	        DESCRIPTION
	                 "This object represents the alarm text and contains
	                  basic information on the fault"
	::= { nAlarmEntry 5 }


 From COMMON-DEFINITION.mib file

	NAlarmText ::= TEXTUAL-CONVENTION
	        DISPLAY-HINT "3072t"
	        STATUS current
	        DESCRIPTION
	                "Alarm text contains information on the fault situation 
	                in the NE in human readable format"
	        SYNTAX OCTET STRING (SIZE (0..3072))

Panic with SYNOLOGY-DISK-MIB::diskTable

I have written go code to try and load in and use SYNOLOGY-DISK-MIB::diskTable but it panics. I have attached the go program and the zip of the mibs. Any help is greatly appreciated.

From what I can tell I call gosmi.GetNode, GetNode calls smi.GetNode(smiModule, name), in GetNode smiModulePtr is empty and skips down the the for loop doesn't find anything, returns nil and panics.

synology.txt -> the go program (github made me upload it as a txt)

Synology_MIB_File.zip -> the mibs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.