snmp_exporter generator: Cannot find oid 'ifXTable' to walk

912 views
Skip to first unread message

Simon Szustkowski

unread,
Jun 5, 2019, 7:17:22 AM6/5/19
to Prometheus Users
Hi

i have a problem setting up the snmp_exporter. I have a minimal generator configuration file which just should create the default config:

generator.yml:

modules:
 
# Default IF-MIB interfaces table with ifIndex.
  if_mib
:
    walk
: [sysUpTime, interfaces, ifXTable]
    lookups
:
     
- source_indexes: [ifIndex]
        lookup
: ifAlias
     
- source_indexes: [ifIndex]
        lookup
: ifDescr
     
- source_indexes: [ifIndex]
       
# Use OID to avoid conflict with Netscaler NS-ROOT-MIB.
        lookup
: 1.3.6.1.2.1.31.1.1.1.1 # ifName
    overrides
:
      ifAlias
:
        ignore
: true # Lookup metric
      ifDescr
:
        ignore
: true # Lookup metric
      ifName
:
        ignore
: true # Lookup metric
      ifType
:
        type
: EnumAsInfo


(as copied from the example generator.yml)

I am running the generator via Docker then:
$ docker pull prom/snmp-generator
$ docker run
-ti \                                                                                                                                          
-v /data/snmp-exporter/mibs:/root/.snmp/mibs \
-v /data/snmp-exporter/exporter:/opt/ \
snmp
-generator generate


As a result i get the following error:

INFO[0000] Loading MIBs from mibs                        source="net_snmp.go:141"
WARN
[0000] NetSNMP reported 1 parse error(s)             source="main.go:104"
INFO
[0000] Generating config for module if_mib           source="main.go:49"
WARN
[0000] Could not find metric 'ifType' to override type  source="tree.go:264"
FATA
[0000] Cannot find oid 'ifXTable' to walk            source="tree.go:290"


Since i was unsure if the builtin snmp binaries did provide these MIBs, i downloaded them separately from http://www.net-snmp.org/docs/mibs/IF-MIB.txt and mounted the host directory containing the MIBs to `/root/.snmp/mibs` with the same result. 

Where am i wrong? Why can't the generator find the OID? 

Ben Kochie

unread,
Jun 5, 2019, 8:23:23 AM6/5/19
to Simon Szustkowski, Prometheus Users
In the snmp_exporter repo there is a Makefile that downloads all the base MIBs.

cd snmp_exporter/generator
make mibs

That should make you a good mibs/ dir that you can use with the generator.
--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/d1d5137b-15f0-456f-9781-e7dac750c628%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon Szustkowski

unread,
Jun 5, 2019, 8:31:04 AM6/5/19
to Prometheus Users
Well...i did it, but:

docker run -ti \                                                                                                                                                                        
                           
-v /data/snmp-exporter/mibs:/root/.snmp/mibs \
                           
-v /data/snmp-exporter/exporter:/opt/ \

                            snmp
-generator generate --log.level="debug" --log.format="logger:stdout"

INFO
[0000] Loading MIBs from mibs                        source="net_snmp.go:141"
WARN
[0000] NetSNMP reported 1 parse error(s)             source="main.go:104"
INFO
[0000] Generating config for module if_mib           source="main.go:49"
WARN
[0000] Could not find metric 'ifType' to override type  source="tree.go:264"
FATA
[0000] Cannot find oid 'ifXTable' to walk            source="tree.go:290"

But: 
 simonszu@naugol  /data/snmp-exporter/mibs  ls                                                                                                                                                                    
