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

Adapt Dockerfile for arguments + multi-stage build #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jstoja
Copy link

@jstoja jstoja commented Oct 3, 2017

Hello,

I saw on your issue prometheus/snmp_exporter#120 that you created this Dockerfile.
I modified it so it's lighter (using multi-stage builds), but also configurable like @brian-brazil advised it.
In addition I used the idea from prometheus/snmp_exporter#223 to statically compile it.

I hope it'll help and maybe integrate it later to the original repo!

Hello,

I saw on your issue prometheus/snmp_exporter#120 that you created this Dockerfile.
I modified it so it's lighter (using multi-stage builds), but also configurable like @brian-brazil advised it.
In addition I used the idea from prometheus/snmp_exporter#223 to statically compile it.

I hope it'll help and maybe integrate it later to the original repo!
@ninoabbate
Copy link
Owner

Hey @jstoja, could you please update the readme too? Thanks

@jstoja
Copy link
Author

jstoja commented Jan 16, 2018

With pleasure, what do you want me to modify?
The Docker image is working the same way. The multi-stage build is totally transparent and don't change how the image is built or ran.

@ninoabbate
Copy link
Owner

The docker image is working, though the paths are different, I tested a build using the paths in README and this is the result:

$ docker run --rm -v "$PWD/mibs:/root/.snmp/mibs" \
> -v "$PWD/generator.yml:/root/go/src/github.com/prometheus/snmp_exporter/generator/generator.yml" \
> -v "$PWD/snmp.yml:/root/go/src/github.com/prometheus/snmp_exporter/generator/snmp.yml" 4e3487ca49d3
time="2018-01-16T10:38:44Z" level=info msg="Loading MIBs from $HOME/.snmp/mibs:/usr/share/snmp/mibs" source="net_snmp.go:109"
time="2018-01-16T10:38:44Z" level=warning msg="NetSNMP reported 3182 parse errors" source="main.go:72"
time="2018-01-16T10:38:44Z" level=info msg="Generating config for module default" source="main.go:30"
time="2018-01-16T10:38:44Z" level=fatal msg="Cannot find oid 'sysUpTime' to walk" source="tree.go:155"

As you see the paths are different, this is why I asked you to update the README to reflect your changes :).
Thanks again for your help.

@jstoja
Copy link
Author

jstoja commented Jan 25, 2018

Hello @ninoabbate sorry for the delay.

I indeed need to fix the README file, but the error you're having doesn't come from that.
The MIBs you're adding from this repository, do not have the definition for sysUpTime, therefore, after testing the $HOME/mibs directory, the usual fallback is the host definition. For this to work, it's needed to have the snmp library installed (or to mount them).
For example:

From there, 2 solutions:

  • We let it like this and advise people to mount the MIBs from their host.
  • We use Alpine in the Dockerfile to have the library.

Tell me which solution you prefer so I can push it + the README modification.
Thanks

@ninoabbate
Copy link
Owner

Hi @jstoja no worries, thanks!
Regarding the MIBs included in this repo, they are all recognized, infact if you run the container as explained in the current README everything works:

$ docker run --rm -v "$PWD/mibs:/root/.snmp/mibs" \
> -v "$PWD/generator.yml:/root/go/src/github.com/prometheus/snmp_exporter/generator/generator.yml" \
> -v "$PWD/snmp.yml:/root/go/src/github.com/prometheus/snmp_exporter/generator/snmp.yml" aabbate/secg:v0.8.0
time="2018-01-26T17:08:34Z" level=info msg="Loading MIBs from $HOME/.snmp/mibs:/usr/share/snmp/mibs" source="net_snmp.go:109"
time="2018-01-26T17:08:34Z" level=warning msg="NetSNMP reported 5 parse errors" source="main.go:72"
time="2018-01-26T17:08:34Z" level=info msg="Generating config for module default_ifname" source="main.go:30"
time="2018-01-26T17:08:34Z" level=info msg="Generated 42 metrics for module default_ifname" source="main.go:33"
time="2018-01-26T17:08:34Z" level=info msg="Generating config for module default_ifindex" source="main.go:30"
time="2018-01-26T17:08:34Z" level=info msg="Generated 42 metrics for module default_ifindex" source="main.go:33"
time="2018-01-26T17:08:34Z" level=info msg="Generating config for module paloalto_fw" source="main.go:30"
time="2018-01-26T17:08:34Z" level=info msg="Generated 152 metrics for module paloalto_fw" source="main.go:33"
time="2018-01-26T17:08:34Z" level=info msg="Generating config for module default" source="main.go:30"
time="2018-01-26T17:08:34Z" level=info msg="Generated 42 metrics for module default" source="main.go:33"
time="2018-01-26T17:08:34Z" level=info msg="Config written to snmp.yml" source="main.go:57"

We can include the package net-snmp-base and I'm cool with that, but keep in mind that the goal of this container is to make easy to everyone to create by himself the SNMP exporter configuration for monitoring their own devices starting from their MIBs, so they indeed will need to mount their MIBs, the fact that there are included MIBs in this repo is only for demo purposes .

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

Successfully merging this pull request may close these issues.

2 participants