Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Module: Unexpected #23

Closed
MyaLongmire opened this issue Jun 7, 2021 · 5 comments
Closed

Parse Module: Unexpected #23

MyaLongmire opened this issue Jun 7, 2021 · 5 comments

Comments

@MyaLongmire
Copy link

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.

@sleepinggenius2
Copy link
Owner

Given the referenced paths, I'm assuming that those are globally installed MIBs, potentially from a package like snmp-mibs-downloader. Those are typically ripped directly from the corresponding RFCs and are often error prone. The path on my system is /var/lib/snmp/mibs/ietf, but I'm assuming the files are the same. SNMPv2-PDU is an ASN.1 module defining the structure of SNMP PDUs, not a MIB, and will therefore fail parsing as such. You can just delete it if it's causing you issues, as it will never be imported by another module. The others I have confirmed contain the exactly syntax errors you are seeing. DPI20-MIB is missing a semicolon (;) at the end of the import statement on line 7. HPR-MIB has a wrapping issue on line 493 where "delay" should be included in the comment on the line above or start a new comment. TCPIPX-MIB is missing a comma (,) after IpxAddress on line 62.

@MyaLongmire
Copy link
Author

MyaLongmire commented Jun 7, 2021

Thank you so much for your quick reply! The path I am passing is /usr/share/snmp/mibs but the error is saying a different path. I checked and they are in both places. I have not touched the files so did they come with those errors? Is it common for mibs to come with errors? Sorry for all the questions I am new to this and trying to figure it out.

@sleepinggenius2
Copy link
Owner

Yes, the ones that get installed from packages are typically ripped directly from the RFCs and some contain errors. Depending on your application, I would typically suggest starting by loading only the MIBs that have the OIDs that you are specifically looking to target, as the library will automatically load the necessary imports, if provided with an appropriate path. Almost all of the ones that I've found which include errors are rarely used in practice and should not pose a problem for most applications.

@Hipska
Copy link

Hipska commented Dec 17, 2021

@sleepinggenius2 for Telegraf, that's not quite possible since users are allowed to provide a raw OID and telegraf then tries to get the translation of it. So users provide a path and gosmi loads all mibs in that path.

@elad-bar
Copy link

elad-bar commented Dec 17, 2021

if that's assist to understand the issue, also happens to me,
Configuration:

