This commit is contained in:
Zakary Timson 2022-06-02 15:09:23 -04:00
parent 2a5179cf74
commit 7386ea1274
3 changed files with 5 additions and 10 deletions

View File

@ -1,7 +1,6 @@
FROM prom/node-exporter:latest FROM prom/node-exporter:latest
USER root
COPY entrypoint.sh /etc/node-exporter/ COPY entrypoint.sh /etc/node-exporter/
RUN chmod +x /etc/node-exporter/entrypoint.sh ENTRYPOINT ["sh", "/etc/node-exporter/entrypoint.sh"]
CMD ["/bin/node_exporter"]
ENTRYPOINT [ "/etc/node-exporter/docker-entrypoint.sh" ]
CMD [ "/bin/node_exporter" ]

View File

@ -4,7 +4,7 @@ This is a copy of [prom/node-exporter](https://hub.docker.com/r/prom/node-export
## Example ## Example
For the hostname to be detected, you must load the host filesystem into the container's `/host` directory as seen here. For the hostname to be detected, you must mount the host's `rootfs` into the container's `/host` directory as seen here:
``` ```
version: '3.8' version: '3.8'
@ -21,5 +21,3 @@ services:
deploy: deploy:
mode: global mode: global
``` ```
Otherwise use the `$HOSTNAME` variable to specify the path to the *hostname file* & ensure it's mounted.

View File

@ -1,8 +1,6 @@
#!/bin/sh #!/bin/sh
if [ -z "$HOSTNAME" ]; then $HOSTNAME="/host/hostname"; fi NODE_NAME=$(cat "/host/etc/hostname")
NODE_NAME=$(cat "$HOSTNAME")
echo "node_meta{node_name=\"$NODE_NAME\"} 1" > /etc/node-exporter/node-meta.prom echo "node_meta{node_name=\"$NODE_NAME\"} 1" > /etc/node-exporter/node-meta.prom
set -- /bin/node_exporter "$@" set -- /bin/node_exporter "$@"
exec "$@" exec "$@"