how to use snmp generator

3,695 views
Skip to first unread message

californi...@gmail.com

unread,
Jan 20, 2017, 2:07:01 AM1/20/17
to Prometheus Users
Hi,

I have compiled generator that comes with snmp exporter on my ubuntu container. I can successfully generate metrics settings from MIB files. But I could not figure out the details.

1. Where are the MIB files referred to by generator? (Where should I put additional extended/enterprise mib files?)
I was wondering where I should put additional extended mibs (1.3.6.1.4.1.X). I can find mib files at /usr/share/mibs(link to /var/lib/mibs), which seemed to be downloaded while installing snmp-mibs-downloader. I assumed generator refers to this directory. Is this true and I am recommended to put extended mibs here?

2. Where can I find logs about generater?
Following log message is shown while generating snmp.yml:

WARN[0000] NetSNMP reported 9 parse errors               source=main.go:75

I can find the parse errors NetSNMP reported. What I want to do is to prove snmp.yml contains correct metrics setting. Which mib files were used, which SNMP object was written or dropped, and so forth.

Brian Brazil

unread,
Jan 20, 2017, 3:38:57 AM1/20/17
to 若林耕平, Prometheus Users
On 20 January 2017 at 07:07, <californi...@gmail.com> wrote:
Hi,

I have compiled generator that comes with snmp exporter on my ubuntu container. I can successfully generate metrics settings from MIB files. But I could not figure out the details.

1. Where are the MIB files referred to by generator? (Where should I put additional extended/enterprise mib files?)
I was wondering where I should put additional extended mibs (1.3.6.1.4.1.X). I can find mib files at /usr/share/mibs(link to /var/lib/mibs), which seemed to be downloaded while installing snmp-mibs-downloader. I assumed generator refers to this directory. Is this true and I am recommended to put extended mibs here?

You can put them wherever netsmp will read them from.
 

2. Where can I find logs about generater?
Following log message is shown while generating snmp.yml:

WARN[0000] NetSNMP reported 9 parse errors               source=main.go:75

I can find the parse errors NetSNMP reported. What I want to do is to prove snmp.yml contains correct metrics setting. Which mib files were used, which SNMP object was written or dropped, and so forth.

That requires manual verification, logs wouldn't help you here.

Brian
 

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/ead86b49-8afd-44c1-9f97-a7238643c5ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

californi...@gmail.com

unread,
Jan 20, 2017, 4:18:39 AM1/20/17
to Prometheus Users, californi...@gmail.com
You can put them wherever netsmp will read them from.

OK. At least, generator looks up to /usr/share/mibs. I will use this directory to store extended mibs.
 
That requires manual verification, logs wouldn't help you here.

I need to figure out what happend with this message, whether I can just ignore it or not.

WARN[0000] NetSNMP reported 9 parse errors               source=main.go:75

please let me know where to look up.

Brian Brazil

unread,
Jan 20, 2017, 4:27:47 AM1/20/17
to 若林耕平, Prometheus Users
You can usually ignore it. If you're seeing issues with MIBs not being parsed correctly you might need to read them.

Brian 

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

californi...@gmail.com

unread,
Jan 23, 2017, 9:31:11 AM1/23/17
to Prometheus Users, californi...@gmail.com

I have a generator.yml as follows:


--------

modules:

  vyos:

    walk:

      - 1.3.6.1.2.1.2.2.1.4

    lookups:

      - old_index: ifIndex

        new_index: ifDescr

--------


where 1.3.6.1.2.1.2.2.1.4 is ifMtu defined in IF-MIB.

I executed 'generator generate' command.


--------

root@9064bddcf637:~/go/bin# generator generate

WARN[0000] NetSNMP reported 1 parse errors               source=main.go:75

INFO[0000] Generating config for module vyos             source=main.go:29

INFO[0000] Generated 1 metrics for module vyos           source=main.go:33

INFO[0000] Config written to snmp.yml                    source=main.go:55

--------


I get snmp.yml as follows:


--------

vyos:

  walk:

  - 1.3.6.1.2.1.2.2.1.2

  - 1.3.6.1.2.1.2.2.1.4

  metrics:

  - name: ifMtu

    oid: 1.3.6.1.2.1.2.2.1.4

    indexes:

    - labelname: ifDescr

      type: Integer

    lookups:

    - labels:

      - ifDescr

      labelname: ifDescr

      oid: 1.3.6.1.2.1.2.2.1.2

--------


I get an error when accessing at http://snmp_exporter:9116/snmp?module=vyos&target=target_device