##
## EdgeRouter devices
##
[[inputs.snmp]]
   # List of agents to poll
   agents = [ "IPORHOST" ]
   # Polling interval
   interval = "60s"
   # Timeout for each SNMP query.
   timeout = "5s"
   # Number of retries to attempt within timeout.
   retries = 3
   # SNMP version, values can be 1, 2, or 3
   version = 2
   # SNMP community string.
   community = "public"
   # The GETBULK max-repetitions parameter
   max_repetitions = 50
   # Measurement name
   name = "NAME"
   ##
   ## Exclusions
   ##
   # Don't want these columns from UCD-SNMP-MIB::laTable
   fielddrop = [ "laErrorFlag", "laErrMessage" ]
   # Don't want these rows from UCD-DISKIO-MIB::diskIOTable
   [inputs.snmp.tagdrop]
     diskIODevice = [ "loop*", "ram*" ]
   ## 
   ## System details
   ##
   #  System name (hostname)
   [[inputs.snmp.field]]
     name = "sysName"
     oid = "SNMPv2-MIB::sysName.0"
     is_tag = true
   #  System vendor OID
   [[inputs.snmp.field]]
     name = "sysObjectID"
     oid = "SNMPv2-MIB::sysObjectID.0"
   #  System description
   [[inputs.snmp.field]]
     name = "sysDescr"
     oid = "SNMPv2-MIB::sysDescr.0"
   #  System contact
   [[inputs.snmp.field]]
     name = "sysContact"
     oid = "SNMPv2-MIB::sysContact.0"
   #  System location
   [[inputs.snmp.field]]
     name = "sysLocation"
     oid = "SNMPv2-MIB::sysLocation.0"
   ##
   ## Host/System Resources
   ##
   #  System uptime
   [[inputs.snmp.field]]
     name = "sysUpTime"
     oid = "HOST-RESOURCES-MIB::hrSystemUptime.0"
   #  Number of user sessions
   [[inputs.snmp.field]]
     name = "hrSystemNumUsers"
     oid = "HOST-RESOURCES-MIB::hrSystemNumUsers.0"
   #  Number of process contexts
   [[inputs.snmp.field]]
     name = "hrSystemProcesses"
     oid = "HOST-RESOURCES-MIB::hrSystemProcesses.0"
   #  Device Listing
   [[inputs.snmp.table]]
     oid = "HOST-RESOURCES-MIB::hrDeviceTable"
     [[inputs.snmp.table.field]]
       oid = "HOST-RESOURCES-MIB::hrDeviceIndex"
       is_tag = true
   ##
   ## Context Switches & Interrupts
   ##
   #  Number of interrupts processed
   [[inputs.snmp.field]]
     name = "ssRawInterrupts"
     oid = "UCD-SNMP-MIB::ssRawInterrupts.0"
   #  Number of context switches
   [[inputs.snmp.field]]
     name = "ssRawContexts"
     oid = "UCD-SNMP-MIB::ssRawContexts.0"
   ##
   ## Host performance metrics
   ##
   #  System Load Average 
   [[inputs.snmp.table]]
     oid = "UCD-SNMP-MIB::laTable"
     [[inputs.snmp.table.field]]
       oid = "UCD-SNMP-MIB::laNames"
       is_tag = true
   ##
   ## CPU inventory
   ##
   #  Processor listing
   [[inputs.snmp.table]]
     index_as_tag = true
     oid = "HOST-RESOURCES-MIB::hrProcessorTable"
   ##
   ## CPU utilization
   ##
   #  Number of 'ticks' spent on user-level
   [[inputs.snmp.field]]
     name = "ssCpuRawUser"
     oid = "UCD-SNMP-MIB::ssCpuRawUser.0"
   #  Number of 'ticks' spent on reduced-priority
   [[inputs.snmp.field]]
     name = "ssCpuRawNice"
     oid = "UCD-SNMP-MIB::ssCpuRawNice.0"
   #  Number of 'ticks' spent on system-level
   [[inputs.snmp.field]]
     name = "ssCpuRawSystem"
     oid = "UCD-SNMP-MIB::ssCpuRawSystem.0"
   #  Number of 'ticks' spent idle
   [[inputs.snmp.field]]
     name = "ssCpuRawIdle"
     oid = "UCD-SNMP-MIB::ssCpuRawIdle.0"
   #  Number of 'ticks' spent waiting on I/O
   [[inputs.snmp.field]]
     name = "ssCpuRawWait"
     oid = "UCD-SNMP-MIB::ssCpuRawWait.0"
   #  Number of 'ticks' spent in kernel
   [[inputs.snmp.field]]
     name = "ssCpuRawKernel"
     oid = "UCD-SNMP-MIB::ssCpuRawKernel.0"
   #  Number of 'ticks' spent on hardware interrupts
   [[inputs.snmp.field]]
     name = "ssCpuRawInterrupt"
     oid = "UCD-SNMP-MIB::ssCpuRawInterrupt.0"
   #  Number of 'ticks' spent on software interrupts
   [[inputs.snmp.field]]
     name = "ssCpuRawSoftIRQ"
     oid = "UCD-SNMP-MIB::ssCpuRawSoftIRQ.0"
   ##
   ## System Memory (physical/virtual)
   ##
   #  Size of phsyical memory (RAM)
   [[inputs.snmp.field]]
     name = "hrMemorySize"
     oid = "HOST-RESOURCES-MIB::hrMemorySize.0"
   #  Size of real/phys mem installed
   [[inputs.snmp.field]]
     name = "memTotalReal"
     oid = "UCD-SNMP-MIB::memTotalReal.0"
   #  Size of real/phys mem unused/avail
   [[inputs.snmp.field]]
     name = "memAvailReal"
     oid = "UCD-SNMP-MIB::memAvailReal.0"
   #  Total amount of mem unused/avail
   [[inputs.snmp.field]]
     name = "memTotalFree"
     oid = "UCD-SNMP-MIB::memTotalFree.0"
   #  Size of mem used as shared memory
   [[inputs.snmp.field]]
     name = "memShared"
     oid = "UCD-SNMP-MIB::memShared.0"
   #  Size of mem used for buffers
   [[inputs.snmp.field]]
     name = "memBuffer"
     oid = "UCD-SNMP-MIB::memBuffer.0"
   #  Size of mem used for cache
   [[inputs.snmp.field]]
     name = "memCached"
     oid = "UCD-SNMP-MIB::memCached.0"
   ##
   ## Block (Disk) performance
   ##
   #  System-wide blocks written
   [[inputs.snmp.field]]
     name = "ssIORawSent"
     oid = "UCD-SNMP-MIB::ssIORawSent.0"
   #  Number of blocks read
   [[inputs.snmp.field]]
     name = "ssIORawReceived"
     oid = "UCD-SNMP-MIB::ssIORawReceived.0"
   #  Per-device (disk) performance
   [[inputs.snmp.table]]
     oid = "UCD-DISKIO-MIB::diskIOTable"
     [[inputs.snmp.table.field]]
       oid = "UCD-DISKIO-MIB::diskIODevice"
       is_tag = true
   ##
   ## Disk/Partition/Filesystem inventory & usage
   ##
   #  Storage listing
   [[inputs.snmp.table]]
     oid = "HOST-RESOURCES-MIB::hrStorageTable"
     [[inputs.snmp.table.field]]
       oid = "HOST-RESOURCES-MIB::hrStorageDescr"
       is_tag = true
   ##
   ## Interface metrics
   ##
   #  Per-interface traffic, errors, drops
   [[inputs.snmp.table]]
     oid = "IF-MIB::ifTable"
     [[inputs.snmp.table.field]]
       oid = "IF-MIB::ifName"
       is_tag = true
   #  Per-interface high-capacity (HC) counters
   [[inputs.snmp.table]]
     oid = "IF-MIB::ifXTable"
     [[inputs.snmp.table.field]]
       oid = "IF-MIB::ifName"
       is_tag = true
   ##
   ## IP metrics
   ##
   #  System-wide IP metrics
   [[inputs.snmp.table]]
     index_as_tag = true
     oid = "IP-MIB::ipSystemStatsTable"
   ## 
   ## ICMP Metrics
   ##
   #  ICMP statistics
   [[inputs.snmp.table]]
     index_as_tag = true
     oid = "IP-MIB::icmpStatsTable"
   #  ICMP per-type statistics
   [[inputs.snmp.table]]
     index_as_tag = true
     oid = "IP-MIB::icmpMsgStatsTable"
   ##
   ## UDP statistics
   ##
   #  Datagrams delivered to app
   [[inputs.snmp.field]]
     name = "udpInDatagrams"
     oid = "UDP-MIB::udpInDatagrams.0"
   #  Datagrams received with no app
   [[inputs.snmp.field]]
     name = "udpNoPorts"
     oid = "UDP-MIB::udpNoPorts.0"
   #  Datagrams received with error
   [[inputs.snmp.field]]
     name = "udpInErrors"
     oid = "UDP-MIB::udpInErrors.0"
   #  Datagrams sent
   [[inputs.snmp.field]]
     name = "udpOutDatagrams"
     oid = "UDP-MIB::udpOutDatagrams.0"
   ##
   ## TCP statistics
   ##
   #  Number of CLOSED -> SYN-SENT transitions
   [[inputs.snmp.field]]
     name = "tcpActiveOpens"
     oid = "TCP-MIB::tcpActiveOpens.0"
   #  Number of SYN-RCVD -> LISTEN transitions
   [[inputs.snmp.field]]
     name = "tcpPassiveOpens"
     oid = "TCP-MIB::tcpPassiveOpens.0"
   #  Number of SYN-SENT/RCVD -> CLOSED transitions
   [[inputs.snmp.field]]
     name = "tcpAttemptFails"
     oid = "TCP-MIB::tcpAttemptFails.0"
   #  Number of ESTABLISHED/CLOSE-WAIT -> CLOSED transitions
   [[inputs.snmp.field]]
     name = "tcpEstabResets"
     oid = "TCP-MIB::tcpEstabResets.0"
   #  Number of ESTABLISHED or CLOSE-WAIT
   [[inputs.snmp.field]]
     name = "tcpCurrEstab"
     oid = "TCP-MIB::tcpCurrEstab.0"
   #  Number of segments received
   [[inputs.snmp.field]]
     name = "tcpInSegs"
     oid = "TCP-MIB::tcpInSegs.0"
   #  Number of segments sent
   [[inputs.snmp.field]]
     name = "tcpOutSegs"
     oid = "TCP-MIB::tcpOutSegs.0"
   #  Number of segments retransmitted
   [[inputs.snmp.field]]
     name = "tcpRetransSegs"
     oid = "TCP-MIB::tcpRetransSegs.0"
   #  Number of segments received with error
   [[inputs.snmp.field]]
     name = "tcpInErrs"
     oid = "TCP-MIB::tcpInErrs.0"
   #  Number of segments sent w/RST
   [[inputs.snmp.field]]
     name = "tcpOutRsts"
     oid = "TCP-MIB::tcpOutRsts.0"
   ##
   ## IP routing statistics
   ##
   #  Number of valid routing entries
   [[inputs.snmp.field]]
     name = "inetCidrRouteNumber"
     oid = "IP-FORWARD-MIB::inetCidrRouteNumber.0"
   #  Number of valid entries discarded
   [[inputs.snmp.field]]
     name = "inetCidrRouteDiscards"
     oid = "IP-FORWARD-MIB::inetCidrRouteDiscards.0"
   #  Number of valid forwarding entries
   [[inputs.snmp.field]]
     name = "ipForwardNumber"
     oid = "IP-FORWARD-MIB::ipForwardNumber.0"
   ##
   ## IP routing statistics
   ##
   # Number of valid routes discarded
   [[inputs.snmp.field]]
     name = "ipRoutingDiscards"
     oid = "RFC1213-MIB::ipRoutingDiscards.0"
   ##
   ## SNMP metrics
   ##
   #  Number of SNMP messages received
   [[inputs.snmp.field]]
     name = "snmpInPkts"
     oid = "SNMPv2-MIB::snmpInPkts.0"
   #  Number of SNMP Get-Request received
   [[inputs.snmp.field]]
     name = "snmpInGetRequests"
     oid = "SNMPv2-MIB::snmpInGetRequests.0"
   #  Number of SNMP Get-Next received
   [[inputs.snmp.field]]
     name = "snmpInGetNexts"
     oid = "SNMPv2-MIB::snmpInGetNexts.0"
   #  Number of SNMP objects requested
   [[inputs.snmp.field]]
     name = "snmpInTotalReqVars"
     oid = "SNMPv2-MIB::snmpInTotalReqVars.0"
   #  Number of SNMP Get-Response received
   [[inputs.snmp.field]]
     name = "snmpInGetResponses"
     oid = "SNMPv2-MIB::snmpInGetResponses.0"
   #  Number of SNMP messages sent
   [[inputs.snmp.field]]
     name = "snmpOutPkts"
     oid = "SNMPv2-MIB::snmpOutPkts.0"
   #  Number of SNMP Get-Request sent
   [[inputs.snmp.field]]
     name = "snmpOutGetRequests"
     oid = "SNMPv2-MIB::snmpOutGetRequests.0"
   #  Number of SNMP Get-Next sent
   [[inputs.snmp.field]]
     name = "snmpOutGetNexts"
     oid = "SNMPv2-MIB::snmpOutGetNexts.0"
   #  Number of SNMP Get-Response sent
   [[inputs.snmp.field]]
     name = "snmpOutGetResponses"
     oid = "SNMPv2-MIB::snmpOutGetResponses.0"

