Skip to content

Commit

Permalink
Merge pull request #4 from testainers/dev
Browse files Browse the repository at this point in the history
Version 0.0.4.
  • Loading branch information
edufolly authored Aug 14, 2024
2 parents 7638049 + cc0a28d commit e5d64bf
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- 3.17
- 3.18
- 3.19
- 3.20
steps:
- name: Code Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:${ALPINE_VERSION:-3.19}
FROM alpine:${ALPINE_VERSION:-3.20}

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build

FROM command must use declared ARGs

UndefinedArgInFrom: FROM argument 'ALPINE_VERSION' is not declared More info: https://docs.docker.com/go/dockerfile/rule/undefined-arg-in-from/

RUN apk add --update --no-cache net-snmp net-snmp-tools envsubst

Expand Down
57 changes: 44 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> |
| 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

Expand Down Expand Up @@ -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 "[email protected]"
```

```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:
Expand Down
16 changes: 11 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"
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

Expand Down
10 changes: 6 additions & 4 deletions etc/snmp/snmpd.template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
##################
Expand Down
2 changes: 1 addition & 1 deletion version.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 0.0.3
version: 0.0.4

0 comments on commit e5d64bf

Please sign in to comment.