From 39eb9939cef59c87528e6e5581780e159aed3692 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 9 Aug 2021 17:08:25 +0200 Subject: [PATCH] ddsa --- collectd.env | 22 +++-- collectd/Dockerfile | 13 ++- collectd/root/entrypoint.sh | 43 +++++++-- .../collectd/templates/collectd.conf.template | 38 -------- .../collectd.conf.template.base.part | 4 + .../templates/collectd.plugin.network.part | 6 ++ .../templates/collectd.plugin.python.end.part | 1 + .../collectd.plugin.python.fritz.part | 11 +++ .../collectd.plugin.python.start.part | 4 + .../collectd.plugin.write_graphite.part | 18 ++++ volumes/grafana/data/grafana.db | Bin 1191936 -> 1191936 bytes volumes/grafana/logs/grafana.log | 84 ++++++++++++++++++ 12 files changed, 191 insertions(+), 53 deletions(-) create mode 100644 collectd/root/srv/collectd/templates/collectd.conf.template.base.part create mode 100644 collectd/root/srv/collectd/templates/collectd.plugin.network.part create mode 100644 collectd/root/srv/collectd/templates/collectd.plugin.python.end.part create mode 100644 collectd/root/srv/collectd/templates/collectd.plugin.python.fritz.part create mode 100644 collectd/root/srv/collectd/templates/collectd.plugin.python.start.part create mode 100644 collectd/root/srv/collectd/templates/collectd.plugin.write_graphite.part diff --git a/collectd.env b/collectd.env index 2c4b4e2..7e6125b 100644 --- a/collectd.env +++ b/collectd.env @@ -1,7 +1,19 @@ TZ=Europe/Berlin -FRITZ_IP=192.168.1.1 -FRITZ_USER=collectd -FRITZ_PASSWORD=ec2ruRlOhFqpDPw0 -EP_HOST=influxdb -EP_PORT=25826 +P_NETWORK_ENABLED=true +P_NETWORK_HOST=influxdb +P_NETWORK_PORT=25826 + +P_PYTHON_ENABLED=true + +P_PYTHON_FRITZ_ENABLED=true +P_PYTHON_FRITZ_HOST=192.168.1.1 +P_PYTHON_FRITZ_PORT=49000 +P_PYTHON_FRITZ_USER=collectd +P_PYTHON_FRITZ_PASSWORD=ec2ruRlOhFqpDPw0 + +P_WGRAPHITE_ENABLED=false +P_WGRAPHITE_NODE=FritzBoxTest +P_WGRAPHITE_HOST=graphite +P_WGRAPHITE_PORT=2003 +P_WGRAPHITE_PROTO=tcp diff --git a/collectd/Dockerfile b/collectd/Dockerfile index 6e5dc7d..ab25b87 100644 --- a/collectd/Dockerfile +++ b/collectd/Dockerfile @@ -1,8 +1,15 @@ FROM alpine:latest -RUN apk --no-cache add collectd collectd-python collectd-network gettext \ - py3-pip libxslt-dev gcc musl-dev python3-dev tzdata && \ - pip3 install --no-cache-dir fritzcollectd +RUN apk --no-cache add collectd collectd-python collectd-network tzdata \ + py3-pip gettext && \ + apk add --no-cache --virtual .build-deps \ + git libxslt-dev gcc musl-dev python3-dev && \ + git clone --depth 1 https://github.com/fetzerch/fritzcollectd.git && \ + cd fritzcollectd && \ + pip3 install --no-cache-dir . && \ + apk del .build-deps && \ + rm -rf .git/ && \ + apk --no-cache add libxslt COPY ./root / diff --git a/collectd/root/entrypoint.sh b/collectd/root/entrypoint.sh index de0b499..2b8ba06 100755 --- a/collectd/root/entrypoint.sh +++ b/collectd/root/entrypoint.sh @@ -3,13 +3,42 @@ # Exit at first error set -e -mkdir -p /srv/collectd/config +CONFIG_DIR=/srv/collectd/config +TEMPLATES_DIR="/srv/collectd/templates" -# Fill the varibles in funkwhale.template and put the result in default.conf -echo "Generating '/srv/collectd/config/collectd.conf'..." -envsubst < \ - /srv/collectd/templates/collectd.conf.template > \ - /srv/collectd/config/collectd.conf +mkdir -p "${CONFIG_DIR}" +echo "Generating '/srv/collectd/templates/collectd.conf.template'..." + +cat "${TEMPLATES_DIR}/collectd.conf.template.base.part" > \ + "${TEMPLATES_DIR}/collectd.conf.template" + +if [ "${P_NETWORK_ENABLED}" = "true" ]; then + cat "${TEMPLATES_DIR}/collectd.plugin.network.part" >> \ + "${TEMPLATES_DIR}/collectd.conf.template" +fi + +if [ "${P_PYTHON_ENABLED}" = "true" ]; then + cat "${TEMPLATES_DIR}/collectd.plugin.python.start.part" >> \ + "${TEMPLATES_DIR}/collectd.conf.template" + + if [ "${P_PYTHON_FRITZ_ENABLED}" = "true" ]; then + cat "${TEMPLATES_DIR}/collectd.plugin.python.fritz.part" >> \ + "${TEMPLATES_DIR}/collectd.conf.template" + fi + + cat "${TEMPLATES_DIR}/collectd.plugin.python.end.part" >> \ + "${TEMPLATES_DIR}/collectd.conf.template" +fi + +if [ "${P_WGRAPHITE_ENABLED}" = "true" ]; then + cat "${TEMPLATES_DIR}/collectd.plugin.write_graphite.part" >> \ + "${TEMPLATES_DIR}/collectd.conf.template" +fi + +# Fill the varibles in collectd.conf.template and put the result in collectd.conf +echo "Generating '${CONFIG_DIR}/collectd.conf'..." +envsubst < /srv/collectd/templates/collectd.conf.template > \ + "${CONFIG_DIR}/collectd.conf" echo "Starting collectd..." -collectd -C /srv/collectd/config/collectd.conf -f +collectd -C "${CONFIG_DIR}/collectd.conf" -f diff --git a/collectd/root/srv/collectd/templates/collectd.conf.template b/collectd/root/srv/collectd/templates/collectd.conf.template index ede81bb..2340f60 100644 --- a/collectd/root/srv/collectd/templates/collectd.conf.template +++ b/collectd/root/srv/collectd/templates/collectd.conf.template @@ -2,41 +2,3 @@ FQDNLookup true Interval 10 Timeout 2 ReadThreads 5 - -LoadPlugin python -LoadPlugin network -LoadPlugin "write_graphite" - - - Server "${EP_HOST}" "${EP_PORT}" - - - - Import "fritzcollectd" - - - Address "${FRITZ_IP}" - Port 49000 - User "${FRITZ_USER}" - Password "${FRITZ_PASSWORD}" - Hostname "FritzBox" - Instance "1" - Verbose "False" - - - - - - Host "graphite" - Port "2003" - #Prefix "collectd." - #Postfix "" - #Protocol "udp" - #LogSendErrors false - EscapeCharacter "_" - SeparateInstances true - StoreRates false - AlwaysAppendDS false - #UseTags false - - diff --git a/collectd/root/srv/collectd/templates/collectd.conf.template.base.part b/collectd/root/srv/collectd/templates/collectd.conf.template.base.part new file mode 100644 index 0000000..2340f60 --- /dev/null +++ b/collectd/root/srv/collectd/templates/collectd.conf.template.base.part @@ -0,0 +1,4 @@ +FQDNLookup true +Interval 10 +Timeout 2 +ReadThreads 5 diff --git a/collectd/root/srv/collectd/templates/collectd.plugin.network.part b/collectd/root/srv/collectd/templates/collectd.plugin.network.part new file mode 100644 index 0000000..527dbae --- /dev/null +++ b/collectd/root/srv/collectd/templates/collectd.plugin.network.part @@ -0,0 +1,6 @@ + +LoadPlugin network + + + Server "${P_NETWORK_HOST}" "${P_NETWORK_PORT}" + diff --git a/collectd/root/srv/collectd/templates/collectd.plugin.python.end.part b/collectd/root/srv/collectd/templates/collectd.plugin.python.end.part new file mode 100644 index 0000000..25a1eed --- /dev/null +++ b/collectd/root/srv/collectd/templates/collectd.plugin.python.end.part @@ -0,0 +1 @@ + diff --git a/collectd/root/srv/collectd/templates/collectd.plugin.python.fritz.part b/collectd/root/srv/collectd/templates/collectd.plugin.python.fritz.part new file mode 100644 index 0000000..f2d7b33 --- /dev/null +++ b/collectd/root/srv/collectd/templates/collectd.plugin.python.fritz.part @@ -0,0 +1,11 @@ + Import "fritzcollectd" + + + Address "${P_PYTHON_FRITZ_HOST}" + Port "${P_PYTHON_FRITZ_PORT}" + User "${P_PYTHON_FRITZ_USER}" + Password "${P_PYTHON_FRITZ_PASSWORD}" + Hostname "FritzBox" + Instance "1" + Verbose "False" + diff --git a/collectd/root/srv/collectd/templates/collectd.plugin.python.start.part b/collectd/root/srv/collectd/templates/collectd.plugin.python.start.part new file mode 100644 index 0000000..df3f779 --- /dev/null +++ b/collectd/root/srv/collectd/templates/collectd.plugin.python.start.part @@ -0,0 +1,4 @@ + +LoadPlugin python + + diff --git a/collectd/root/srv/collectd/templates/collectd.plugin.write_graphite.part b/collectd/root/srv/collectd/templates/collectd.plugin.write_graphite.part new file mode 100644 index 0000000..8e14363 --- /dev/null +++ b/collectd/root/srv/collectd/templates/collectd.plugin.write_graphite.part @@ -0,0 +1,18 @@ + +LoadPlugin "write_graphite" + + + + Host "${P_WGRAPHITE_HOST}" + Port "${P_WGRAPHITE_PORT}" + #Prefix "collectd." + #Postfix "" + Protocol "${P_WGRAPHITE_PROTO}" + #LogSendErrors false + EscapeCharacter "_" + SeparateInstances true + StoreRates false + AlwaysAppendDS false + #UseTags false + + diff --git a/volumes/grafana/data/grafana.db b/volumes/grafana/data/grafana.db index 70ef9f0efb8bcbdf44380465a58c69d199b0136c..c65682cfedad47ad4709467adcf8f0c4e84fa422 100644 GIT binary patch delta 552 zcmZp8;L-5FV}dl}^@%dhjMq0NwCFMNZ+@yLXvk%$U}$1xWMpMv(3G$(fsykA`$zuE z{73j7Z5DLc!aw~;Jd+WZrH`kfX{ft-75}ybrloR>{L`1!F-@)qYc({rGBh?aFf!CN zu+TL?2vsYU43H5WTxhoK(!?sq~!XCW*7yBB%9>;1({fsnOnF7`XyzQX-8RlWVvUSrIq9& z>+?>n1lksu>sI7vR1p>I;^>r9neP=Ck)0hCW$9~@T9E2tnwp!JQ;?-p3-{Hw2B!b~ zjQrasK&S;^s%-;P+Xm*g4J>UNShsCp+fdKSk|=0VG<~Z+y8>%kqM(b`_FMYwHu?^U zDdr|=X{MIOMrMg=CW)p7$*C!p=BZ{W<|$?-X$A(#My3{~DaJsysX>~Ng`s(xxv_y| zQc`NNiG_hhs_FCt`RoqUr^T~JvkO{W1=?|G`;U0`6Z{k#ye)y9O`x5vfgOlBfS41A bxqz4(h-A*wzD+|{#p+JDAKKE delta 548 zcmZp8;L-5FV}dl}$%!(~j3+lHwCFMNZGNgJXvk%uU}S7%Vq|4v-juK{fsykA`(^$k z{EzrQZWeUd!aw~;Jd+VuyiZD2psRacHs7`crloR>eAAcJF-@)qYc)2oGBz?YFf!CN zumB>EX<(shrIMUtXGiDMq7o%5rKIo@@8DcFw?u=K;vi3>utE#Z%z$)fr>a8pR0|L1 z+;DHVJS82lmYmGgyb`Fk@ERQ_5%Dj-= z3}k)Ysg*$6f(&zlQVdK?!dxpOyv;*hjVirzasw0neUmHP)6$KNEb_B5m1^O>+Sb7I zpP!L$+XM);08F)QU~1dI+_r(GZ3FAJ4Qw0gS(y_B5++UGs?V;#nwTh%U9kO@KD&+n z^aJ(m4h}|!My4jo7Di^4X@;hz21yncX-TF@<|Zj-CWdClDJe-NCTWIAsfMO$i782j zW{KvO#-