diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 427822e..707f922 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,7 @@ jobs: password: ${{ secrets.DOCKER_TOKEN }} - name: Docker Build & Push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: push: true context: . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7da15eb..072b8d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,7 @@ jobs: - 3.17 - 3.18 - 3.19 + - 3.20 steps: - name: Code Checkout uses: actions/checkout@v4 diff --git a/Dockerfile b/Dockerfile index d1d9149..746b946 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:${ALPINE_VERSION:-3.19} +FROM alpine:${ALPINE_VERSION:-3.20} RUN apk add --update --no-cache net-snmp net-snmp-tools envsubst diff --git a/README.md b/README.md index a634c5c..f108072 100644 --- a/README.md +++ b/README.md @@ -31,18 +31,21 @@ Obrigado pelo seu apoio contínuo! ## Environment Variables -| Variable | Options | Default | -|-----------------------|-----------------|--------------------------------| -| SNMP_COMMUNITY | -- | public | -| SNMP_LOCATION | -- | At flying circus | -| SNMP_CONTACT | -- | Testainers | -| SNMP_SERVICES | -- | 72 | -| SNMP_V3_USER | -- | -- | -| SNMP_V3_USER_TYPE | rouser - rwuser | rouser | -| SNMP_V3_AUTH_PROTOCOL | MD5 - SHA | SHA | -| SNMP_V3_AUTH_PWD | -- | -- | -| SNMP_V3_PRIV_PROTOCOL | DES - AES | AES | -| SNMP_V3_PRIV_PWD | -- | -- | +| Variable | Options | Default | +|-----------------------|-----------------|---------| +| SNMP_COMMUNITY | -- | public | +| SNMP_LOCATION | -- | -- | +| SNMP_CONTACT | -- | -- | +| SNMP_SERVICES | -- | -- | +| SNMP_V3_USER | -- | -- | +| SNMP_V3_USER_TYPE | rouser - rwuser | rouser | +| SNMP_V3_AUTH_PROTOCOL | MD5 - SHA | SHA | +| SNMP_V3_AUTH_PWD | -- | -- | +| SNMP_V3_PRIV_PROTOCOL | DES - AES | AES | +| SNMP_V3_PRIV_PWD | -- | -- | + +If `SNMP_LOCATION`, `SNMP_CONTACT` or `SNMP_SERVICES` are not set, they may +be writable. ## How to Use @@ -73,7 +76,35 @@ docker build . --no-cache -t snmpd-container Run: ```shell -docker run -d --rm --name snmpd -p 5161:161/udp snmpd-container +docker run -d --rm --name snmpd -p 5161:161/udp \ + -e SNMP_V3_USER_TYPE=rwuser \ + -e SNMP_V3_USER=testainers \ + -e SNMP_V3_AUTH_PWD=authpass \ + -e SNMP_V3_PRIV_PWD=privpass \ + snmpd-container +``` + +Test: + +```shell +snmpwalk -v3 -On -u testainers -l authPriv \ + -a SHA -A authpass \ + -x AES -X privpass \ + localhost:5161 .1.3.6.1.2.1.1 +``` + +```shell +snmpset -v3 -u testainers -l authPriv \ + -a SHA -A authpass \ + -x AES -X privpass \ + localhost:5161 .1.3.6.1.2.1.1.4.0 s "admin@testainers.com" +``` + +```shell +snmpget -v3 -u testainers -l authPriv \ + -a SHA -A authpass \ + -x AES -X privpass \ + localhost:5161 .1.3.6.1.2.1.1.4.0 ``` Access: diff --git a/entrypoint.sh b/entrypoint.sh index 784a70b..5a2844b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,15 +30,21 @@ if [ -z "$SNMP_COMMUNITY" ]; then export SNMP_COMMUNITY="public" fi -if [ -z "$SNMP_LOCATION" ]; then - export SNMP_LOCATION="At flying circus" +if [ -n "$SNMP_LOCATION" ]; then + export SNMP_LOCATION="sysLocation $SNMP_LOCATION" +else + export SNMP_LOCATION="" fi -if [ -z "$SNMP_CONTACT" ]; then - export SNMP_CONTACT="Testainers " +if [ -n "$SNMP_CONTACT" ]; then + export SNMP_CONTACT="sysContact $SNMP_CONTACT" +else + export SNMP_CONTACT="" fi -if [ -z "$SNMP_SERVICES" ]; then +if [ -n "$SNMP_SERVICES" ]; then + export SNMP_SERVICES="sysServices $SNMP_SERVICES" +else export SNMP_SERVICES="72" fi diff --git a/etc/snmp/snmpd.template.conf b/etc/snmp/snmpd.template.conf index a4ae023..571eed9 100644 --- a/etc/snmp/snmpd.template.conf +++ b/etc/snmp/snmpd.template.conf @@ -77,11 +77,13 @@ rocommunity ${SNMP_COMMUNITY} default # Note that setting these values here, results in the corresponding MIB objects being 'read-only' # See snmpd.conf(5) for more details -sysLocation ${SNMP_LOCATION} -sysContact ${SNMP_CONTACT} +# sysLocation +${SNMP_LOCATION} +# sysContact +${SNMP_CONTACT} # Application + End-to-End layers -sysServices ${SNMP_SERVICES} - +# sysServices +${SNMP_SERVICES} # # Process Monitoring diff --git a/test.sh b/test.sh index b3be96a..73f54e3 100755 --- a/test.sh +++ b/test.sh @@ -297,6 +297,8 @@ docker stop -t 1 "$CONTAINER_NAME" >/dev/null 2>&1 sleep 2 printf "[OK]\n\n" +# TODO: Write test for SNMP SET! + ################## # Removing Image # ################## diff --git a/version.yaml b/version.yaml index f2b2ffc..b1f07a6 100644 --- a/version.yaml +++ b/version.yaml @@ -1 +1 @@ -version: 0.0.3 +version: 0.0.4