-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from testainers/dev
Version 0.0.3.
- Loading branch information
Showing
7 changed files
with
259 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
etc/snmp/snmpd_default.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,37 +31,53 @@ Obrigado pelo seu apoio contínuo! | |
|
||
## Environment Variables | ||
|
||
| Variable | Options | Default | | ||
|-----------------------|-----------------|---------| | ||
| 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 | -- | 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 | -- | -- | | ||
|
||
## How to Use | ||
|
||
### Only SNMPv2c | ||
|
||
Run: | ||
|
||
```shell | ||
docker run --rm --name snmpd -p 5161:161/udp -d testainers/snmpd-container:latest | ||
docker run -d --rm --name snmpd -p 5161:161/udp testainers/snmpd-container:latest | ||
``` | ||
|
||
## How to Connect | ||
Test: | ||
|
||
```shell | ||
snmpwalk -v2c -c public 127.0.0.1:5161 . | ||
``` | ||
|
||
--- | ||
|
||
## Build | ||
## Local Image Build | ||
|
||
Build: | ||
|
||
```shell | ||
docker build . --no-cache -t snmpd-container | ||
``` | ||
|
||
## Run | ||
Run: | ||
|
||
```shell | ||
docker run -d --rm --name snmpd -p 5161:161/udp snmpd-container | ||
``` | ||
|
||
Access: | ||
|
||
```shell | ||
docker run --rm --name snmpd -p 5161:161/udp -d snmpd-container | ||
docker exec -it snmpd sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,22 +26,38 @@ create_user_auth_priv() { | |
echo "$SNMP_V3_USER_TYPE $SNMP_V3_USER priv" >'/usr/share/snmp/snmpd.conf' | ||
} | ||
|
||
if [ -z "$SNMP_COMMUNITY" ]; then | ||
export SNMP_COMMUNITY="public" | ||
fi | ||
|
||
if [ -z "$SNMP_LOCATION" ]; then | ||
export SNMP_LOCATION="At flying circus" | ||
fi | ||
|
||
if [ -z "$SNMP_CONTACT" ]; then | ||
export SNMP_CONTACT="Testainers <[email protected]>" | ||
fi | ||
|
||
if [ -z "$SNMP_SERVICES" ]; then | ||
export SNMP_SERVICES="72" | ||
fi | ||
|
||
if [ -z "$SNMP_V3_USER_TYPE" ]; then | ||
SNMP_V3_USER_TYPE="rouser" | ||
export SNMP_V3_USER_TYPE="rouser" | ||
fi | ||
|
||
if [ "$SNMP_V3_USER_TYPE" != "rwuser" ] && [ "$SNMP_V3_USER_TYPE" != "rouser" ]; then | ||
echo "SNMP_V3_USER_TYPE is not correct" | ||
echo "Updating from '$SNMP_V3_USER_TYPE' to 'rouser'" | ||
SNMP_V3_USER_TYPE="rouser" | ||
export SNMP_V3_USER_TYPE="rouser" | ||
fi | ||
|
||
if [ -z "$SNMP_V3_AUTH_PROTOCOL" ]; then | ||
SNMP_V3_AUTH_PROTOCOL="SHA" | ||
export SNMP_V3_AUTH_PROTOCOL="SHA" | ||
fi | ||
|
||
if [ -z "$SNMP_V3_PRIV_PROTOCOL" ]; then | ||
SNMP_V3_PRIV_PROTOCOL="AES" | ||
export SNMP_V3_PRIV_PROTOCOL="AES" | ||
fi | ||
|
||
if [ -n "$SNMP_V3_USER" ]; then | ||
|
@@ -61,6 +77,10 @@ else | |
echo "User not created" | ||
fi | ||
|
||
envsubst <'/etc/snmp/snmpd.template.conf' >'/etc/snmp/snmpd.conf' | ||
|
||
rm -f '/etc/snmp/snmpd.template.conf' | ||
|
||
### Start snmpd. | ||
# /usr/sbin/snmpd -f -Lo -C -c /etc/snmp/snmpd.conf | ||
/usr/sbin/snmpd -f -Lo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,17 +47,17 @@ view systemonly included .1.3.6.1.2.1.1 | |
view systemonly included .1.3.6.1.2.1.25.1 | ||
|
||
# Full access from the local host | ||
#rocommunity public localhost | ||
#rocommunity ${SNMP_COMMUNITY} localhost | ||
# Default access to basic system info | ||
#rocommunity public default -V systemonly | ||
#rocommunity ${SNMP_COMMUNITY} default -V systemonly | ||
|
||
# Full access from an example network | ||
# Adjust this network address to match your local | ||
# settings, change the community string, | ||
# and check the 'agentAddress' setting above | ||
#rocommunity secret 10.0.0.0/16 | ||
|
||
rocommunity public default | ||
rocommunity ${SNMP_COMMUNITY} default | ||
|
||
# Full read-only access for SNMPv3 | ||
#rouser authOnlyUser | ||
|
@@ -77,10 +77,10 @@ rocommunity public default | |
|
||
# Note that setting these values here, results in the corresponding MIB objects being 'read-only' | ||
# See snmpd.conf(5) for more details | ||
sysLocation At flying circus | ||
sysContact Testainers <[email protected]> | ||
sysLocation ${SNMP_LOCATION} | ||
sysContact ${SNMP_CONTACT} | ||
# Application + End-to-End layers | ||
sysServices 72 | ||
sysServices ${SNMP_SERVICES} | ||
|
||
|
||
# | ||
|
@@ -126,11 +126,11 @@ load 12 10 5 | |
# | ||
|
||
# send SNMPv1 traps | ||
trapsink localhost public | ||
trapsink localhost ${SNMP_COMMUNITY} | ||
# send SNMPv2c traps | ||
#trap2sink localhost public | ||
#trap2sink localhost ${SNMP_COMMUNITY} | ||
# send SNMPv2c INFORMs | ||
#informsink localhost public | ||
#informsink localhost ${SNMP_COMMUNITY} | ||
|
||
# Note that you typically only want *one* of these three lines | ||
# Uncommenting two (or all three) will result in multiple copies of each notification. | ||
|
Oops, something went wrong.