--------

An error has occurred during metrics gathering:

collected metric ifMtu untyped:<value:9001 >  was collected before with the same name and label values

--------


I replaced 'type: Integer' in snmp.yml with 'type: Integer32' then it worked


--------

# HELP ifMtu 

# TYPE ifMtu untyped

ifMtu{ifDescr="eth0"} 9001

ifMtu{ifDescr="lo"} 65536

--------


This is 'generator dump' output:


--------

1.3.6.1.2.1.2.2.1.4 ifMtu INTEGER32 [ifIndex] The size of the largest packet which can be sent/received on the interface, specified in octets

--------


I cannot figure out how to generate snmp.yml with Integer32 instead of Integer. I appreciate any help.

Brian Brazil

unread,
Jan 23, 2017, 9:33:06 AM1/23/17
to 若林耕平, Prometheus Users
ifDesc is non-unique, you can't use it as a lookup. Try the just-merged string support to handle this.

Brian
 

--------


I replaced 'type: Integer' in snmp.yml with 'type: Integer32' then it worked


--------

# HELP ifMtu 

# TYPE ifMtu untyped

ifMtu{ifDescr="eth0"} 9001

ifMtu{ifDescr="lo"} 65536

--------


This is 'generator dump' output:


--------

1.3.6.1.2.1.2.2.1.4 ifMtu INTEGER32 [ifIndex] The size of the largest packet which can be sent/received on the interface, specified in octets

--------


I cannot figure out how to generate snmp.yml with Integer32 instead of Integer. I appreciate any help.

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

californi...@gmail.com

unread,
Jan 23, 2017, 10:17:12 AM1/23/17
to Prometheus Users, californi...@gmail.com
 
ifDesc is non-unique, you can't use it as a lookup. Try the just-merged string support to handle this.

I get same error with generator.yml without lookup:

-- generator.yml --

modules:

  vyos:

    walk

      - 1.3.6.1.2.1.2.2.1.4

-- snmp.yml --

vyos:

  walk:

  - 1.3.6.1.2.1.2.2.1.4

  metrics:

  - name: ifMtu

    oid: 1.3.6.1.2.1.2.2.1.4

    indexes:

    - labelname: ifIndex

      type: Integer


-- error from snmp exporter --

An error has occurred during metrics gathering:
 

collected metric ifMtu untyped:<value:9001 > was collected before with the same name and label values 

-- ifDesc --
$ snmpwalk -v 2c -c prom 172.31.48.226 1.3.6.1.2.1.2.2.1.2

IF-MIB::ifDescr.1 = STRING: lo

IF-MIB::ifDescr.2 = STRING: eth0

Sorry if I misunderstood your comment. 

Brian Brazil

unread,
Jan 23, 2017, 10:19:43 AM1/23/17
to 若林耕平, Prometheus Users
On 23 January 2017 at 15:17, <californi...@gmail.com> wrote:
 
ifDesc is non-unique, you can't use it as a lookup. Try the just-merged string support to handle this.

I get same error with generator.yml without lookup:

Are you sure that's the config the snmp_exporter is using?

Brian
 

-- generator.yml --

modules:

  vyos:

    walk

      - 1.3.6.1.2.1.2.2.1.4

-- snmp.yml --

vyos:

  walk:

  - 1.3.6.1.2.1.2.2.1.4

  metrics:

  - name: ifMtu

    oid: 1.3.6.1.2.1.2.2.1.4

    indexes:

    - labelname: ifIndex

      type: Integer


-- error from snmp exporter --

An error has occurred during metrics gathering:
 

collected metric ifMtu untyped:<value:9001 > was collected before with the same name and label values 

-- ifDesc --
$ snmpwalk -v 2c -c prom 172.31.48.226 1.3.6.1.2.1.2.2.1.2

IF-MIB::ifDescr.1 = STRING: lo

IF-MIB::ifDescr.2 = STRING: eth0

Sorry if I misunderstood your comment. 

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

californi...@gmail.com

unread,
Jan 23, 2017, 10:31:54 AM1/23/17
to Prometheus Users, californi...@gmail.com


Are you sure that's the config the snmp_exporter is using?

Yes. 


# cat generator.yml

modules:

  vyos:

    walk:

      - 1.3.6.1.2.1.2.2.1.4

# generator generate

WARN[0000] NetSNMP reported 1 parse errors               source=main.go:75

INFO[0000] Generating config for module vyos             source=main.go:29

INFO[0000] Generated 1 metrics for module vyos           source=main.go:33

