From 08ee7e13988ed012ca301516d8535a875f5ea94f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20D=C3=B6rsch?= <656249+Flow86@users.noreply.github.com> Date: Fri, 16 Aug 2024 09:37:34 +0200 Subject: [PATCH 1/4] fix: do not always add service-run as argument to the entrypoint This allows the correct usage of `docker run -it paessler/multi-platform-probe example-config` --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 45edbc7..1278e99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] \ No newline at end of file From cb62a9faa3c74429149c430f0eea4bbc517b4ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20D=C3=B6rsch?= <656249+Flow86@users.noreply.github.com> Date: Fri, 16 Aug 2024 09:49:29 +0200 Subject: [PATCH 2/4] docs: add clarification on how to find all configuration file options --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 64510e8..81c5194 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ 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. From 8a15bb8d9406602f34bd79c6d36d620e92cf7081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20D=C3=B6rsch?= <656249+Flow86@users.noreply.github.com> Date: Fri, 16 Aug 2024 10:09:22 +0200 Subject: [PATCH 3/4] docs: add information on how to use a custom CA certificate and/or where to obtain it --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 81c5194..9b68f20 100644 --- a/README.md +++ b/README.md @@ -68,11 +68,24 @@ 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 From 07882452e1ea80a604521aeca0d96f00e8073514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20D=C3=B6rsch?= <656249+Flow86@users.noreply.github.com> Date: Fri, 16 Aug 2024 10:33:15 +0200 Subject: [PATCH 4/4] feat: test if the id is set in the config.yml and if so, don't generate an id.txt file aswell as not set PRTGMPPROBE__ID --- run-prtgmpprobe.sh | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/run-prtgmpprobe.sh b/run-prtgmpprobe.sh index affcb3d..68b32a3 100644 --- a/run-prtgmpprobe.sh +++ b/run-prtgmpprobe.sh @@ -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} \ "$@" @@ -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)"} @@ -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