Skip to content

Commit

Permalink
Add SNMP config (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarlinMr authored Aug 7, 2021
1 parent 21d52c3 commit 0fe44f1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
9 changes: 9 additions & 0 deletions doc/docker/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
> :warning: Only used if you enable and run a [sidecar snmptrapd container](../notes/snmptrapd.md)
* `SIDECAR_SNMPTRAPD`: Set to `1` to enable sidecar snmptrapd mode for this container (default `0`)
* `SNMP_PROCESSING_TYPE`: Sets which type of processing (`log`, `execute`, and/or `net`) to use with the SNMP trap (default `log,execute,net`)
* `SNMP_USER`: Defines what username to authenticate with (default `librenms_user`)
* `SNMP_AUTH`: Defines what password to authenticate with (default `auth_pass` should not be used, but will work)
* `SNMP_PRIV`: Defines what password to encrypt packages with (default `priv_pass` should not be used, but will work)
* `SNMP_AUTH_PROTO`: Sets what protocol (`MD5`|`SHA`) to use for authentication (default `SHA`)
* `SNMP_PRIV_PROTO`: Sets what protocol (`DES`|`AES`) to use for encryption of packages (default `AES`)
* `SNMP_SECURITY_LEVEL`: Sets what security level (`noauth`|`priv`) to use (default `priv`)
* `SNMP_ENGINEID`: Defines what SNMP EngineID to use (default `1234567890`)
* `SNMP_DISABLE_AUTHORIZATION`: Will disable the above access control checks, and revert to the previous behaviour of accepting all incoming notifications. (default `yes`)

### Database

Expand Down
18 changes: 18 additions & 0 deletions rootfs/etc/cont-init.d/08-svc-snmptrapd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

SIDECAR_SNNMPTRAPD=${SIDECAR_SNNMPTRAPD:-0}
LIBRENMS_SNMP_COMMUNITY=${LIBRENMS_SNMP_COMMUNITY:-librenmsdocker}
SNMP_PROCESSING_TYPE=${SNMP_PROCESSING_TYPE:-log,execute,net}
SNMP_USER=${SNMP_USER:-librenms_user}
SNMP_AUTH=${SNMP_AUTH:-auth_pass}
SNMP_PRIV=${SNMP_PRIV:-priv_pass}
SNMP_AUTH_PROTO=${SNMP_AUTH_PROTO:-SHA}
SNMP_PRIV_PROTO=${SNMP_PRIV_PROTO:-AES}
SNMP_SECURITY_LEVEL=${SNMP_SECURITY_LEVEL:-priv}
SNMP_ENGINEID=${SNMP_ENGINEID:-1234567890}
SNMP_DISABLE_AUTHORIZATION=${SNMP_DISABLE_AUTHORIZATION:-yes}

# Continue only if sidecar snmptrapd container
if [ "$SIDECAR_SNNMPTRAPD" != "1" ]; then
Expand All @@ -16,6 +25,15 @@ mkdir -p /run/snmptrapd
chown -R librenms. /run/snmptrapd

sed -ie "s/@LIBRENMS_SNMP_COMMUNITY@/${LIBRENMS_SNMP_COMMUNITY}/" /etc/snmp/snmptrapd.conf
sed -ie "s/@SNMP_PROCESSING_TYPE@/${SNMP_PROCESSING_TYPE}/" /etc/snmp/snmptrapd.conf'
sed -ie "s/@SNMP_USER@/${SNMP_USER}/" /etc/snmp/snmptrapd.conf
sed -ie "s/@SNMP_AUTH@/${SNMP_AUTH}/" /etc/snmp/snmptrapd.conf
sed -ie "s/@SNMP_PRIV@/${SNMP_PRIV}/" /etc/snmp/snmptrapd.conf
sed -ie "s/@SNMP_AUTH_PROTO@/${SNMP_AUTH_PROTO}/" /etc/snmp/snmptrapd.conf
sed -ie "s/@SNMP_PRIV_PROTO@/${SNMP_PRIV_PROTO}/" /etc/snmp/snmptrapd.conf
sed -ie "s/@SNMP_SECURITY_LEVEL@/${SNMP_SECURITY_LEVEL}/" /etc/snmp/snmptrapd.conf
sed -ie "s/@SNMP_ENGINEID@/${SNMP_ENGINEID}/" /etc/snmp/snmptrapd.conf
sed -ie "s/@SNMP_DISABLE_AUTHORIZATION@/${SNMP_DISABLE_AUTHORIZATION}/" /etc/snmp/snmptrapd.conf
# Create service
mkdir -p /etc/services.d/snmptrapd
Expand Down
6 changes: 4 additions & 2 deletions rootfs/etc/snmp/snmptrapd.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
disableAuthorization yes
authCommunity log,execute,net @LIBRENMS_SNMP_COMMUNITY@
disableAuthorization @SNMP_DISABLE_AUTHORIZATION@
createUser -e 0x@SNMP_ENGINEID@ @SNMP_USER@ @SNMP_AUTH_PROTO@ @SNMP_AUTH@ @SNMP_PRIV_PROTO@ @SNMP_PRIV@
authUser @SNMP_PROCESSING_TYPE@ @SNMP_USER@ @SNMP_SECURITY_LEVEL@
authCommunity @SNMP_PROCESSING_TYPE@ @LIBRENMS_SNMP_COMMUNITY@
traphandle default /opt/librenms/snmptrap.php

0 comments on commit 0fe44f1

Please sign in to comment.