Logs:

2021-12-17T10:34:47Z I! Starting Telegraf 1.21.1
2021-12-17T10:34:47Z I! Loaded inputs: snmp
2021-12-17T10:34:47Z I! Loaded aggregators:
2021-12-17T10:34:47Z I! Loaded processors:
2021-12-17T10:34:47Z I! W! Outputs are not used in testing mode!
2021-12-17T10:34:47Z I! Tags enabled: host=server
Parse module: /var/lib/snmp/mibs/ietf/DPI20-MIB:9:4: unexpected "ibm" (expected ";")
2021-12-17T10:34:48Z W! [inputs.snmp] Could not load module at DPI20-MIB
Parse module: /var/lib/snmp/mibs/ietf/HPR-MIB:494:30: unexpected "HprRtpCounter" (expected "}")
2021-12-17T10:34:49Z W! [inputs.snmp] Could not load module at HPR-MIB
Parse module: /var/lib/snmp/mibs/ietf/SNMPv2-PDU:73:1: unexpected "max-bindings" (expected "END")
2021-12-17T10:34:50Z W! [inputs.snmp] Could not load module at SNMPv2-PDU
Parse module: /var/lib/snmp/mibs/ietf/TCPIPX-MIB:63:12: unexpected "tcpIpxConnLocalPort" (expected "}")
2021-12-17T10:34:51Z W! [inputs.snmp] Could not load module at TCPIPX-MIB
panic: strconv.ParseUint: parsing "": invalid syntax

