mirror of
https://github.com/luzifer-docker/netdata.git
synced 2024-11-08 17:30:02 +00:00
Initial version at 1.7.0
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
commit
0e4ae8ccca
5 changed files with 167 additions and 0 deletions
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
|||
FROM debian:stretch
|
||||
|
||||
ENV NETDATA_PORT 19999
|
||||
EXPOSE $NETDATA_PORT
|
||||
|
||||
VOLUME /override
|
||||
|
||||
ENTRYPOINT ["/src/run.sh"]
|
||||
|
||||
ADD . /src
|
||||
RUN /src/build.sh
|
14
README.md
Normal file
14
README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Luzifer-Docker / netdata
|
||||
|
||||
This repository contains a dockerized version of the [netdata](https://github.com/firehol/netdata) daemon. It supports adding and overriding configurations and plugins through overrides.
|
||||
|
||||
The expected structure on the `/override` volume mount is as following:
|
||||
|
||||
```
|
||||
/override
|
||||
├── charts.d
|
||||
├── conf.d
|
||||
├── node.d
|
||||
├── plugins.d
|
||||
└── python.d
|
||||
```
|
44
build.sh
Executable file
44
build.sh
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
set -o pipefail
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# install dependencies for build
|
||||
|
||||
apt-get -qq update
|
||||
apt-get -y install zlib1g-dev uuid-dev libmnl-dev gcc make curl git autoconf autogen automake pkg-config netcat-openbsd jq \
|
||||
autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml \
|
||||
ssmtp mailutils apcupsd rsync
|
||||
|
||||
# fetch netdata
|
||||
|
||||
git clone https://github.com/firehol/netdata.git /netdata.git
|
||||
cd /netdata.git
|
||||
TAG=$(</src/git-tag)
|
||||
if [ ! -z "$TAG" ]; then
|
||||
echo "Checking out tag: $TAG"
|
||||
git checkout tags/$TAG
|
||||
else
|
||||
echo "No tag, using master"
|
||||
fi
|
||||
|
||||
# use the provided installer
|
||||
|
||||
./netdata-installer.sh --dont-wait --dont-start-it
|
||||
|
||||
# remove build dependencies
|
||||
|
||||
cd /
|
||||
rm -rf /netdata.git
|
||||
|
||||
apt-get purge -y zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config
|
||||
apt-get autoremove -y
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# symlink access log and error log to stdout/stderr
|
||||
|
||||
ln -sf /dev/stdout /var/log/netdata/access.log
|
||||
ln -sf /dev/stdout /var/log/netdata/debug.log
|
||||
ln -sf /dev/stderr /var/log/netdata/error.log
|
1
git-tag
Normal file
1
git-tag
Normal file
|
@ -0,0 +1 @@
|
|||
v1.7.0
|
97
run.sh
Executable file
97
run.sh
Executable file
|
@ -0,0 +1,97 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
set -o pipefail
|
||||
|
||||
# fix permissions due to netdata running as root
|
||||
chown -R root:root /usr/share/netdata/web/
|
||||
echo -n "" > /usr/share/netdata/web/version.txt
|
||||
|
||||
# set up ssmtp
|
||||
if [[ $SSMTP_TO ]] && [[ $SSMTP_USER ]] && [[ $SSMTP_PASS ]]; then
|
||||
cat << EOF > /etc/ssmtp/ssmtp.conf
|
||||
root=$SSMTP_TO
|
||||
mailhub=$SSMTP_SERVER:$SSMTP_PORT
|
||||
AuthUser=$SSMTP_USER
|
||||
AuthPass=$SSMTP_PASS
|
||||
UseSTARTTLS=$SSMTP_TLS
|
||||
hostname=$SSMTP_HOSTNAME
|
||||
FromLineOverride=NO
|
||||
EOF
|
||||
|
||||
cat << EOF > /etc/ssmtp/revaliases
|
||||
netdata:netdata@$SSMTP_HOSTNAME:$SSMTP_SERVER:$SSMTP_PORT
|
||||
root:netdata@$SSMTP_HOSTNAME:$SSMTP_SERVER:$SSMTP_PORT
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [[ $SLACK_WEBHOOK_URL ]]; then
|
||||
sed -i -e "s@SLACK_WEBHOOK_URL=\"\"@SLACK_WEBHOOK_URL=\"${SLACK_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
|
||||
fi
|
||||
|
||||
if [[ $SLACK_CHANNEL ]]; then
|
||||
sed -i -e "s@DEFAULT_RECIPIENT_SLACK=\"\"@DEFAULT_RECIPIENT_SLACK=\"${SLACK_CHANNEL}\"@" /etc/netdata/health_alarm_notify.conf
|
||||
fi
|
||||
|
||||
if [[ $TELEGRAM_BOT_TOKEN ]]; then
|
||||
sed -i -e "s@TELEGRAM_BOT_TOKEN=\"\"@TELEGRAM_BOT_TOKEN=\"${TELEGRAM_BOT_TOKEN}\"@" /etc/netdata/health_alarm_notify.conf
|
||||
fi
|
||||
|
||||
if [[ $TELEGRAM_CHAT_ID ]]; then
|
||||
sed -i -e "s@DEFAULT_RECIPIENT_TELEGRAM=\"\"@DEFAULT_RECIPIENT_TELEGRAM=\"${TELEGRAM_CHAT_ID}\"@" /etc/netdata/health_alarm_notify.conf
|
||||
fi
|
||||
|
||||
if [[ $PUSHBULLET_ACCESS_TOKEN ]]; then
|
||||
sed -i -e "s@PUSHBULLET_ACCESS_TOKEN=\"\"@PUSHBULLET_ACCESS_TOKEN=\"${PUSHBULLET_ACCESS_TOKEN}\"@" /etc/netdata/health_alarm_notify.conf
|
||||
fi
|
||||
|
||||
if [[ $PUSHBULLET_DEFAULT_EMAIL ]]; then
|
||||
sed -i -e "s#DEFAULT_RECIPIENT_PUSHBULLET=\"\"#DEFAULT_RECIPIENT_PUSHBULLET=\"${PUSHBULLET_DEFAULT_EMAIL}\"#" /etc/netdata/health_alarm_notify.conf
|
||||
fi
|
||||
|
||||
if [[ $NETDATA_IP ]]; then
|
||||
NETDATA_ARGS="${NETDATA_ARGS} -i ${NETDATA_IP}"
|
||||
fi
|
||||
|
||||
# on a client netdata set this destination to be the [PROTOCOL:]HOST[:PORT] of the
|
||||
# central netdata, and give an API_KEY that is secret and only known internally
|
||||
# to the netdata clients, and netdata central
|
||||
if [[ $NETDATA_STREAM_DESTINATION ]] && [[ $NETDATA_STREAM_API_KEY ]]; then
|
||||
cat << EOF > /etc/netdata/stream.conf
|
||||
[stream]
|
||||
enabled = yes
|
||||
destination = $NETDATA_STREAM_DESTINATION
|
||||
api key = $NETDATA_STREAM_API_KEY
|
||||
EOF
|
||||
fi
|
||||
|
||||
# set 1 or more NETADATA_API_KEY_ENABLE env variables, such as NETDATA_API_KEY_ENABLE_1h213ch12h3rc1289e=1
|
||||
# that matches the API_KEY that you used on the client above, this will enable the netdata client
|
||||
# node to communicate with the netdata central
|
||||
if printenv | grep -q 'NETDATA_API_KEY_ENABLE_'; then
|
||||
printenv | grep -oe 'NETDATA_API_KEY_ENABLE_[^=]\+' | sed 's/NETDATA_API_KEY_ENABLE_//' | xargs -n1 -I{} echo '['{}$']\n\tenabled = yes' >> /etc/netdata/stream.conf
|
||||
fi
|
||||
|
||||
# exec custom command
|
||||
if [[ $# -gt 0 ]] ; then
|
||||
exec "$@"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ -d "/fakenet/" ]]; then
|
||||
echo "Running fakenet config reload in background"
|
||||
( sleep 10 ; curl -s http://localhost:${NETDATA_PORT}/netdata.conf | sed -e 's/# filename/filename/g' | sed -e 's/\/host\/proc\/net/\/fakenet\/proc\/net/g' > /etc/netdata/netdata.conf ; pkill -9 netdata ) &
|
||||
/usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT}
|
||||
# add some artificial sleep because netdata might think it can't bind to $NETDATA_PORT
|
||||
# and report things like "netdata: FATAL: Cannot listen on any socket. Exiting..."
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# Pull in overrides and additions for config and plugins
|
||||
[ -e /override/conf.d ] && rsync -arv /override/conf.d/ /etc/netdata/
|
||||
for dir in charts.d node.d plugins.d python.d; do
|
||||
[ -e "/override/${dir}" ] && rsync -arv "/override/${dir}/" "/usr/libexec/netdata/${dir}/"
|
||||
done
|
||||
|
||||
# main entrypoint
|
||||
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS}
|
Loading…
Reference in a new issue