Skip to content

Commit

Permalink
fixup collectd.conf (#233)
Browse files Browse the repository at this point in the history
the container customizations done in Dockerfile were somewhat broken
when adding the hide system graphs option

fix that by doing the customizations in graphs1090-init
  • Loading branch information
wiedehopf authored Oct 4, 2024
1 parent 4212e07 commit b2c0052
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
27 changes: 2 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,7 @@ RUN \
&& \
# ref: https://github.com/wiedehopf/graphs1090/blob/151e63a810d6b087518992d4f366d9776c5c826b/install.sh#L148
chmod -v a+x /usr/share/graphs1090/*.sh && \
# ref: https://github.com/wiedehopf/graphs1090/blob/151e63a810d6b087518992d4f366d9776c5c826b/install.sh#L151
cp -v \
/usr/share/graphs1090/git/collectd.conf \
/etc/collectd/collectd.conf \
&& \
# ref: https://github.com/wiedehopf/graphs1090/blob/151e63a810d6b087518992d4f366d9776c5c826b/install.sh#L171
sed -i '/<Plugin "interface">/a\ \ \ \ Interface "eth0"' /etc/collectd/collectd.conf && \
# collectd.conf customization done in graphs1090-init
# ref: https://github.com/wiedehopf/graphs1090/blob/151e63a810d6b087518992d4f366d9776c5c826b/install.sh#L179
cp -rv \
/usr/share/graphs1090/git/html \
Expand All @@ -130,22 +124,6 @@ RUN \
mkdir -p /usr/share/graphs1090/data-symlink && \
# ref: https://github.com/wiedehopf/graphs1090/blob/151e63a810d6b087518992d4f366d9776c5c826b/install.sh#L217
ln -vsnf /run/readsb /usr/share/graphs1090/data-symlink/data && \
# ref: https://github.com/wiedehopf/graphs1090/blob/151e63a810d6b087518992d4f366d9776c5c826b/install.sh#L218
sed -i -e 's?URL .*?URL "file:///usr/share/graphs1090/data-symlink"?' /etc/collectd/collectd.conf && \
## Lines below merge the tar1090 collectd config with the graphs1090 collectd config
# remove the default syslog config in collectd.conf
sed -i '/<Plugin\ syslog>/,/<\/Plugin>/d' /etc/collectd/collectd.conf && \
# replace syslog plugin with logfile plugin in collectd.conf
sed -i 's/LoadPlugin\ syslog/LoadPlugin logfile/' /etc/collectd/collectd.conf && \
# add configuration to log to STDOUT in collectd.conf ("/a" == append lines after match)
sed -i '/LoadPlugin\ logfile/a\\n<Plugin\ logfile>\n<\/Plugin>' /etc/collectd/collectd.conf && \
sed -i '/<Plugin\ logfile>/a\ \ \ \ PrintSeverity\ true' /etc/collectd/collectd.conf && \
sed -i '/<Plugin\ logfile>/a\ \ \ \ Timestamp\ false' /etc/collectd/collectd.conf && \
sed -i '/<Plugin\ logfile>/a\ \ \ \ File\ STDOUT' /etc/collectd/collectd.conf && \
sed -i '/<Plugin\ logfile>/a\ \ \ \ LogLevel\ "notice"' /etc/collectd/collectd.conf && \
# add tar1090 specific stuff
sed -i '$a\\n' /etc/collectd/collectd.conf && \
sed -i '$aFQDNLookup\ true' /etc/collectd/collectd.conf && \
# set up base telegraf config directories
##telegraf##mkdir -p /etc/telegraf/telegraf.d && \
# document telegraf version
Expand All @@ -158,8 +136,7 @@ RUN \
bash -ec 'echo "$(TZ=UTC date +%Y%m%d-%H%M%S)_$(git rev-parse --short HEAD)_$(git branch --show-current)" > /.CONTAINER_VERSION' && \
popd && \
# Clean-up.
apt-get remove -y ${TEMP_PACKAGES[@]} && \
apt-get autoremove -q -o APT::Autoremove::RecommendsImportant=0 -o APT::Autoremove::SuggestsImportant=0 -y && \
apt-get autoremove -q -o APT::Autoremove::RecommendsImportant=0 -o APT::Autoremove::SuggestsImportant=0 -y ${TEMP_PACKAGES[@]} && \
apt-get clean -q -y && \
rm -rf /src/* /tmp/* /var/lib/apt/lists/* /var/cache/* && \
# document versions
Expand Down
21 changes: 21 additions & 0 deletions rootfs/etc/s6-overlay/startup.d/08-graphs1090-init
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ else
cp /usr/share/graphs1090/git/collectd.conf /etc/collectd/collectd.conf
fi

# ref: https://github.com/wiedehopf/graphs1090/blob/151e63a810d6b087518992d4f366d9776c5c826b/install.sh#L171
sed -i '/<Plugin "interface">/a\ \ \ \ Interface "eth0"' /etc/collectd/collectd.conf
# ref: https://github.com/wiedehopf/graphs1090/blob/151e63a810d6b087518992d4f366d9776c5c826b/install.sh#L218
sed -i -e 's?URL .*?URL "file:///usr/share/graphs1090/data-symlink"?' /etc/collectd/collectd.conf
## Lines below merge the tar1090 collectd config with the graphs1090 collectd config
# remove the default syslog config in collectd.conf
sed -i '/<Plugin\ syslog>/,/<\/Plugin>/d' /etc/collectd/collectd.conf
# replace syslog plugin with logfile plugin in collectd.conf
sed -i 's/LoadPlugin\ syslog/LoadPlugin logfile/' /etc/collectd/collectd.conf
# add configuration to log to STDOUT in collectd.conf ("/a" == append lines after match)
sed -i '/LoadPlugin\ logfile/a\\n<Plugin\ logfile>\n<\/Plugin>' /etc/collectd/collectd.conf
sed -i '/<Plugin\ logfile>/a\ \ \ \ PrintSeverity\ true' /etc/collectd/collectd.conf
sed -i '/<Plugin\ logfile>/a\ \ \ \ Timestamp\ false' /etc/collectd/collectd.conf
sed -i '/<Plugin\ logfile>/a\ \ \ \ File\ STDOUT' /etc/collectd/collectd.conf
sed -i '/<Plugin\ logfile>/a\ \ \ \ LogLevel\ "notice"' /etc/collectd/collectd.conf
# add tar1090 specific stuff
# shellcheck disable=SC2016
sed -i '$a\\n' /etc/collectd/collectd.conf
# shellcheck disable=SC2016
sed -i '$aFQDNLookup\ true' /etc/collectd/collectd.conf

# Disable a few graphs based on parameter settings:
if chk_enabled "${GRAPHS1090_DISABLE_CHART_CPU}"; then
sed -i '/^\s*<div class="column text-center">$/{$!{N;s/\(<div class="column text-center"\)\(>\n\s*<a id ="system-cpu-link"\)/\1 style="display:none"\2/;t;P;D}}' /usr/share/graphs1090/html/index.html
Expand Down

0 comments on commit b2c0052

Please sign in to comment.