INFO[0000] Config written to snmp.yml                    source=main.go:55

# cat snmp.yml

vyos:

  walk:

  - 1.3.6.1.2.1.2.2.1.4

  metrics:

  - name: ifMtu

    oid: 1.3.6.1.2.1.2.2.1.4

    indexes:

    - labelname: ifIndex

      type: Integer



$ docker exec -it snmp-exporter3 /bin/ash

/ # cat /etc/snmp_exporter/snmp.yml

---

# Default module: interface stats and uptime.

vyos:

  version: 2

  auth:

    community: xxxx

californi...@gmail.com

unread,
Jan 24, 2017, 2:20:43 AM1/24/17
to Prometheus Users, californi...@gmail.com

I have been using docker container from prom/snmp_exporter. I reconstructed snmp_exporter from the latest source code without using prom/snmp_exporter container. Then, ifMtu shows up correctly without lookups.


--- snmp.yml ---

vyos:

  version: 2

  auth:

    community: prom

  walk:

  - 1.3.6.1.2.1

  metrics:

  - name: ifMtu

    oid: 1.3.6.1.2.1.2.2.1.4

    type: gauge

    indexes:

    - labelname: ifIndex

      type: Integer


--- browser output ---

# HELP ifMtu 

# TYPE ifMtu gauge

ifMtu{ifIndex="1"} 65536

ifMtu{ifIndex="2"} 9001



But same issue happens with other metrics and latest source code.


--- snmp.yml ---

vyos:

  version: 2

  auth:

    community: prom

  walk:

  - 1.3.6.1.2.1

  metrics:

  - name: tcpConnLocalPort

    oid: 1.3.6.1.2.1.6.13.1.3

    type: gauge

    indexes:

    - labelname: tcpConnLocalAddress

      type: IpAddr

    - labelname: tcpConnLocalPort

      type: Integer

    - labelname: tcpConnRemAddress

      type: IpAddr

    - labelname: tcpConnRemPort

      type: Integer


--- browser Output ---

An error has occurred during metrics gathering:


6 error(s) occurred:

* collected metric tcpConnLocalPort label:<name:"tcpConnLocalPort" value:"127" > label:<name:"tcpConnRemPort" value:"0" > gauge:<value:199 >  was collected before with the same name and label values

* collected metric tcpConnLocalPort label:<name:"tcpConnLocalPort" value:"127" > label:<name:"tcpConnRemPort" value:"0" > gauge:<value:199 >  was collected before with the same name and label values

* collected metric tcpConnLocalPort label:<name:"tcpConnLocalPort" value:"127" > label:<name:"tcpConnRemPort" value:"0" > gauge:<value:49108 >  was collected before with the same name and label values

* collected metric tcpConnLocalPort label:<name:"tcpConnLocalPort" value:"127" > label:<name:"tcpConnRemPort" value:"0" > gauge:<value:49107 >  was collected before with the same name and label values

* collected metric tcpConnLocalPort label:<name:"tcpConnLocalPort" value:"127" > label:<name:"tcpConnRemPort" value:"0" > gauge:<value:199 >  was collected before with the same name and label values

* collected metric tcpConnLocalPort label:<name:"tcpConnLocalPort" value:"127" > label:<name:"tcpConnRemPort" value:"0" > gauge:<value:199 >  was collected before with the same name and label values


--- snmpwalk result ---

$ snmpwalk -v 2c -c xxx x.x.x.x 1.3.6.1.2.1.6.13.1.3

TCP-MIB::tcpConnLocalPort.0.0.0.0.22.0.0.0.0.0 = INTEGER: 22

TCP-MIB::tcpConnLocalPort.127.0.0.1.199.0.0.0.0.0 = INTEGER: 199

TCP-MIB::tcpConnLocalPort.127.0.0.1.199.127.0.0.1.49107 = INTEGER: 199

TCP-MIB::tcpConnLocalPort.127.0.0.1.199.127.0.0.1.49108 = INTEGER: 199

TCP-MIB::tcpConnLocalPort.127.0.0.1.199.127.0.0.1.49109 = INTEGER: 199

TCP-MIB::tcpConnLocalPort.127.0.0.1.49107.127.0.0.1.199 = INTEGER: 49107

TCP-MIB::tcpConnLocalPort.127.0.0.1.49108.127.0.0.1.199 = INTEGER: 49108

TCP-MIB::tcpConnLocalPort.127.0.0.1.49109.127.0.0.1.199 = INTEGER: 49109

Reply all
Reply to author
Forward
0 new messages