Skip to content

Commit b738bf9

Browse files
authored
Merge pull request #394 from Paraphraser/20210823-telegraf-master
20210823 Telegraf - master branch - PR 1 of 3
2 parents 38999a6 + dff7b81 commit b738bf9

File tree

6 files changed

+292
-392
lines changed

6 files changed

+292
-392
lines changed

.templates/telegraf/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Download base image
2+
FROM telegraf:latest
3+
4+
# Add support tool
5+
RUN apt update && apt install -y rsync
6+
7+
# where IOTstack template files are stored
8+
ENV IOTSTACK_DEFAULTS_DIR="iotstack_defaults"
9+
10+
# make a copy of the default config file
11+
RUN mkdir -p /${IOTSTACK_DEFAULTS_DIR} && \
12+
cp /etc/telegraf/telegraf.conf /${IOTSTACK_DEFAULTS_DIR}/
13+
14+
# replace the docker entry-point script with a self-repairing version
15+
ENV IOTSTACK_ENTRY_POINT="entrypoint.sh"
16+
COPY ${IOTSTACK_ENTRY_POINT} /${IOTSTACK_ENTRY_POINT}
17+
RUN chmod 755 /${IOTSTACK_ENTRY_POINT}
18+
ENV IOTSTACK_ENTRY_POINT=
19+
20+
# IOTstack declares this path for persistent storage
21+
VOLUME ["/etc/telegraf"]
22+
23+
# EOF

.templates/telegraf/build.py

Lines changed: 0 additions & 153 deletions
This file was deleted.

.templates/telegraf/entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ "${1:0:1}" = '-' ]; then
5+
set -- telegraf "$@"
6+
fi
7+
8+
# perform IOTstack self-repair
9+
U="$(id -u)"
10+
T="/etc/telegraf"
11+
if [ "$U" = '0' -a -d "$T" ]; then
12+
rsync -arp --ignore-existing /${IOTSTACK_DEFAULTS_DIR}/ "$T"
13+
chown -R "$U:$U" "$T"
14+
fi
15+
16+
exec "$@"
17+
18+

.templates/telegraf/service.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
telegraf:
22
container_name: telegraf
3-
image: telegraf
3+
build: ./.templates/telegraf/.
44
restart: unless-stopped
5+
environment:
6+
- TZ=Etc/UTC
7+
ports:
8+
- "8092:8092/udp"
9+
- "8094:8094/tcp"
10+
- "8125:8125/udp"
511
volumes:
6-
- ./services/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
12+
- ./volumes/telegraf/:/etc/telegraf
713
depends_on:
814
- influxdb
915
- mosquitto
1016
networks:
1117
- iotstack_nw
18+

0 commit comments

Comments
 (0)