Skip to content

Commit

Permalink
snmptrapd: add larger buffer size than the linux default ones and mak…
Browse files Browse the repository at this point in the history
…e it customizable via env var
  • Loading branch information
iqbalaydrus committed Dec 13, 2023
1 parent 848827c commit 27d3bf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apt-get update && \
snmptrapd=5.9.1+* \
snmp=5.9.1+* \
snmp-mibs-downloader=1.5 \
pv \
tzdata ca-certificates
RUN mkdir /etc/trap2json /etc/trap2json/mibs /var/run/snmptrapd /var/log/trap2json
COPY --from=buildStage /trap2json /usr/local/bin/trap2json
Expand All @@ -23,4 +24,5 @@ RUN chmod +x entrypoint.sh
EXPOSE 10162/udp
# prometheus
EXPOSE 9285
ENV T2J_BUFFERSIZE=32M
ENTRYPOINT ["/entrypoint.sh"]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ Or if you want to pass extra arguments to snmptrapd
```shell
docker run -v ./config.yml:/etc/trap2json/config.yml -p 162:10162/udp bangunindo/trap2json:latest -Lf /var/log/trap2json/snmptrapd.log -Dusm
```
The buffer size for snmptrapd can be customized by setting `T2J_BUFFERSIZE` environment variable.
By default, it's set to 32M to accommodate trap2json startup time.
```shell
docker run -e T2J_BUFFERSIZE=128M -v ./config.yml:/etc/trap2json/config.yml -p 162:10162/udp bangunindo/trap2json:latest
```

## Zabbix Forwarder
For zabbix forwarder to work, you need to create an item with Zabbix Trapper type and text/log data type. If you need
to map the agent address to host's interface, consider using the `advanced` section of `zabbix_trapper` config in [config.yml](config.yml).

Zabbix limits its text/log type to 65536 characters/bytes (depending on backend). In most cases you probably will
not meet this limitation. But when it does, you might want to create a smaller json schema with only the data
you want.
you want.
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -e
trap2json -generate /etc/trap2json/snmptrapd.conf
shopt -s lastpipe
snmptrapd -M +/etc/trap2json/mibs -m ALL -Lo -OnUx -f -C -c /etc/trap2json/snmptrapd.conf $@ | exec trap2json
snmptrapd -M +/etc/trap2json/mibs -m ALL -Lo -OnUx -f -C -c /etc/trap2json/snmptrapd.conf $@ | pv -q -B "${T2J_BUFFERSIZE:-32M}" | exec trap2json

0 comments on commit 27d3bf7

Please sign in to comment.