AIRESPACE
-REF-MIB            ENTITY-SENSOR-MIB     IF-MIB             PAN-COMMON-MIB.my.md5sum      PAN-LC-MIB.my              servertech-sentry3-mib  SYNOLOGY-FLASHCACHE-MIB.txt*  SYNOLOGY-STORAGEIO-MIB.txt*
AIRESPACE
-WIRELESS-MIB       ENTITY-STATE-MIB      INET-ADDRESS-MIB   PAN-ENTITY-EXT-MIB.my         PAN-LC-MIB.my.md5sum       SNMP-FRAMEWORK-MIB      SYNOLOGY-ISCSILUN-MIB.txt*    SYNOLOGY-SYSTEM-MIB.txt*
apc
-powernet-mib             ENTITY-STATE-TC-MIB   KEEPALIVED-MIB     PAN-ENTITY-EXT-MIB.my.md5sum  PAN-PRODUCT-MIB.my         SNMPv2-MIB              SYNOLOGY-RAID-MIB.txt*        SYNOLOGY-UPS-MIB.txt*
ARISTA
-ENTITY-SENSOR-MIB     HOST-RESOURCES-MIB    MIKROTIK-MIB       PAN-GLOBAL-REG-MIB.my         PAN-PRODUCT-MIB.my.md5sum  SNMPv2-SMI              SYNOLOGY-SERVICES-MIB.txt*    UBNT-AirMAX-MIB.txt
ARISTA
-SMI-MIB               IANA-CHARSET-MIB.txt  NET-SNMP-MIB       PAN-GLOBAL-REG-MIB.my.md5sum  PAN-TRAPS.my               SNMPv2-TC               SYNOLOGY-SHA-MIB.txt*         UBNT-MIB
ARISTA
-SW-IP-FORWARDING-MIB  IANA-IFTYPE-MIB.txt   NET-SNMP-TC        PAN-GLOBAL-TC-MIB.my          PAN-TRAPS.my.md5sum        SYNOLOGY-DISK-MIB.txt*  SYNOLOGY-SMART-MIB.txt*       UBNT-UniFi-MIB
ENTITY
-MIB                   IANA-PRINTER-MIB.txt  PAN-COMMON-MIB.my  PAN-GLOBAL-TC-MIB.my.md5sum   PRINTER-MIB-V2.txt         SYNOLOGY-EBOX-MIB.txt*  SYNOLOGY-SPACEIO-MIB.txt*     UCD-SNMP-MIB.txt

So, the MIBs are there, and they are mounted inside the container, but somehow cannot be parsed or what? :(

Ben Kochie

unread,
Jun 5, 2019, 9:48:07 AM6/5/19
to Simon Szustkowski, Prometheus Users
I figured it out.. Your docker command has the wrong volume map for the mibs dir. The default Dockerfile sets the MIBDIRS path to just be "mibs" which needs to be in /opt.

$ cd /data/snmp-exporter
$ ls -l
total 8
-rw-rw-r-- 1 ben ben  599 Jun  5 15:42 generator.yml
drwxrwxr-x 3 ben ben 4096 May 22 15:30 mibs
$ docker run -ti -v /data/snmp-exporter/:/opt/ snmp-generator generate

INFO[0000] Loading MIBs from mibs                        source="net_snmp.go:141"
WARN[0000] NetSNMP reported 229 parse errors             source="main.go:105"

INFO[0000] Generating config for module if_mib           source="main.go:49"
INFO[0000] Generated 39 metrics for module if_mib        source="main.go:60"
INFO[0000] Config written to /opt/snmp.yml               source="main.go:85"
$ ls -l
total 40
-rw-rw-r-- 1 ben  ben   599 Jun  5 15:42 generator.yml
drwxrwxr-x 3 ben  ben  4096 May 22 15:30 mibs
-rw-r--r-- 1 root ben 31079 Jun  5 15:47 snmp.yml


--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.

Simon Szustkowski

unread,
Jun 6, 2019, 5:05:20 AM6/6/19
to Prometheus Users
Ah yes. It works now, and i could create a proper ansible role to deploy the SNMP exporter. Thank you very much. 
To unsubscribe from this group and stop receiving emails from it, send an email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages