Skip to content

Commit 166b51f

Browse files
committed
Add snmp-exporter image
1 parent d7c4458 commit 166b51f

File tree

5 files changed

+164
-0
lines changed

5 files changed

+164
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
prometheus/blackbox-exporter: 'prometheus/blackbox-exporter/**'
7878
prometheus/node-exporter: 'prometheus/node-exporter/**'
7979
prometheus/prometheus: 'prometheus/prometheus/**'
80+
prometheus/snmp-exporter: 'prometheus/snmp-exporter/**'
8081
pspace: 'pspace/**'
8182
pulumi/pulumi-base: 'pulumi/pulumi-base/**'
8283
pulumi/pulumi-python: 'pulumi/pulumi-python/**'
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# syntax=docker/dockerfile:1
2+
ARG BASE_IMAGE=docker.io/ubuntu:noble-20250529
3+
# hadolint ignore=DL3006
4+
FROM $BASE_IMAGE AS base
5+
6+
ARG SNMP_EXPORTER_URL_AMD64
7+
ARG SNMP_EXPORTER_SHA256_AMD64
8+
ARG SNMP_EXPORTER_URL_ARM64
9+
ARG SNMP_EXPORTER_SHA256_ARM64
10+
11+
FROM base AS download
12+
13+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
14+
RUN <<EOF
15+
apt-get update
16+
apt-get install -y --no-install-recommends \
17+
ca-certificates \
18+
curl
19+
mkdir -p /tmp/snmp_exporter
20+
dpkgArch="$(dpkg --print-architecture)"
21+
case "${dpkgArch##*-}" in \
22+
amd64) \
23+
SNMP_EXPORTER_URL="${SNMP_EXPORTER_URL_AMD64}" \
24+
SNMP_EXPORTER_SHA256="${SNMP_EXPORTER_SHA256_AMD64}" \
25+
;; \
26+
arm64) \
27+
SNMP_EXPORTER_URL="${SNMP_EXPORTER_URL_ARM64}" \
28+
SNMP_EXPORTER_SHA256="${SNMP_EXPORTER_SHA256_ARM64}" \
29+
;; \
30+
*) echo "unsupported architecture"; exit 1 ;; \
31+
esac
32+
curl -fsSL -o /tmp/snmp_exporter.tar.gz "${SNMP_EXPORTER_URL}"
33+
echo "${SNMP_EXPORTER_SHA256} /tmp/snmp_exporter.tar.gz" | sha256sum -c -
34+
tar xvf /tmp/snmp_exporter.tar.gz -C /tmp/snmp_exporter --strip-components 1
35+
EOF
36+
37+
FROM base
38+
39+
RUN <<EOF
40+
apt-get update
41+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
42+
ca-certificates
43+
rm -rf /var/lib/apt/lists/*
44+
EOF
45+
46+
COPY --chmod=755 --from=download /tmp/snmp_exporter/snmp_exporter /usr/local/bin/snmp_exporter
47+
COPY --from=download /tmp/snmp_exporter/snmp.yml /etc/snmp_exporter/snmp.yml
48+
49+
EXPOSE 9116
50+
USER nobody
51+
ENTRYPOINT [ "/usr/local/bin/snmp_exporter" ]
52+
CMD ["--config.file=/etc/snmp_exporter/snmp.yml"]

prometheus/snmp-exporter/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
snmp_exporter
2+
-----------------
3+
This image repackages snmp_exporter releases from
4+
https://github.com/prometheus/snmp_exporter/releases
5+
6+
This image is based on https://github.com/prometheus/snmp_exporter/blob/main/Dockerfile
7+
8+
Image Source: https://github.com/polymathrobotics/oci/tree/main/prometheus/snmp_exporter
9+
10+
CLI
11+
---
12+
```
13+
% docker run -it --rm docker.io/polymathrobotics/snmp-exporter --help
14+
usage: snmp_exporter [<flags>]
15+
16+
17+
Flags:
18+
-h, --[no-]help Show context-sensitive help (also try
19+
--help-long and --help-man).
20+
--[no-]snmp.wrap-large-counters
21+
Wrap 64-bit counters to avoid floating point
22+
rounding.
23+
--snmp.source-address="" Source address to send snmp from in the format
24+
'address:port' to use when connecting targets.
25+
If the port parameter is empty or '0', as in
26+
'127.0.0.1:' or '[::1]:0', a source port number
27+
is automatically (random) chosen.
28+
--config.file=snmp.yml ...
29+
Path to configuration file.
30+
--[no-]dry-run Only verify configuration is valid and exit.
31+
--snmp.module-concurrency=1
32+
The number of modules to fetch concurrently per
33+
scrape
34+
--[no-]snmp.debug-packets Include a full debug trace of SNMP packet
35+
traffics.
36+
--[no-]config.expand-environment-variables
37+
Expand environment variables to source secrets
38+
--web.telemetry-path="/metrics"
39+
Path under which to expose metrics.
40+
--[no-]web.systemd-socket Use systemd socket activation listeners instead
41+
of port listeners (Linux only).
42+
--web.listen-address=:9116 ...
43+
Addresses on which to expose metrics and web
44+
interface. Repeatable for multiple addresses.
45+
Examples: `:9100` or `[::1]:9100` for http,
46+
`vsock://:9100` for vsock
47+
--web.config.file="" Path to configuration file that can
48+
enable TLS or authentication. See:
49+
https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md
50+
--log.level=info Only log messages with the given severity or
51+
above. One of: [debug, info, warn, error]
52+
--log.format=logfmt Output format of log messages. One of: [logfmt,
53+
json]
54+
--[no-]version Show application version.
55+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
variable "TAG_PREFIX" {
2+
default = "docker.io/polymathrobotics/snmp-exporter"
3+
}
4+
5+
variable "VERSION" {
6+
default = "0.29.0"
7+
}
8+
9+
# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux
10+
variable "LOCAL_PLATFORM" {
11+
default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux")
12+
}
13+
14+
target "_common" {
15+
dockerfile = "Containerfile"
16+
args = {
17+
SNMP_EXPORTER_URL_AMD64 = "https://github.com/prometheus/snmp_exporter/releases/download/v0.29.0/snmp_exporter-0.29.0.linux-amd64.tar.gz"
18+
SNMP_EXPORTER_SHA256_AMD64 = "fd7ded886180063a8f77e1ca18cc648e44b318b9c92bcb3867b817d93a5232d6"
19+
SNMP_EXPORTER_URL_ARM64 = "https://github.com/prometheus/snmp_exporter/releases/download/v0.29.0/snmp_exporter-0.29.0.linux-arm64.tar.gz"
20+
SNMP_EXPORTER_SHA256_ARM64 = "e590870ad2fcd39ea9c7d722d6e85aa6f1cc9e8671ff3f17feba12a6b5a3b47a"
21+
}
22+
tags = [
23+
"${TAG_PREFIX}:${VERSION}",
24+
"${TAG_PREFIX}:latest"
25+
]
26+
labels = {
27+
"org.opencontainers.image.source" = "https://github.com/polymathrobotics/oci"
28+
"org.opencontainers.image.licenses" = "Apache-2.0"
29+
"org.opencontainers.image.description" = "Prometheus SNMP Exporter"
30+
"org.opencontainers.image.title" = "${TAG_PREFIX}"
31+
"org.opencontainers.image.created" = "${timestamp()}"
32+
"dev.polymathrobotics.image.readme-filepath" = "prometheus/snmp-exporter/README.md"
33+
}
34+
}
35+
36+
target "local" {
37+
inherits = ["_common"]
38+
platforms = ["${LOCAL_PLATFORM}"]
39+
}
40+
41+
target "default" {
42+
inherits = ["_common"]
43+
platforms = ["linux/amd64", "linux/arm64/v8"]
44+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
describe command('snmp_exporter') do
2+
it { should exist }
3+
end
4+
5+
describe command('snmp_exporter --version') do
6+
its('exit_status') { should eq 0 }
7+
its('stderr') { should match(/snmp_exporter, version/) }
8+
end
9+
10+
describe file('/etc/snmp_exporter/snmp.yml') do
11+
it { should exist }
12+
end

0 commit comments

Comments
 (0)