Skip to content

Commit

Permalink
Merge pull request #1 from PaesslerAG/fix/entrypoint_service_run
Browse files Browse the repository at this point in the history
Adapt entrypoint and README
  • Loading branch information
Flow86 authored Sep 13, 2024
2 parents 29af404 + 0788245 commit 19ee055
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ VOLUME [ "/config", "/opt/paessler/share/scripts" ]
# set WORKDIR to a sane default
WORKDIR /

ENTRYPOINT [ "/run-prtgmpprobe.sh", "service-run" ]
ENTRYPOINT [ "/run-prtgmpprobe.sh" ]
CMD [ "service-run" ]
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,26 @@ nats:
```
You must put the configuration file into the `/config/config.yml` volume of the docker container.
For all available configuration options, see [config.full-example.yml](./config/config.full-example.yml).

ℹ️ The container also used the `/config` volume to store the [multi-platform probe's GID][GID] and therefore cannot be set as read-only (`:ro`) unless you specify the GID as an environment variable.
ℹ️ If necessary you can put your custom [CA certificate][TLS] into `/config/certs` and specify it in the `/config/config.yml` as well:

```yaml
access_key: YOUR_PROBE_ACCESS_KEY
nats:
url: tls://localhost:23561
authentication:
user: USER
password: PASSWORD
server_ca: /config/certs/ca.crt
```

ℹ️ The container also used the `/config` volume to store the [multi-platform probe's GID][GID] and therefore cannot be set as read-only (`:ro`) unless you specify the [multi-platform probe's GID][GID] as an environment variable.

You can also use the `/opt/paessler/share/scripts` volume for the scripts of the [Script v2][prtgmanual:scriptv2] sensor.

[prtgmanual:scriptv2]: https://www.paessler.com/manuals/prtg/script_v2_sensor
[TLS]: https://kb.paessler.com/en/topic/91877-how-can-i-create-a-tls-certificate
[GID]: https://www.paessler.com/manuals/prtg/prtg_administration_tool_on_remote_probe_systems#:~:text=GID

```sh
Expand Down
44 changes: 23 additions & 21 deletions run-prtgmpprobe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ do
;;
esac
done
if [ ! $_passthrough -eq 0 ] ; then
if [ $_passthrough -neq 0 ] ; then
exec gosu paessler_mpprobe:paessler_mpprobe \
${PRTGMPPROBE__BINARY} \
"$@"
Expand All @@ -42,19 +42,29 @@ done

# Handling Env vars

# Get/Generate a probe id from PRTGMPPROBE__ID_FILE or from PRTGMPPROBE__ID
if [ -z "${PRTGMPPROBE__ID-}" ] ; then
if [ ! -f "${PRTGMPPROBE__ID_FILE}" ] ; then
cat /proc/sys/kernel/random/uuid > ${PRTGMPPROBE__ID_FILE} || (
error "Unable to write to ${PRTGMPPROBE__ID_FILE}. Please either set PRTGMPPROBE__ID in the container environment or make sure the location ${PRTGMPPROBE__ID_FILE} is writable."
echo >&2 " "
echo >&2 "Example:"
echo >&2 "PRTGMPPROBE__ID=$(cat /proc/sys/kernel/random/uuid)"
exit 1
)
if [ ! -f "${PRTGMPPROBE__CONFIG_FILE}" ] ; then
error "Configuration file ${PRTGMPPROBE__CONFIG_FILE} does not exist. Please create one."
echo >&2 " "
echo >&2 "Example:"
${PRTGMPPROBE__BINARY} example-config >&2
exit 1
fi

# Get/Generate a probe id from PRTGMPPROBE__ID_FILE or from PRTGMPPROBE__ID if not set in PRTGMPPROBE__CONFIG_FILE
if [ ! grep -q "^id:" "${PRTGMPPROBE__CONFIG_FILE}" ] ; then
if [ -z "${PRTGMPPROBE__ID-}" ] ; then
if [ ! -f "${PRTGMPPROBE__ID_FILE}" ] ; then
cat /proc/sys/kernel/random/uuid > ${PRTGMPPROBE__ID_FILE} || (
error "Unable to write to ${PRTGMPPROBE__ID_FILE}. Please either set PRTGMPPROBE__ID in the container environment, 'id:' in the ${PRTGMPPROBE__CONFIG_FILE} or make sure the location ${PRTGMPPROBE__ID_FILE} is writable."
echo >&2 " "
echo >&2 "Example:"
echo >&2 "PRTGMPPROBE__ID=$(cat /proc/sys/kernel/random/uuid)"
exit 1
)
fi
PRTGMPPROBE__ID=$(cat ${PRTGMPPROBE__ID_FILE})
export PRTGMPPROBE__ID
fi
PRTGMPPROBE__ID=$(cat ${PRTGMPPROBE__ID_FILE})
export PRTGMPPROBE__ID
fi

export PRTGMPPROBE__NAME=${PRTGMPPROBE__NAME:-"multi-platform-probe@$(hostname)"}
Expand All @@ -70,14 +80,6 @@ export PRTGMPPROBE__LOGGING__CONSOLE__WITHOUT_TIME=${PRTGMPPROBE__LOGGING__CONSO
export PRTGMPPROBE__LOGGING__JOURNALD__LEVEL=${PRTGMPPROBE__LOGGING__JOURNALD__FIELD_PREFIX:-"off"}
export PRTGMPPROBE__LOGGING__JOURNALD__FIELD_PREFIX=${PRTGMPPROBE__LOGGING__JOURNALD__FIELD_PREFIX:-"PRTGMPPROBE"}

if [ ! -f "${PRTGMPPROBE__CONFIG_FILE}" ] ; then
error "Configuration file ${PRTGMPPROBE__CONFIG_FILE} does not exist. Please create one."
echo >&2 " "
echo >&2 "Example:"
${PRTGMPPROBE__BINARY} example-config >&2
exit 1
fi

env | grep PRTGMPPROBE__ >&2

# add capabilities for icmp to the probe executable
Expand Down

0 comments on commit 19ee055

Please sign in to comment.