Full Code of titpetric/netdata for AI

master 0ce01519712d cached
43 files
79.4 KB
24.0k tokens
1 requests
Download .txt
Repository: titpetric/netdata
Branch: master
Commit: 0ce01519712d
Files: 43
Total size: 79.4 KB

Directory structure:
gitextract_mmhg773n/

├── .gitignore
├── LICENSE
├── README.md
├── docker-compose.yml
├── fakenet.sh
├── package.json
├── releases/
│   ├── dev/
│   │   ├── Dockerfile.build
│   │   ├── Dockerfile.run
│   │   └── Makefile
│   ├── latest/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.10.0/
│   │   ├── Dockerfile
│   │   ├── README.md
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.4.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.5.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.6.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.7.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.8.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   └── v1.9.0/
│       ├── Dockerfile
│       ├── git-tag
│       └── scripts/
│           ├── build.sh
│           └── run.sh
└── update-releases.sh

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
/update-releases.json

================================================
FILE: LICENSE
================================================
Creative Commons Legal Code

CC0 1.0 Universal

    CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
    LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
    ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
    INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
    REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
    PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
    THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
    HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.

For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:

  i. the right to reproduce, adapt, distribute, perform, display,
     communicate, and translate a Work;
 ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
     likeness depicted in a Work;
 iv. rights protecting against unfair competition in regards to a Work,
     subject to the limitations in paragraph 4(a), below;
  v. rights protecting the extraction, dissemination, use and reuse of data
     in a Work;
 vi. database rights (such as those arising under Directive 96/9/EC of the
     European Parliament and of the Council of 11 March 1996 on the legal
     protection of databases, and under any national implementation
     thereof, including any amended or successor version of such
     directive); and
vii. other similar, equivalent or corresponding rights throughout the
     world based on applicable law or treaty, and any national
     implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.

4. Limitations and Disclaimers.

 a. No trademark or patent rights held by Affirmer are waived, abandoned,
    surrendered, licensed or otherwise affected by this document.
 b. Affirmer offers the Work as-is and makes no representations or
    warranties of any kind concerning the Work, express, implied,
    statutory or otherwise, including without limitation warranties of
    title, merchantability, fitness for a particular purpose, non
    infringement, or the absence of latent or other defects, accuracy, or
    the present or absence of errors, whether or not discoverable, all to
    the greatest extent permissible under applicable law.
 c. Affirmer disclaims responsibility for clearing rights of other persons
    that may apply to the Work or any use thereof, including without
    limitation any person's Copyright and Related Rights in the Work.
    Further, Affirmer disclaims responsibility for obtaining any necessary
    consents, permissions or other rights required for any use of the
    Work.
 d. Affirmer understands and acknowledges that Creative Commons is not a
    party to this document and has no duty or obligation with respect to
    this CC0 or use of the Work.


================================================
FILE: README.md
================================================
# netdata

Dockerfile for building and running a netdata deamon for your host instance.

Netdata monitors your server with thoughts of performance and memory usage, providing detailed insight into very recent server metrics. It's nice, and now it's also dockerized.

More info about project: https://github.com/firehol/netdata