goroutine 1 [running]:
github.com/sleepinggenius2/gosmi/types.OidMustFromString(...)
        /go/pkg/mod/github.com/sleepinggenius2/[email protected]/types/oid.go:91
github.com/influxdata/telegraf/internal/snmp.GetIndex({0x5693358, 0x1}, {0xc0008e9220, 0xe})
        /go/src/github.com/influxdata/telegraf/internal/snmp/translate.go:126 +0x3c8
github.com/influxdata/telegraf/plugins/inputs/snmp.snmpTableCall({0xc000eac221, 0x15})
        /go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:837 +0xc5
github.com/influxdata/telegraf/plugins/inputs/snmp.snmpTable({0xc000eac221, 0x15})
        /go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:820 +0x19d
github.com/influxdata/telegraf/plugins/inputs/snmp.(*Table).initBuild(0xc0007fa860)
        /go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:192 +0x4a
github.com/influxdata/telegraf/plugins/inputs/snmp.(*Table).Init(0xc0007fa860)
        /go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:162 +0x5b
github.com/influxdata/telegraf/plugins/inputs/snmp.(*Snmp).Init(0xc000072160)
        /go/src/github.com/influxdata/telegraf/plugins/inputs/snmp/snmp.go:110 +0x127
github.com/influxdata/telegraf/models.(*RunningInput).Init(0xc000e4f758)
        /go/src/github.com/influxdata/telegraf/models/running_input.go:82 +0x35
github.com/influxdata/telegraf/agent.(*Agent).initPlugins(0xc0001302e0)
        /go/src/github.com/influxdata/telegraf/agent/agent.go:189 +0x96
github.com/influxdata/telegraf/agent.(*Agent).test(0xc0001302e0, {0x57e5688, 0xc0002d0180}, 0x0, 0xc000311680)
        /go/src/github.com/influxdata/telegraf/agent/agent.go:884 +0x7b
github.com/influxdata/telegraf/agent.(*Agent).Test(0x4dea408, {0x57e5688, 0xc0002d0180}, 0x7)
        /go/src/github.com/influxdata/telegraf/agent/agent.go:866 +0xd4
main.runAgent({0x57e5688, 0xc0002d0180}, {0x837a278, 0x0, 0x0}, {0x837a278, 0x0, 0x0})
        /go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf.go:291 +0xadd
main.reloadLoop({0x837a278, 0x0, 0x0}, {0x837a278, 0x0, 0x0})
        /go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf.go:147 +0x28a
main.run(...)
        /go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf_posix.go:8
main.main()
        /go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf.go:485 +0xa9a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants