This commit is contained in:
2021-08-24 14:35:11 +03:00
parent d8fba9335d
commit 4f37cb59b1
107 changed files with 3941 additions and 66 deletions

View File

@@ -0,0 +1,47 @@
## 1.4.0 - 2021-04-02
* 🔨 Use ghcr.io/home-assistant for base images
* 🔼 Update docker to `12.20.1-r1`
## 1.3.1 - 2021-03-17
* 🐛 Specifiy own S6 entrypoint, don't rely on the base image.
* 🔼 Update git to `2.30.2-r0`
## 1.3.0 - 2021-02-27
* 🔼 Update alpine to `3.13`
* 🔼 Update git to `2.30.1-r0`
* 🔼 Update npm/nodejs to `14.16.0-r0`
* 🔼 Update python2 to `2.7.18-r1`
* 🔼 Update g++ to `20.10.3-r0`
* 🔼 Update docker to `12.20.1-r0`
* 🔼 Update sqlite to `3.34.1-r0`
## 1.2.0 - 2021-01-15
* 🧪 Mark addon as experimental. It fills up all the available memory when running, see [Readme](https://github.com/Poeschl/Hassio-Addons/blob/master/container-stats/README.md).
* 🔼 Update npm to `12.20.1-r0`
## 1.1.1 - 2020-12-16
* 🐛 Fix database location
* 🔨 Create a persistence setting
## 1.1.0 - 2020-12-16
* 🔨 Make statistics persistent
## 1.0.1 - 2020-12-03
* 🔨 Fixed link to Github
## 1.0.0 - 2019-11-27
* Introduced container-stats addon

21
container-stats/DOCS.md Normal file
View File

@@ -0,0 +1,21 @@
## Precondition
Unfortunately there is now way to access the docker api without disabling the *Protection Mode* of the addon.
Technically with disabling it, the addon can access and control other addons and the core on a HA supervised system.
But without it we can not retrieve the statistics of the running container and this addon don't work at all.
To make the addon work you have to disable the *Protection Mode* on the addon details page.
**Only do this if you know what this means to your system**
If you want to review the source of the contained application [here is your link](https://github.com/virtualzone/docker-container-stats).
At the time of writing all docker related code is in `stats.js`.
## Config
### `persistent`
Enable persistence of the collected data. If disabled the data vanish on addon stop.
### `update_interval` (Optional)
Set a custom update interval for the data in seconds. Defaults to `60` seconds.

View File

@@ -0,0 +1,45 @@
ARG BUILD_FROM
FROM $BUILD_FROM AS REPOSITORY
RUN apk --update add --no-cache \
git=2.30.2-r0
ENV COMMIT_SHA '586ebebf16195bfab7ffd2b3dbc4344077e72a05'
# hadolint ignore=DL3003
RUN git clone https://github.com/virtualzone/docker-container-stats.git -b master /container-stats && \
cd /container-stats && git checkout $COMMIT_SHA
FROM $BUILD_FROM AS BUILD
RUN apk --update add --no-cache \
npm=14.16.0-r0 \
python2=2.7.18-r1 \
make=4.3-r0 \
g++=10.2.1_pre1-r3
WORKDIR /container-stats
RUN npm update && \
npm install \
express@4.17.1 \
sqlite3@5.0.0 \
body-parser@1.19.0 \
moment@2.29.1
FROM $BUILD_FROM AS RUNNING
RUN apk --update add --no-cache \
nodejs=14.16.0-r0 \
docker=20.10.3-r1 \
sqlite=3.34.1-r0
COPY --from=BUILD /container-stats /container-stats
COPY --from=REPOSITORY /container-stats/stats.js /container-stats
COPY --from=REPOSITORY /container-stats/httpd.js /container-stats
COPY --from=REPOSITORY /container-stats/html /container-stats/html
ENTRYPOINT [ "/init" ]
CMD []
COPY root /

39
container-stats/README.md Normal file
View File

@@ -0,0 +1,39 @@
# Docker Container Stats (Home Assistant Addon)
It contains [Docker Container Stats](https://github.com/virtualzone/docker-container-stats) to monitor all running containers / addons.
![Addon Stage][stage-badge]
![Supports aarch64 Architecture][aarch64-badge]
![Supports amd64 Architecture][amd64-badge]
![Supports armhf Architecture][armhf-badge]
![Supports armv7 Architecture][armv7-badge]
![Supports i386 Architecture][i386-badge]
[![Install on my Home Assistant][install-badge]][install-url]
[![Donate][donation-badge]][donation-url]
## 🧪 Experimental Addon
During long-term usage I noticed that the addon fills up all available memory when getting the data for a week.
Especially on a Raspberry Pi with Home Assistant this means death in a few minutes.
__Use this addon on your own risk!__
## Security
Since the addon accesses the docker api, the security rating is this low.
Unfortunately there is now way to access the docker api without disabling the *Protection Mode* of the addon.
Technically with disabling it, the addon can access and control other addons and the core on a HA supervised system.
But without it we can not retrieve the statistics of the running container and this addon don't work at all.
[aarch64-badge]: https://img.shields.io/badge/aarch64-yes-green.svg?style=for-the-badge
[amd64-badge]: https://img.shields.io/badge/amd64-yes-green.svg?style=for-the-badge
[armhf-badge]: https://img.shields.io/badge/armhf-yes-green.svg?style=for-the-badge
[armv7-badge]: https://img.shields.io/badge/armv7-yes-green.svg?style=for-the-badge
[i386-badge]: https://img.shields.io/badge/i386-yes-green.svg?style=for-the-badge
[install-url]: https://my.home-assistant.io/redirect/supervisor_addon?addon=243ffc37_container-stats
[stage-badge]: https://img.shields.io/badge/Addon%20stage-experimental%20🧪-yellow.svg?style=for-the-badge
[install-badge]: https://img.shields.io/badge/Install%20on%20my-Home%20Assistant-41BDF5?logo=home-assistant&style=for-the-badge
[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=for-the-badge&logoColor=white
[donation-url]: https://www.buymeacoffee.com/Poeschl

View File

@@ -0,0 +1,9 @@
{
"build_from": {
"armhf": "ghcr.io/home-assistant/armhf-base:3.13",
"armv7": "ghcr.io/home-assistant/armv7-base:3.13",
"aarch64": "ghcr.io/home-assistant/aarch64-base:3.13",
"amd64": "ghcr.io/home-assistant/amd64-base:3.13",
"i386": "ghcr.io/home-assistant/i386-base:3.13"
}
}

View File

@@ -0,0 +1,38 @@
{
"name": "Docker Container Stats",
"version": "1.4.0",
"slug": "container-stats",
"description": "🧪 experimental | A web interface for viewing historical and current statistics per docker container",
"url": "https://github.com/Poeschl/Hassio-Addons/tree/master/container-stats",
"arch": [
"armhf",
"armv7",
"aarch64",
"amd64",
"i386"
],
"ingress": true,
"ingress_port": 8080,
"panel_title": "Docker Container Stats",
"panel_icon": "mdi:chart-line",
"startup": "application",
"stage": "experimental",
"boot": "auto",
"docker_api": true,
"image": "ghcr.io/poeschl/ha-container-stats-{arch}",
"ports": {
"8080/tcp": null
},
"ports_description": {
"8080/tcp": "Web Interface (Not required for Supervisor Ingress)"
},
"map": [],
"schema": {
"update_interval": "int?",
"persistent": "bool"
},
"options": {
"persistent": "true"
}
}

BIN
container-stats/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
container-stats/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -0,0 +1,18 @@
#!/usr/bin/with-contenv bashio
set -e
bashio::log.info 'Start docker statistics'
if bashio::config.has_value 'update_interval'; then
export STATS_UPDATE_INTERVAL=$(bashio::config 'update_interval')
fi
if [ ! -d /container-stats/db ] && bashio::config 'persistent'; then
[ ! -d /data/db ] && mkdir -p /data/db
ln -s /data/db/ /container-stats/db
else
mkdir -p /container-stats/db
fi
cd /container-stats
node stats.js

View File

@@ -0,0 +1,11 @@
#!/usr/bin/with-contenv bashio
set -e
if [ ! -d /container-stats/db ]; then
bashio::log.debug 'Wait for database'
sleep 2s
fi
bashio::log.info 'Start webserver'
cd /container-stats
node httpd.js