> **Note**: the netdata project includes telemetry. Google Analytics is used to aggregate telemetry data, with IP anonymisation turned on. There is currently
> no way to opt out, until such a mechanism can be provided at runtime instead of compile time. You can track the upstream [issue #7404](https://github.com/netdata/netdata/issues/7404) if
> you have privacy concerns. GDPR explicitly allows [processing for statistical purposes, without requiring opt-in](https://github.com/netdata/netdata/issues/7366#issuecomment-560363265) in
> it's Article 6, and related Article 89(1). Currently, you can only opt out if you build netdata without telemetry.
>
> More info about the original telemetry implementation in netdata is on [issue #4735](https://github.com/netdata/netdata/issues/4735), and instructions
> / documentation, including a way to opt out of telemetry is available here: [anonymous statistics docs page](https://docs.netdata.cloud/docs/anonymous-statistics/).

# More info about me

I'm primarily a full-stack web developer with strong knowledge of Docker, APIs, AWS, PHP, Go, Nginx+LUA, SQL and NoSQL databases, Video Streaming (Wowza Media Server), and handle DevOps/automation for several large scale international clients (High traffic/HA deployments).

If you need someone with this skillset, please contact me at black@scene-si.org.

I'm also the author of the following books:

* [Advent of Go Microservices](https://leanpub.com/go-microservices)
* [API Foundations in Go](https://leanpub.com/api-foundations)
* [12 Factor Applications with Docker and Go](https://leanpub.com/12fa-docker-golang)

Consider buying the books to learn something new and support my open source work.

For more information, I also write a development-themed blog at [scene-si.org](https://scene-si.org/).
I occasionally tweet my pursuits (sometimes in Slovenian) on [@TitPetric](https://twitter.com/TitPetric).

# Using

## Statring the container

### Docker CLI

```
docker run -d --cap-add SYS_PTRACE \
           -v /proc:/host/proc:ro \
           -v /sys:/host/sys:ro \
           -p 19999:19999 \
           --restart unless-stopped \
           titpetric/netdata
```

> **Note:** Remove the `--restart unless-stopped` [parameter](https://docs.docker.com/config/containers/start-containers-automatically/#use-a-restart-policy) if you don't need the netdata container to start automatically on boot.

### Docker Compose

Use the sample [docker-compose.yml](docker-compose.yml) file.

> **Note:** Remove the `restart: unless-stopped` [option](https://docs.docker.com/compose/compose-file/#restart) if you don't need the netdata container to start automatically on boot.

```
mkdir netdata && cd netdata && wget https://raw.githubusercontent.com/titpetric/netdata/master/docker-compose.yml
docker-compose up -d
```

## Accessing the data

Open a browser on http://server:19999/ and watch how your server is doing.

# Supported tags and respective Dockerfile links

Check out for [Docker Hub Tags page for titpetric/netdata](https://cloud.docker.com/repository/docker/titpetric/netdata/tags) if you
need to grab an older version. There's an archive of versions going back from 1.4 to the current version.

The `latest` tag is in line with the upstream and is occasionally prone to failure. As far as older tags go -
they will inevitably lack some new features but should provide a more stable version to run.

> Developers note: new tags are not added automatically which means there might be some delay between when a new
> release of netdata is available and when a new tag is available on docker hub; open an issue if that happens.

# Limiting IP netdata listens to

By default netdata listens to 0.0.0.0 (any address). You might want to change this if you're running netdata in `--net=host` mode. You can pass the following environment variable:

- NETDATA_IP - the IP that netdata should listen to, e.g. `127.0.0.1` for localhost only.

# Passing custom netdata options

If you need to pass some custom options to netdata, you can pass the following environment variable:

- NETDATA_ARGS - for example if you don't want to use NETDATA_IP above, you can pass `-e NETDATA_ARGS="-i 127.0.0.1"` for same effect.

# Getting emails on alarms

Netdata supports forwarding alarms to an email address. You can set up msmtp by setting the following ENV variables:

- SMTP_TO - This is the address alarms will be delivered to.
- SMTP_FROM - This is the address the emails will be from. Defaults to localhost.
- SMTP_SERVER - This is your SMTP server. Defaults to smtp.gmail.com.
- SMTP_PORT - This is the SMTP server port. Defaults to 587.
- SMTP_USER - This is your username for the SMTP server.
- SMTP_PASS - This is your password for the SMTP server. Use an app password if using Gmail.
- SMTP_TLS - Use TLS for the connection. Defaults to `on`.
- SMTP_STARTTLS - Use STARTTLS for the connection. Defaults to `on`.

For example, using gmail:

```
-e SMTP_TO=user@gmail.com -e SMTP_USER=user -e SMTP_PASS=password
```

Alternatively, if you already have s msmtp config, you can use that config with:

~~~
-v /path/to/msmtprc:/etc/msmtprc:ro
~~~

See the following link for details on setting up msmtp: [MSMTP - ArchWiki](https://wiki.archlinux.org/index.php/Msmtp)

> Note: email settings up to version v0.10.0 were different. You can get the [old documentation](https://github.com/titpetric/netdata/blob/master/releases/v0.10.0/README.md) is the corresponding release subfolder.

# Adding custom alarms, charts and configuration overrides

To add custom alarms, charts or to override any default configuration file, mount a volume to the container to /etc/netdata/override, like `-v /opt/netdata/override:/etc/netdata/override:ro`.  Then, place your config files in the directory as if it was /etc/netdata/.

For example to create a custom alarm for system temperature, create a `health.d` folder in your local directory (`/opt/netdata/override` in the example above) and place a `sensors.conf` file with your alarm configuration inside the `health.d` directory.

# Getting alarms in Slack

Netdata supports sending alerts to slack via webhooks. You can set that up by setting the following ENV variables:

- SLACK_WEBHOOK_URL - This is your incoming slack webhook
- SLACK_CHANNEL - This is the default channel that alerts will get sent to

For example:

```
-e SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXX -e SLACK_CHANNEL=alerts
```

# Getting alarms in Discord

Netdata supports sending alerts to Discord via webhooks. You can set that up by setting the following ENV variables:

- DISCORD_WEBHOOK_URL - This is your incoming Discord webhook
- DISCORD_RECIPIENT - This is the default channel that alerts will get sent to

For example:

```
-e DISCORD_WEBHOOK_URL=https://discordapp.com/api/webhooks/XXXX -e DISCORD_RECIPIENT=alerts
```

# Getting alarms in Telegram

Netdata supports sending alerts to Telegram via token and chat ID. You can set that up by setting the following ENV variables:

- TELEGRAM_BOT_TOKEN - This is your bot token
- TELEGRAM_CHAT_ID - This is the chat ID

For example:

```
-e TELEGRAM_BOT_TOKEN=22624413:AAGy12TkSMBYVBTe4lQt3BfUYvUs5h7I1jn -e TELEGRAM_CHAT_ID=137165138
```

For more details about Telegram alerts, see [this page - GitHub](https://github.com/firehol/netdata/wiki/health-monitoring#telegramorg-messages)

# Getting alarms in Pushbullet

Netdata supports sending alerts to Pushbullet via API token. You can set that up by setting the following ENV variables:

- PUSHBULLET_ACCESS_TOKEN - This is your API token
- PUSHBULLET_DEFAULT_EMAIL - This is the default email that alerts will get sent to if there is not a Pushbullet account attached to it

For example:

```
-e PUSHBULLET_ACCESS_TOKEN=o.l8VuizWhXgbERf2Q78ghtzb1LDCYvbSD -e PUSHBULLET_DEFAULT_EMAIL=your.email@gmail.com
```

More details about Pushbullet alerts are provided [here - GitHub](https://github.com/firehol/netdata/wiki/health-monitoring#pushbulletcom-push-notifications)

# Setting up streaming

On a client netdata set this destination to be the 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. See [this page - GitHub](https://github.com/firehol/netdata/wiki/Replication-Overview#options-for-the-sending-node)

- NETDATA_STREAM_DESTINATION - `HOST[:PORT]` to stream to
- NETDATA_STREAM_API_KEY - `API_KEY` to send to central net data

```
-e NETDATA_STREAM_DESTINATION=netdata.service:19999 -e NETDATA_STREAM_API_KEY=1h213ch12h3rc1289e
```

On the central netdata set 1 or more `NETADATA_API_KEY_ENABLE` env variables 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

- NETADATA_API_KEY_ENABLE_{API_KEY}=1

```
-e NETDATA_API_KEY_ENABLE_1h213ch12h3rc1289e=1
```

# Monitoring docker container metrics

Netdata supports fetching container data from `docker.sock`. You can forward it to the netdata container with:

~~~
-v /var/run/docker.sock:/var/run/docker.sock:ro
~~~

This will allow netdata to resolve container names.

> Note: forwarding docker.sock exposes the administrative docker API. If due to some security issue access has been obtained to the container, it will expose full docker API, allowing to stop, create or delete containers, as well as download new images in the host.
>
> TL;DR If you care about security, consider forwarding a secure docker socket with [docker-proxy-acl](https://github.com/titpetric/docker-proxy-acl)

# Monitoring docker notes on some systems (Debian jessie)

On debian jessie only 'cpu' and 'disk' metrics show up under individual docker containers. To get the memory metric, you will have to add `cgroup_enable=memory swapaccount=1` to `/etc/default/grub`, appending the `GRUB_CMDLINE_LINUX_DEFAULT` variable:

~~~
$ cat /etc/default/grub  | grep GRUB_CMDLINE_LINUX_DEFAULT
GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1"
~~~

After rebooting your linux instance, the memory accounting subsystem of the kernel will be enabled. Netdata will pick up additional metrics for the containers when it starts.

# Environment variables

It's possible to pass a NETDATA_PORT environment variable with -e, to start up netdata on a different port.

```
docker run -e NETDATA_PORT=80 [...]
```

# Some explanation is in order

Docker needs to run with the SYS_PTRACE capability. Without it, the mapped host/proc filesystem is not fully readable to the netdata deamon, more specifically the "apps" plugin:

```
16-01-12 07:58:16: ERROR: apps.plugin: Cannot process /host/proc/1/io (errno 13, Permission denied)
```

See the following link for more details: [/proc/1/environ is unavailable in a container that is not priviledged](https://github.com/docker/docker/issues/6607)

# Limitations

In addition to the above requirements and limitations, monitoring the complete network interface list of the host is not possible from within the Docker container. If you're running netdata and want to graph all the interfaces available on the host, you will have to use `--net=host` mode.

See the following link for more details: [network interfaces missing when mounting proc inside a container](https://github.com/docker/docker/issues/13398)

## Work-around

I provided a script called `fakenet.sh` which provides a copy of the `/proc/net` filesystem. You should start this script before you start the netdata container. You can do it like this:

~~~
wget https://raw.githubusercontent.com/titpetric/netdata/master/fakenet.sh
chmod a+x fakenet.sh
nohup ./fakenet.sh >/dev/null 2>&1 &
~~~

Using the above command, the fakenet script will start in the background and will keep running there. You can use other tools like `screen` or `tmux` to provide similar capability.

The script fills out the `/dev/shm/fakenet` location, which you must mount into the container. You *must* mount it into `/fakenet/proc/net` exactly with the option like this:

~~~
-v /dev/shm/fakenet:/fakenet/proc/net
~~~

The script refreshes network information about every 250ms (four times per second). The interval may be increased to give better accuracy of netdata, but CPU usage will also increase. Because of this, the data is not very accurate and some spikes and valleys will occur because of a shifting window between when the reading was taken (fakeproc) and between when the reading was read by netdata. This means the margin for error is whatever data can be collected in ~250ms.

While the solution might not fit everybody, it's security-positive because the netdata container can only inspect the fake proc/net location, and can't actually access any of the networks because it runs on a private LAN / custom network which is managed and firewalled by docker. You may even open access via application, like a nginx reverse proxy where you can add authentication etc.

Pro/con list:

* + network isolation stays in tact
* + all network device metrics are available
* - one more service to provide fakenet
* - accuracy vs. cpu use is a trade-off

# Additional notes

Netdata provides monitoring via a plugin architecture. This plugin supports many projects that don't provide data over the `/proc` filesystem. When you're running netdata in the container, you will have difficulty providing many of these paths to the netdata container.

What you do get (even with the docker version) is:

* Host CPU statististics
* Host Network I/O, QoS
* Host Disk I/O
* Applications monitoring
* Container surface metrics (cpu/disk per name)

You will not get detailed application metrics (mysql, ups, etc.) from other containers or from the host if running netdata in a container. It may be possible to get *some* of those metrics, but it might not be easy, and most likely not worth it. For most detailed metrics, netdata needs to share the same environment as the application server it monitors. This means it would need to run either in the same container (not even remotely practical), or in the same virtual machine (no containers).

> Note: if you have some custom hardware like a UPS which is monitored via USB and netdata supports it, you will most likely need to add new software to the netdata docker image to support it. The correct way to do it is to create your own Dockerfile, start with "FROM titpetric/netdata" and then add all your installation commands to build your own image which will support your hardware setup. Most likely if it's not a very common setup (i.e. available on most machines), the software will not be added to `titpetric/netdata` - that being said, your use case might be useful for others so feel free to submit issues with your extensions or feature requests in terms of new software. I'll gladly add your project/extension to the README here.

# Changelog

### v1.10.0 -> Latest

* Replaced sSMTP with msmtp, renamed `SSMTP_*` settings as `SMTP_*`, removed `SSMTP_HOSTNAME` setting, renamed `SSMTP_TLS` to `SMTP_STARTTLS` and added `SMTP_TLS`.


================================================
FILE: docker-compose.yml
================================================
version: '3.4'

services:
  netdata:
    restart: always
    hostname: netdata
    image: titpetric/netdata
    cap_add:
      - SYS_PTRACE
    security_opt:
      - apparmor:unconfined
    ports:
      - 19999:19999
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro


================================================
FILE: fakenet.sh
================================================
#!/bin/bash
# generate a fake /proc/net with a limited set of files
# which are used for netdata metrics collection
OUTPUT="/dev/shm/fakenet/";

if [ ! -d "$OUTPUT" ]; then
	mkdir -p $OUTPUT/{rpc,stat,ip_vs}
fi

SOURCES="/proc/net/dev
/proc/net/ip_vs_stats
/proc/net/ip_vs/stats
/proc/net/netstat
/proc/net/rpc/nfs
/proc/net/rpc/nfsd
/proc/net/snmp
/proc/net/snmp6
/proc/net/softnet_stat
/proc/net/stat/conntrack
/proc/net/stat/nf_conntrack
/proc/net/stat/synproxy"

NETFILES=""
for SOURCE in $SOURCES; do
	if [ -f "$SOURCE" ]; then
		NETFILES="$NETFILES $SOURCE"
	fi
done

while [ true ]; do
	for NETFILE in $NETFILES; do
		OUTFILE="${NETFILE:10}"
		echo "$(<$NETFILE)" > $OUTPUT$OUTFILE
	done
	##date +%s.%N
	sleep 0.23
done


================================================
FILE: package.json
================================================
{
  "name": "netdata",
  "version": "0.0.10",
  "description": "Netdata monitors your server with thoughts of performance and memory usage, providing detailed insight into very recent server metrics.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/titpetric/netdata.git"
  },
  "keywords": [
    "netdata",
    "monitoring",
    "statistics",
    "graphs",
    "ganglia",
    "cacti",
    "munin"
  ],
  "author": "Tit Petric",
  "license": "GPL3 or later",
  "bugs": {
    "url": "https://github.com/titpetric/netdata/issues"
  },
  "homepage": "https://github.com/titpetric/netdata"
}


================================================
FILE: releases/dev/Dockerfile.build
================================================
FROM debian:jessie

ADD scripts/build.sh /build.sh
RUN chmod +x /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

================================================
FILE: releases/dev/Dockerfile.run
================================================
FROM titpetric/netdata-build

ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh && sync && sleep 1

WORKDIR /

ENV NETDATA_PORT=19999 SSMTP_TLS=YES SSMTP_SERVER=smtp.gmail.com SSMTP_PORT=587 SSMTP_HOSTNAME=localhost
EXPOSE $NETDATA_PORT

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/dev/Makefile
================================================
build:
	docker build --rm --no-cache=true -t titpetric/netdata-build -f Dockerfile.build .

run:
	docker build --rm --no-cache=true -t titpetric/netdata -f Dockerfile.run .

.PHONY: build run

================================================
FILE: releases/latest/Dockerfile
================================================
FROM debian:stretch

ADD git-tag /git-tag

ADD scripts/build.sh /build.sh
ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

ENV NETDATA_PORT=19999 SMTP_TLS=on SMTP_STARTTLS=on SMTP_SERVER=smtp.gmail.com SMTP_PORT=587 SMTP_FROM=localhost
EXPOSE $NETDATA_PORT

VOLUME /etc/netdata/override

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/latest/git-tag
================================================


================================================
FILE: releases/latest/scripts/build.sh
================================================
#!/bin/bash
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror

echo "deb http://ftp.nl.debian.org/debian/ stretch main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list

# 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 libuv1-dev liblz4-dev libjudy-dev libssl-dev
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml libjudydebian1 libuv1 liblz4-1 openssl
apt-get -y install msmtp msmtp-mta apcupsd fping

# fetch netdata

git clone https://github.com/firehol/netdata.git /netdata.git
cd /netdata.git
TAG=$(</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

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config libuv1-dev liblz4-dev libjudy-dev libssl-dev
apt-get -y autoremove
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


================================================
FILE: releases/latest/scripts/run.sh
================================================
#!/bin/bash

# fix permissions due to netdata running as root
chown root:root /usr/share/netdata/web/ -R
echo -n "" > /usr/share/netdata/web/version.txt

# set up msmtp
if [[ $SMTP_TO ]]; then
cat << EOF > /etc/msmtprc
account default
aliases /etc/msmtp_aliases
from $SMTP_FROM
host $SMTP_SERVER
port $SMTP_PORT
tls $SMTP_TLS
tls_starttls $SMTP_STARTTLS
tls_certcheck off
EOF

cat << EOF > /etc/msmtp_aliases
netdata: $SMTP_TO
root: $SMTP_TO
EOF
fi

if [[ $SMTP_USER ]]; then
cat << EOF >> /etc/msmtprc
auth on
user $SMTP_USER
EOF
fi

if [[ $SMTP_PASS ]]; then
cat << EOF >> /etc/msmtprc
password $SMTP_PASS
EOF
fi

# copy conf from NETDATA_STOCK_CONFIG_DIR (normally under /usr/lib/netdata/conf.d) to NETDATA_USER_CONFIG_DIR (normally under /etc/netdata)
cp /usr/lib/netdata/conf.d/health_alarm_notify.conf /etc/netdata

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 [[ $DISCORD_WEBHOOK_URL ]]; then
	sed -i -e "s@DISCORD_WEBHOOK_URL=\"\"@DISCORD_WEBHOOK_URL=\"${DISCORD_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $DISCORD_RECIPIENT ]]; then
	sed -i -e "s@DEFAULT_RECIPIENT_DISCORD=\"\"@DEFAULT_RECIPIENT_DISCORD=\"${DISCORD_RECIPIENT}\"@" /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

for f in /etc/netdata/override/*; do
  cp -a $f /etc/netdata/
done

# main entrypoint
touch /etc/netdata/python.d.conf
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS} "$@"


================================================
FILE: releases/v1.10.0/Dockerfile
================================================
FROM debian:jessie

ADD git-tag /git-tag

ADD scripts/build.sh /build.sh
ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

ENV NETDATA_PORT=19999 SSMTP_TLS=YES SSMTP_SERVER=smtp.gmail.com SSMTP_PORT=587 SSMTP_HOSTNAME=localhost
EXPOSE $NETDATA_PORT

VOLUME /etc/netdata/override

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/v1.10.0/README.md
================================================
# netdata

Dockerfile for building and running a netdata deamon for your host instance.

Netdata monitors your server with thoughts of performance and memory usage, providing detailed insight into very recent server metrics. It's nice, and now it's also dockerized.

More info about project: https://github.com/firehol/netdata

# More info about me

I'm primarily a full-stack web developer with strong knowledge of Docker, APIs, AWS, PHP, Go, Nginx+LUA, SQL and NoSQL databases, Video Streaming (Wowza Media Server), and handle DevOps/automation for several large scale international clients (High traffic/HA deployments).

If you need someone with this skillset, please contact me at black@scene-si.org.

I'm also the author of the following books:

* [API Foundations in Go](https://leanpub.com/api-foundations)
* [12 Factor Applications with Docker and Go](https://leanpub.com/12fa-docker-golang)

For more information, I also write a development-themed blog at [scene-si.org](https://scene-si.org/).
I occasionally tweet my pursuits (sometimes in Slovenian) on [@TitPetric](https://twitter.com/TitPetric).

# Using

```
docker run -d --cap-add SYS_PTRACE \
           -v /proc:/host/proc:ro \
           -v /sys:/host/sys:ro \
           -p 19999:19999 titpetric/netdata
```

Open a browser on http://server:19999/ and watch how your server is doing.

# Supported tags and respective Dockerfile links

* `titpetric/netdata:latest` [releases/latest/Dockerfile](https://github.com/titpetric/netdata/tree/master/releases/latest)
* `titpetric/netdata:1.8` [releases/v1.8.0/Dockerfile](https://github.com/titpetric/netdata/tree/master/releases/v1.8.0)
* `titpetric/netdata:1.7` [releases/v1.7.0/Dockerfile](https://github.com/titpetric/netdata/tree/master/releases/v1.7.0)
* `titpetric/netdata:1.6` [releases/v1.6.0/Dockerfile](https://github.com/titpetric/netdata/tree/master/releases/v1.6.0)
* `titpetric/netdata:1.5` [releases/v1.5.0/Dockerfile](https://github.com/titpetric/netdata/tree/master/releases/v1.5.0)
* `titpetric/netdata:1.4` [releases/v1.4.0/Dockerfile](https://github.com/titpetric/netdata/tree/master/releases/v1.4.0)

The tags include builds of netdata, with the same tag in upstream. If there's some need to add older tags, you may
use the provided `/releases` folder as reference, and add new tags as a PR. The `latest` tag is in line with the
upstream and is occasionally prone to failure. As far as older tags go - they will inevitably lack some new features
but should provide a more stable version to run.

> Developers note: new tags are not added automatically which means there might be some delay between when a new
> release of netdata is available and when a new tag is available on docker hub - to add a new release yourself, the procedure is as follows:
>
> 1. fork netdata repo,
> 2. run /update-releases.sh,
> 3. add, commit, push and submit a PR to `titpetric/netdata`
>
> When you will submit a PR, I will also add the new version to the docker hub and thank you profusely.

# Limiting IP netdata listens to

By default netdata listens to 0.0.0.0 (any address). You might want to change this if you're running netdata in `--net=host` mode. You can pass the following environment variable:

- NETDATA_IP - the IP that netdata should listen to, e.g. `127.0.0.1` for localhost only.

# Passing custom netdata options

If you need to pass some custom options to netdata, you can pass the following environment variable:

- NETDATA_ARGS - for example if you don't want to use NETDATA_IP above, you can pass `-e NETDATA_ARGS="-i 127.0.0.1"` for same effect.

# Getting emails on alarms

Netdata supports forwarding alarms to an email address. You can set up sSMTP by setting the following ENV variables:

- SSMTP_TO - This is the address alarms will be delivered to.
- SSMTP_SERVER - This is your SMTP server. Defaults to smtp.gmail.com.
- SSMTP_PORT - This is the SMTP server port. Defaults to 587.
- SSMTP_USER - This is your username for the SMTP server.
- SSMTP_PASS - This is your password for the SMTP server. Use an app password if using Gmail.
- SSMTP_TLS - Use TLS for the connection. Defaults to YES.
- SSMTP_HOSTNAME - The hostname mail will come from. Defaults to localhost.

For example, using gmail:

```
-e SSMTP_TO=user@gmail.com -e SSMTP_USER=user -e SSMTP_PASS=password
```

Alternatively, if you already have s sSMTP config, you can use that config with:

~~~
-v /path/to/config:/etc/ssmtp
~~~

See the following link for details on setting up sSMTP: [SSMTP - ArchWiki](https://wiki.archlinux.org/index.php/SSMTP)

# Adding custom alarms, charts and configuration overrides

To add custom alarms, charts or to override any default configuration file, mount a volume to the container to /etc/netdata/override, like `-v /opt/netdata/overrides:/etc/netdata/override`.  Then, place your config files in the directory as if it was /etc/netdata/.  

For example to create a custom alarm for system temperature, create a `health.d` folder in your local directory (`/opt/netdata/override` in the example above) and place a `sensors.conf` file with your alarm configuration inside the `health.d` directory.

# Getting alarms in Slack

Netdata supports sending alerts to slack via webhooks. You can set that up by setting the following ENV variables:

- SLACK_WEBHOOK_URL - This is your incoming slack webhook
- SLACK_CHANNEL - This is the default channel that alerts will get sent to

For example:

```
-e SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXX -e SLACK_CHANNEL=alerts
```

# Getting alarms in Discord

Netdata supports sending alerts to Discord via webhooks. You can set that up by setting the following ENV variables:

- DISCORD_WEBHOOK_URL - This is your incoming Discord webhook
- DISCORD_RECIPIENT - This is the default channel that alerts will get sent to

For example:

```
-e DISCORD_WEBHOOK_URL=https://discordapp.com/api/webhooks/XXXX -e DISCORD_RECIPIENT=alerts
```

# Getting alarms in Telegram

Netdata supports sending alerts to Telegram via token and chat ID. You can set that up by setting the following ENV variables:

- TELEGRAM_BOT_TOKEN - This is your bot token
- TELEGRAM_CHAT_ID - This is the chat ID

For example:

```
-e TELEGRAM_BOT_TOKEN=22624413:AAGy12TkSMBYVBTe4lQt3BfUYvUs5h7I1jn -e TELEGRAM_CHAT_ID=137165138
```

For more details about Telegram alerts, see [this page - GitHub](https://github.com/firehol/netdata/wiki/health-monitoring#telegramorg-messages)

# Getting alarms in Pushbullet

Netdata supports sending alerts to Pushbullet via API token. You can set that up by setting the following ENV variables:

- PUSHBULLET_ACCESS_TOKEN - This is your API token
- PUSHBULLET_DEFAULT_EMAIL - This is the default email that alerts will get sent to if there is not a Pushbullet account attached to it

For example:

```
-e PUSHBULLET_ACCESS_TOKEN=o.l8VuizWhXgbERf2Q78ghtzb1LDCYvbSD -e PUSHBULLET_DEFAULT_EMAIL=your.email@gmail.com
```

More details about Pushbullet alerts are provided [here - GitHub](https://github.com/firehol/netdata/wiki/health-monitoring#pushbulletcom-push-notifications)

# Setting up streaming

On a client netdata set this destination to be the 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. See [this page - GitHub](https://github.com/firehol/netdata/wiki/Replication-Overview#options-for-the-sending-node)

- NETDATA_STREAM_DESTINATION - `HOST[:PORT]` to stream to
- NETDATA_STREAM_API_KEY - `API_KEY` to send to central net data

```
-e NETDATA_STREAM_DESTINATION=netdata.service:19999 -e NETDATA_STREAM_API_KEY=1h213ch12h3rc1289e
```

On the central netdata set 1 or more `NETADATA_API_KEY_ENABLE` env variables 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

- NETADATA_API_KEY_ENABLE_{API_KEY}=1

```
-e NETDATA_API_KEY_ENABLE_1h213ch12h3rc1289e=1
```

# Monitoring docker container metrics

Netdata supports fetching container data from `docker.sock`. You can forward it to the netdata container with:

~~~
-v /var/run/docker.sock:/var/run/docker.sock
~~~

This will allow netdata to resolve container names.

> Note: forwarding docker.sock exposes the administrative docker API. If due to some security issue access has been obtained to the container, it will expose full docker API, allowing to stop, create or delete containers, as well as download new images in the host.
>
> TL;DR If you care about security, consider forwarding a secure docker socket with [docker-proxy-acl](https://github.com/titpetric/docker-proxy-acl)

# Monitoring docker notes on some systems (Debian jessie)

On debian jessie only 'cpu' and 'disk' metrics show up under individual docker containers. To get the memory metric, you will have to add `cgroup_enable=memory swapaccount=1` to `/etc/default/grub`, appending the `GRUB_CMDLINE_LINUX_DEFAULT` variable:

~~~
$ cat /etc/default/grub  | grep GRUB_CMDLINE_LINUX_DEFAULT
GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1"
~~~

After rebooting your linux instance, the memory accounting subsystem of the kernel will be enabled. Netdata will pick up additional metrics for the containers when it starts.

# Environment variables

It's possible to pass a NETDATA_PORT environment variable with -e, to start up netdata on a different port.

```
docker run -e NETDATA_PORT=80 [...]
```

# Some explanation is in order

Docker needs to run with the SYS_PTRACE capability. Without it, the mapped host/proc filesystem is not fully readable to the netdata deamon, more specifically the "apps" plugin:

```
16-01-12 07:58:16: ERROR: apps.plugin: Cannot process /host/proc/1/io (errno 13, Permission denied)
```

See the following link for more details: [/proc/1/environ is unavailable in a container that is not priviledged](https://github.com/docker/docker/issues/6607)

# Limitations

In addition to the above requirements and limitations, monitoring the complete network interface list of the host is not possible from within the Docker container. If you're running netdata and want to graph all the interfaces available on the host, you will have to use `--net=host` mode.

See the following link for more details: [network interfaces missing when mounting proc inside a container](https://github.com/docker/docker/issues/13398)

## Work-around

I provided a script called `fakenet.sh` which provides a copy of the `/proc/net` filesystem. You should start this script before you start the netdata container. You can do it like this:

~~~
wget https://raw.githubusercontent.com/titpetric/netdata/master/fakenet.sh
chmod a+x fakenet.sh
nohup ./fakenet.sh >/dev/null 2>&1 &
~~~

Using the above command, the fakenet script will start in the background and will keep running there. You can use other tools like `screen` or `tmux` to provide similar capability.

The script fills out the `/dev/shm/fakenet` location, which you must mount into the container. You *must* mount it into `/fakenet/proc/net` exactly with the option like this:

~~~
-v /dev/shm/fakenet:/fakenet/proc/net
~~~

The script refreshes network information about every 250ms (four times per second). The interval may be increased to give better accuracy of netdata, but CPU usage will also increase. Because of this, the data is not very accurate and some spikes and valleys will occur because of a shifting window between when the reading was taken (fakeproc) and between when the reading was read by netdata. This means the margin for error is whatever data can be collected in ~250ms.

While the solution might not fit everybody, it's security-positive because the netdata container can only inspect the fake proc/net location, and can't actually access any of the networks because it runs on a private LAN / custom network which is managed and firewalled by docker. You may even open access via application, like a nginx reverse proxy where you can add authentication etc.

Pro/con list:

* + network isolation stays in tact
* + all network device metrics are available
* - one more service to provide fakenet
* - accuracy vs. cpu use is a trade-off

# Additional notes

Netdata provides monitoring via a plugin architecture. This plugin supports many projects that don't provide data over the `/proc` filesystem. When you're running netdata in the container, you will have difficulty providing many of these paths to the netdata container.

What you do get (even with the docker version) is:

* Host CPU statististics
* Host Network I/O, QoS
* Host Disk I/O
* Applications monitoring
* Container surface metrics (cpu/disk per name)

You will not get detailed application metrics (mysql, ups, etc.) from other containers or from the host if running netdata in a container. It may be possible to get *some* of those metrics, but it might not be easy, and most likely not worth it. For most detailed metrics, netdata needs to share the same environment as the application server it monitors. This means it would need to run either in the same container (not even remotely practical), or in the same virtual machine (no containers).

> Note: if you have some custom hardware like a UPS which is monitored via USB and netdata supports it, you will most likely need to add new software to the netdata docker image to support it. The correct way to do it is to create your own Dockerfile, start with "FROM titpetric/netdata" and then add all your installation commands to build your own image which will support your hardware setup. Most likely if it's not a very common setup (i.e. available on most machines), the software will not be added to `titpetric/netdata` - that being said, your use case might be useful for others so feel free to submit issues with your extensions or feature requests in terms of new software. I'll gladly add your project/extension to the README here.


================================================
FILE: releases/v1.10.0/git-tag
================================================
v1.10.0


================================================
FILE: releases/v1.10.0/scripts/build.sh
================================================
#!/bin/bash
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror

echo "deb http://ftp.nl.debian.org/debian/ jessie main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list

# 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
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml
apt-get -y install ssmtp mailutils apcupsd fping

# fetch netdata

git clone https://github.com/firehol/netdata.git /netdata.git
cd /netdata.git
TAG=$(</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

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config
apt-get -y autoremove
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


================================================
FILE: releases/v1.10.0/scripts/run.sh
================================================
#!/bin/bash

# fix permissions due to netdata running as root
chown root:root /usr/share/netdata/web/ -R
echo -n "" > /usr/share/netdata/web/version.txt

# set up ssmtp
if [[ $SSMTP_TO ]]; then
cat << EOF > /etc/ssmtp/ssmtp.conf
root=$SSMTP_TO
mailhub=$SSMTP_SERVER:$SSMTP_PORT
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 [[ $SSMTP_USER ]]; then
cat << EOF >> /etc/ssmtp/ssmtp.conf
AuthUser=$SSMTP_USER
EOF
fi

if [[ $SSMTP_PASS ]]; then
cat << EOF >> /etc/ssmtp/ssmtp.conf
AuthPass=$SSMTP_PASS
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 [[ $DISCORD_WEBHOOK_URL ]]; then
	sed -i -e "s@DISCORD_WEBHOOK_URL=\"\"@DISCORD_WEBHOOK_URL=\"${DISCORD_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $DISCORD_RECIPIENT ]]; then
	sed -i -e "s@DEFAULT_RECIPIENT_DISCORD=\"\"@DEFAULT_RECIPIENT_DISCORD=\"${DISCORD_RECIPIENT}\"@" /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

for f in /etc/netdata/override/*; do
  cp -a $f /etc/netdata/
done

# main entrypoint
touch /etc/netdata/python.d.conf
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS} "$@"


================================================
FILE: releases/v1.4.0/Dockerfile
================================================
FROM debian:jessie

ADD git-tag /git-tag

ADD scripts/build.sh /build.sh
ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

ENV NETDATA_PORT=19999 SSMTP_TLS=YES SSMTP_SERVER=smtp.gmail.com SSMTP_PORT=587 SSMTP_HOSTNAME=localhost
EXPOSE $NETDATA_PORT

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/v1.4.0/git-tag
================================================
v1.4.0


================================================
FILE: releases/v1.4.0/scripts/build.sh
================================================
#!/bin/bash
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror

echo "deb http://ftp.nl.debian.org/debian/ jessie main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list

# 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
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml
apt-get -y install ssmtp mailutils apcupsd

# fetch netdata

git clone https://github.com/firehol/netdata.git /netdata.git
cd /netdata.git
TAG=$(</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

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config
apt-get -y autoremove
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


================================================
FILE: releases/v1.4.0/scripts/run.sh
================================================
#!/bin/bash

# fix permissions due to netdata running as root
chown root:root /usr/share/netdata/web/ -R
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

# 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

# main entrypoint
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS}


================================================
FILE: releases/v1.5.0/Dockerfile
================================================
FROM debian:jessie

ADD git-tag /git-tag

ADD scripts/build.sh /build.sh
ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

ENV NETDATA_PORT=19999 SSMTP_TLS=YES SSMTP_SERVER=smtp.gmail.com SSMTP_PORT=587 SSMTP_HOSTNAME=localhost
EXPOSE $NETDATA_PORT

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/v1.5.0/git-tag
================================================
v1.5.0


================================================
FILE: releases/v1.5.0/scripts/build.sh
================================================
#!/bin/bash
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror

echo "deb http://ftp.nl.debian.org/debian/ jessie main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list

# 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
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml
apt-get -y install ssmtp mailutils apcupsd

# fetch netdata

git clone https://github.com/firehol/netdata.git /netdata.git
cd /netdata.git
TAG=$(</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

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config
apt-get -y autoremove
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


================================================
FILE: releases/v1.5.0/scripts/run.sh
================================================
#!/bin/bash

# fix permissions due to netdata running as root
chown root:root /usr/share/netdata/web/ -R
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

# 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

# main entrypoint
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS}


================================================
FILE: releases/v1.6.0/Dockerfile
================================================
FROM debian:jessie

ADD git-tag /git-tag

ADD scripts/build.sh /build.sh
ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

ENV NETDATA_PORT=19999 SSMTP_TLS=YES SSMTP_SERVER=smtp.gmail.com SSMTP_PORT=587 SSMTP_HOSTNAME=localhost
EXPOSE $NETDATA_PORT

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/v1.6.0/git-tag
================================================
v1.6.0


================================================
FILE: releases/v1.6.0/scripts/build.sh
================================================
#!/bin/bash
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror

echo "deb http://ftp.nl.debian.org/debian/ jessie main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list

# 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
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml
apt-get -y install ssmtp mailutils apcupsd

# fetch netdata

git clone https://github.com/firehol/netdata.git /netdata.git
cd /netdata.git
TAG=$(</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

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config
apt-get -y autoremove
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


================================================
FILE: releases/v1.6.0/scripts/run.sh
================================================
#!/bin/bash

# fix permissions due to netdata running as root
chown root:root /usr/share/netdata/web/ -R
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

# 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

# main entrypoint
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS}


================================================
FILE: releases/v1.7.0/Dockerfile
================================================
FROM debian:jessie

ADD git-tag /git-tag

ADD scripts/build.sh /build.sh
ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

ENV NETDATA_PORT=19999 SSMTP_TLS=YES SSMTP_SERVER=smtp.gmail.com SSMTP_PORT=587 SSMTP_HOSTNAME=localhost
EXPOSE $NETDATA_PORT

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/v1.7.0/git-tag
================================================
v1.7.0


================================================
FILE: releases/v1.7.0/scripts/build.sh
================================================
#!/bin/bash
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror

echo "deb http://ftp.nl.debian.org/debian/ jessie main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list

# 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
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml
apt-get -y install ssmtp mailutils apcupsd

# fetch netdata

git clone https://github.com/firehol/netdata.git /netdata.git
cd /netdata.git
TAG=$(</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

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config
apt-get -y autoremove
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


================================================
FILE: releases/v1.7.0/scripts/run.sh
================================================
#!/bin/bash

# fix permissions due to netdata running as root
chown root:root /usr/share/netdata/web/ -R
echo -n "" > /usr/share/netdata/web/version.txt

# set up ssmtp
if [[ $SSMTP_TO ]]; then
cat << EOF > /etc/ssmtp/ssmtp.conf
root=$SSMTP_TO
mailhub=$SSMTP_SERVER:$SSMTP_PORT
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 [[ $SSMTP_USER ]]; then
cat << EOF >> /etc/ssmtp/ssmtp.conf
AuthUser=$SSMTP_USER
EOF
fi

if [[ $SSMTP_PASS ]]; then
cat << EOF >> /etc/ssmtp/ssmtp.conf
AuthPass=$SSMTP_PASS
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 [[ $DISCORD_WEBHOOK_URL ]]; then
	sed -i -e "s@DISCORD_WEBHOOK_URL=\"\"@DISCORD_WEBHOOK_URL=\"${DISCORD_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $DISCORD_RECIPIENT ]]; then
	sed -i -e "s@DEFAULT_RECIPIENT_DISCORD=\"\"@DEFAULT_RECIPIENT_DISCORD=\"${DISCORD_RECIPIENT}\"@" /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

for f in /etc/netdata/override/*; do
  cp -a $f /etc/netdata/
done

# main entrypoint
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS} "$@"


================================================
FILE: releases/v1.8.0/Dockerfile
================================================
FROM debian:jessie

ADD git-tag /git-tag

ADD scripts/build.sh /build.sh
ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

ENV NETDATA_PORT=19999 SSMTP_TLS=YES SSMTP_SERVER=smtp.gmail.com SSMTP_PORT=587 SSMTP_HOSTNAME=localhost
EXPOSE $NETDATA_PORT

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/v1.8.0/git-tag
================================================
v1.8.0


================================================
FILE: releases/v1.8.0/scripts/build.sh
================================================
#!/bin/bash
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror

echo "deb http://ftp.nl.debian.org/debian/ jessie main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list

# 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
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml
apt-get -y install ssmtp mailutils apcupsd

# fetch netdata

git clone https://github.com/firehol/netdata.git /netdata.git
cd /netdata.git
TAG=$(</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

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config
apt-get -y autoremove
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


================================================
FILE: releases/v1.8.0/scripts/run.sh
================================================
#!/bin/bash

# fix permissions due to netdata running as root
chown root:root /usr/share/netdata/web/ -R
echo -n "" > /usr/share/netdata/web/version.txt

# set up ssmtp
if [[ $SSMTP_TO ]]; then
cat << EOF > /etc/ssmtp/ssmtp.conf
root=$SSMTP_TO
mailhub=$SSMTP_SERVER:$SSMTP_PORT
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 [[ $SSMTP_USER ]]; then
cat << EOF >> /etc/ssmtp/ssmtp.conf
AuthUser=$SSMTP_USER
EOF
fi

if [[ $SSMTP_PASS ]]; then
cat << EOF >> /etc/ssmtp/ssmtp.conf
AuthPass=$SSMTP_PASS
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 [[ $DISCORD_WEBHOOK_URL ]]; then
	sed -i -e "s@DISCORD_WEBHOOK_URL=\"\"@DISCORD_WEBHOOK_URL=\"${DISCORD_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $DISCORD_RECIPIENT ]]; then
	sed -i -e "s@DEFAULT_RECIPIENT_DISCORD=\"\"@DEFAULT_RECIPIENT_DISCORD=\"${DISCORD_RECIPIENT}\"@" /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

for f in /etc/netdata/override/*; do
  cp -a $f /etc/netdata/
done

# main entrypoint
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS} "$@"


================================================
FILE: releases/v1.9.0/Dockerfile
================================================
FROM debian:jessie

ADD git-tag /git-tag

ADD scripts/build.sh /build.sh
ADD scripts/run.sh /run.sh

RUN chmod +x /run.sh /build.sh && sync && sleep 1 && /build.sh

WORKDIR /

ENV NETDATA_PORT=19999 SSMTP_TLS=YES SSMTP_SERVER=smtp.gmail.com SSMTP_PORT=587 SSMTP_HOSTNAME=localhost
EXPOSE $NETDATA_PORT

VOLUME /etc/netdata/override

ENTRYPOINT ["/run.sh"]


================================================
FILE: releases/v1.9.0/git-tag
================================================
v1.9.0


================================================
FILE: releases/v1.9.0/scripts/build.sh
================================================
#!/bin/bash
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror

echo "deb http://ftp.nl.debian.org/debian/ jessie main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list

# 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
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml
apt-get -y install ssmtp mailutils apcupsd

# fetch netdata

git clone https://github.com/firehol/netdata.git /netdata.git
cd /netdata.git
TAG=$(</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

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autogen automake pkg-config
apt-get -y autoremove
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


================================================
FILE: releases/v1.9.0/scripts/run.sh
================================================
#!/bin/bash

# fix permissions due to netdata running as root
chown root:root /usr/share/netdata/web/ -R
echo -n "" > /usr/share/netdata/web/version.txt

# set up ssmtp
if [[ $SSMTP_TO ]]; then
cat << EOF > /etc/ssmtp/ssmtp.conf
root=$SSMTP_TO
mailhub=$SSMTP_SERVER:$SSMTP_PORT
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 [[ $SSMTP_USER ]]; then
cat << EOF >> /etc/ssmtp/ssmtp.conf
AuthUser=$SSMTP_USER
EOF
fi

if [[ $SSMTP_PASS ]]; then
cat << EOF >> /etc/ssmtp/ssmtp.conf
AuthPass=$SSMTP_PASS
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 [[ $DISCORD_WEBHOOK_URL ]]; then
	sed -i -e "s@DISCORD_WEBHOOK_URL=\"\"@DISCORD_WEBHOOK_URL=\"${DISCORD_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $DISCORD_RECIPIENT ]]; then
	sed -i -e "s@DEFAULT_RECIPIENT_DISCORD=\"\"@DEFAULT_RECIPIENT_DISCORD=\"${DISCORD_RECIPIENT}\"@" /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

for f in /etc/netdata/override/*; do
  cp -a $f /etc/netdata/
done

# main entrypoint
touch /etc/netdata/python.d.conf
exec /usr/sbin/netdata -D -u root -s /host -p ${NETDATA_PORT} ${NETDATA_ARGS} "$@"


================================================
FILE: update-releases.sh
================================================
#!/bin/bash
#
# It should go without saying, this script is for development/deployment purposes
# only. If a new tag is added into `netdata/netdata`, this creates the corresponding
# directory (symlink) structure. Most likely, it should be deleted because the build
# steps for netdata have and will change over time. What is symlinked today, will
# not be accurate in the future, as the Dockerfiles are currently maintained only
# for the master branch. Results may vary.
#
# And of course, there's the small issue to add individual tags manually to Docker Hub.
#
rm update-releases.json
if [ ! -f "update-releases.json" ]; then
	curl -s https://api.github.com/repos/netdata/netdata/tags > update-releases.json
fi
TAGS=$(cat update-releases.json | jq -r ".[].name" | grep -v 'rc')
for TAG in $TAGS; do
	if [ -d "releases/$TAG" ]; then
		# tags are sorted, don't create older than the latest created tag
		echo "Done, latest tags are up to date"
		exit
	fi

	TAG=${TAG/v/}
	if [ -d ".git/refs/tags/$TAG" ]; then
		# tags are sorted, don't create older than the latest created tag
		echo "Done, latest tags are up to date"
		exit
	fi


	echo "Creating tag: $TAG"
	git tag $TAG
done
Download .txt
gitextract_mmhg773n/

├── .gitignore
├── LICENSE
├── README.md
├── docker-compose.yml
├── fakenet.sh
├── package.json
├── releases/
│   ├── dev/
│   │   ├── Dockerfile.build
│   │   ├── Dockerfile.run
│   │   └── Makefile
│   ├── latest/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.10.0/
│   │   ├── Dockerfile
│   │   ├── README.md
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.4.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.5.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.6.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.7.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   ├── v1.8.0/
│   │   ├── Dockerfile
│   │   ├── git-tag
│   │   └── scripts/
│   │       ├── build.sh
│   │       └── run.sh
│   └── v1.9.0/
│       ├── Dockerfile
│       ├── git-tag
│       └── scripts/
│           ├── build.sh
│           └── run.sh
└── update-releases.sh
Condensed preview — 43 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (87K chars).
[
  {
    "path": ".gitignore",
    "chars": 21,
    "preview": "/update-releases.json"
  },
  {
    "path": "LICENSE",
    "chars": 7048,
    "preview": "Creative Commons Legal Code\n\nCC0 1.0 Universal\n\n    CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE\n"
  },
  {
    "path": "README.md",
    "chars": 15350,
    "preview": "# netdata\n\nDockerfile for building and running a netdata deamon for your host instance.\n\nNetdata monitors your server wi"
  },
  {
    "path": "docker-compose.yml",
    "chars": 337,
    "preview": "version: '3.4'\n\nservices:\n  netdata:\n    restart: always\n    hostname: netdata\n    image: titpetric/netdata\n    cap_add:"
  },
  {
    "path": "fakenet.sh",
    "chars": 727,
    "preview": "#!/bin/bash\n# generate a fake /proc/net with a limited set of files\n# which are used for netdata metrics collection\nOUTP"
  },
  {
    "path": "package.json",
    "chars": 709,
    "preview": "{\n  \"name\": \"netdata\",\n  \"version\": \"0.0.10\",\n  \"description\": \"Netdata monitors your server with thoughts of performanc"
  },
  {
    "path": "releases/dev/Dockerfile.build",
    "chars": 116,
    "preview": "FROM debian:jessie\n\nADD scripts/build.sh /build.sh\nRUN chmod +x /build.sh && sync && sleep 1 && /build.sh\n\nWORKDIR /"
  },
  {
    "path": "releases/dev/Dockerfile.run",
    "chars": 260,
    "preview": "FROM titpetric/netdata-build\n\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run.sh && sync && sleep 1\n\nWORKDIR /\n\nENV NETDAT"
  },
  {
    "path": "releases/dev/Makefile",
    "chars": 191,
    "preview": "build:\n\tdocker build --rm --no-cache=true -t titpetric/netdata-build -f Dockerfile.build .\n\nrun:\n\tdocker build --rm --no"
  },
  {
    "path": "releases/latest/Dockerfile",
    "chars": 365,
    "preview": "FROM debian:stretch\n\nADD git-tag /git-tag\n\nADD scripts/build.sh /build.sh\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run."
  },
  {
    "path": "releases/latest/git-tag",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "releases/latest/scripts/build.sh",
    "chars": 1625,
    "preview": "#!/bin/bash\nset -e\nDEBIAN_FRONTEND=noninteractive\n\n# some mirrors have issues, i skipped httpredir in favor of an eu mir"
  },
  {
    "path": "releases/latest/scripts/run.sh",
    "chars": 4001,
    "preview": "#!/bin/bash\n\n# fix permissions due to netdata running as root\nchown root:root /usr/share/netdata/web/ -R\necho -n \"\" > /u"
  },
  {
    "path": "releases/v1.10.0/Dockerfile",
    "chars": 356,
    "preview": "FROM debian:jessie\n\nADD git-tag /git-tag\n\nADD scripts/build.sh /build.sh\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run.s"
  },
  {
    "path": "releases/v1.10.0/README.md",
    "chars": 13904,
    "preview": "# netdata\n\nDockerfile for building and running a netdata deamon for your host instance.\n\nNetdata monitors your server wi"
  },
  {
    "path": "releases/v1.10.0/git-tag",
    "chars": 8,
    "preview": "v1.10.0\n"
  },
  {
    "path": "releases/v1.10.0/scripts/build.sh",
    "chars": 1494,
    "preview": "#!/bin/bash\nset -e\nDEBIAN_FRONTEND=noninteractive\n\n# some mirrors have issues, i skipped httpredir in favor of an eu mir"
  },
  {
    "path": "releases/v1.10.0/scripts/run.sh",
    "chars": 3870,
    "preview": "#!/bin/bash\n\n# fix permissions due to netdata running as root\nchown root:root /usr/share/netdata/web/ -R\necho -n \"\" > /u"
  },
  {
    "path": "releases/v1.4.0/Dockerfile",
    "chars": 326,
    "preview": "FROM debian:jessie\n\nADD git-tag /git-tag\n\nADD scripts/build.sh /build.sh\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run.s"
  },
  {
    "path": "releases/v1.4.0/git-tag",
    "chars": 7,
    "preview": "v1.4.0\n"
  },
  {
    "path": "releases/v1.4.0/scripts/build.sh",
    "chars": 1488,
    "preview": "#!/bin/bash\nset -e\nDEBIAN_FRONTEND=noninteractive\n\n# some mirrors have issues, i skipped httpredir in favor of an eu mir"
  },
  {
    "path": "releases/v1.4.0/scripts/run.sh",
    "chars": 2414,
    "preview": "#!/bin/bash\n\n# fix permissions due to netdata running as root\nchown root:root /usr/share/netdata/web/ -R\necho -n \"\" > /u"
  },
  {
    "path": "releases/v1.5.0/Dockerfile",
    "chars": 326,
    "preview": "FROM debian:jessie\n\nADD git-tag /git-tag\n\nADD scripts/build.sh /build.sh\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run.s"
  },
  {
    "path": "releases/v1.5.0/git-tag",
    "chars": 7,
    "preview": "v1.5.0\n"
  },
  {
    "path": "releases/v1.5.0/scripts/build.sh",
    "chars": 1488,
    "preview": "#!/bin/bash\nset -e\nDEBIAN_FRONTEND=noninteractive\n\n# some mirrors have issues, i skipped httpredir in favor of an eu mir"
  },
  {
    "path": "releases/v1.5.0/scripts/run.sh",
    "chars": 2414,
    "preview": "#!/bin/bash\n\n# fix permissions due to netdata running as root\nchown root:root /usr/share/netdata/web/ -R\necho -n \"\" > /u"
  },
  {
    "path": "releases/v1.6.0/Dockerfile",
    "chars": 326,
    "preview": "FROM debian:jessie\n\nADD git-tag /git-tag\n\nADD scripts/build.sh /build.sh\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run.s"
  },
  {
    "path": "releases/v1.6.0/git-tag",
    "chars": 7,
    "preview": "v1.6.0\n"
  },
  {
    "path": "releases/v1.6.0/scripts/build.sh",
    "chars": 1488,
    "preview": "#!/bin/bash\nset -e\nDEBIAN_FRONTEND=noninteractive\n\n# some mirrors have issues, i skipped httpredir in favor of an eu mir"
  },
  {
    "path": "releases/v1.6.0/scripts/run.sh",
    "chars": 2414,
    "preview": "#!/bin/bash\n\n# fix permissions due to netdata running as root\nchown root:root /usr/share/netdata/web/ -R\necho -n \"\" > /u"
  },
  {
    "path": "releases/v1.7.0/Dockerfile",
    "chars": 326,
    "preview": "FROM debian:jessie\n\nADD git-tag /git-tag\n\nADD scripts/build.sh /build.sh\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run.s"
  },
  {
    "path": "releases/v1.7.0/git-tag",
    "chars": 7,
    "preview": "v1.7.0\n"
  },
  {
    "path": "releases/v1.7.0/scripts/build.sh",
    "chars": 1488,
    "preview": "#!/bin/bash\nset -e\nDEBIAN_FRONTEND=noninteractive\n\n# some mirrors have issues, i skipped httpredir in favor of an eu mir"
  },
  {
    "path": "releases/v1.7.0/scripts/run.sh",
    "chars": 3837,
    "preview": "#!/bin/bash\n\n# fix permissions due to netdata running as root\nchown root:root /usr/share/netdata/web/ -R\necho -n \"\" > /u"
  },
  {
    "path": "releases/v1.8.0/Dockerfile",
    "chars": 326,
    "preview": "FROM debian:jessie\n\nADD git-tag /git-tag\n\nADD scripts/build.sh /build.sh\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run.s"
  },
  {
    "path": "releases/v1.8.0/git-tag",
    "chars": 7,
    "preview": "v1.8.0\n"
  },
  {
    "path": "releases/v1.8.0/scripts/build.sh",
    "chars": 1488,
    "preview": "#!/bin/bash\nset -e\nDEBIAN_FRONTEND=noninteractive\n\n# some mirrors have issues, i skipped httpredir in favor of an eu mir"
  },
  {
    "path": "releases/v1.8.0/scripts/run.sh",
    "chars": 3837,
    "preview": "#!/bin/bash\n\n# fix permissions due to netdata running as root\nchown root:root /usr/share/netdata/web/ -R\necho -n \"\" > /u"
  },
  {
    "path": "releases/v1.9.0/Dockerfile",
    "chars": 356,
    "preview": "FROM debian:jessie\n\nADD git-tag /git-tag\n\nADD scripts/build.sh /build.sh\nADD scripts/run.sh /run.sh\n\nRUN chmod +x /run.s"
  },
  {
    "path": "releases/v1.9.0/git-tag",
    "chars": 7,
    "preview": "v1.9.0\n"
  },
  {
    "path": "releases/v1.9.0/scripts/build.sh",
    "chars": 1488,
    "preview": "#!/bin/bash\nset -e\nDEBIAN_FRONTEND=noninteractive\n\n# some mirrors have issues, i skipped httpredir in favor of an eu mir"
  },
  {
    "path": "releases/v1.9.0/scripts/run.sh",
    "chars": 3870,
    "preview": "#!/bin/bash\n\n# fix permissions due to netdata running as root\nchown root:root /usr/share/netdata/web/ -R\necho -n \"\" > /u"
  },
  {
    "path": "update-releases.sh",
    "chars": 1181,
    "preview": "#!/bin/bash\n#\n# It should go without saying, this script is for development/deployment purposes\n# only. If a new tag is "
  }
]

About this extraction

This page contains the full source code of the titpetric/netdata GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 43 files (79.4 KB), approximately 24.0k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!