├── .gitignore ├── renovate.json ├── .github ├── release-drafter.yml ├── sabubot.yml └── workflows │ ├── build.yml │ └── tag.yml ├── .idea ├── php.xml ├── encodings.xml ├── misc.xml ├── vcs.xml ├── modules.xml └── hassio-telegraf.iml ├── PULL_REQUEST_TEMPLATE.md ├── ISSUE_TEMPLATE.md ├── telegraf ├── build.json ├── rootfs │ ├── etc │ │ ├── services.d │ │ │ └── telegraf │ │ │ │ ├── finish │ │ │ │ └── run │ │ └── cont-init.d │ │ │ └── telegraf.sh │ └── bin │ │ └── s6-nuke ├── Dockerfile ├── config.json └── run.sh ├── .vscode └── tasks.json ├── .devcontainer └── devcontainer.json ├── LICENSE.md ├── README.md.save └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | template: | 2 | ## What’s Changed 3 | 4 | $CHANGES 5 | -------------------------------------------------------------------------------- /.idea/php.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Fix or Feature Request? 2 | 3 | 4 | 5 | # What does this solve 6 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #Type of Issue 2 | 3 | 4 | #Description of issue 5 | 6 | 7 | #Ideas to fix 8 | 9 | 10 | 11 | # Logs 12 | 13 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/hassio-telegraf.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /telegraf/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "build_from": { 3 | "aarch64": "ghcr.io/hassio-addons/debian-base/aarch64:6.0.0", 4 | "amd64": "ghcr.io/hassio-addons/debian-base/amd64:6.0.0", 5 | "armv7": "ghcr.io/hassio-addons/debian-base/armv7:6.0.0", 6 | "i386": "ghcr.io/hassio-addons/debian-base/i386:6.0.0" 7 | }, 8 | "args": { 9 | "TELEGRAF_VERSION": "1.26.0" 10 | } 11 | } -------------------------------------------------------------------------------- /telegraf/rootfs/etc/services.d/telegraf/finish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/execlineb -S0 2 | # ============================================================================== 3 | # Home Assistant Community Add-on: Telegraf 4 | # ============================================================================== 5 | if -n { s6-test $# -ne 0 } 6 | if -n { s6-test ${1} -eq 256 } 7 | 8 | s6-svscanctl -t /var/run/s6/services 9 | -------------------------------------------------------------------------------- /telegraf/rootfs/etc/services.d/telegraf/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bashio 2 | # ============================================================================== 3 | # Home Assistant Community Add-on: Example 4 | # Runs example1 script 5 | # ============================================================================== 6 | 7 | 8 | bashio::log.info "Starting Telegraf" 9 | 10 | exec telegraf 11 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Start Home Assistant", 6 | "type": "shell", 7 | "command": "supervisor_run", 8 | "group": { 9 | "kind": "test", 10 | "isDefault": true 11 | }, 12 | "presentation": { 13 | "reveal": "always", 14 | "panel": "new" 15 | }, 16 | "problemMatcher": [] 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /telegraf/rootfs/bin/s6-nuke: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # ============================================================================== 3 | # Home Assistant Community Add-on: Glances 4 | # This file turns s6-nuke into a NOOP to prevent total termination 5 | # of the host system since the add-on runs in the same PID namespace. 6 | # ============================================================================== 7 | echo "S6-NUKE: NOOP" 8 | exit 0 -------------------------------------------------------------------------------- /.github/sabubot.yml: -------------------------------------------------------------------------------- 1 | settings: 2 | add-owner-assignee: true 3 | add-owner-reviewer: true 4 | process-closed-issues: true 5 | remove-labels: true 6 | remove-keyword-labels: true 7 | close-issues: true 8 | move-issues: true 9 | move-prs: false 10 | move-labels: true 11 | 12 | title-keyword-labels: 13 | in-progress: ["WiP"] 14 | chore: ["chore"] 15 | bugfix: ["bug","bugfix","fix"] 16 | feature: ["feature"] 17 | enhancement: ["enhancement"] 18 | 19 | delete_closed_pr: true 20 | help: false 21 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Docker build and shellcheck 2 | 3 | on: [push, pull_request] 4 | 5 | 6 | jobs: 7 | build: 8 | 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v1 13 | - name: shellcheck 14 | run: shellcheck telegraf/run.sh 15 | - name: build docker files 16 | uses: home-assistant/builder@master 17 | with: 18 | args: | 19 | --test \ 20 | --all \ 21 | --target telegraf \ 22 | --docker-hub sabuto \ 23 | --docker-user sabuto \ 24 | --docker-password ${{ secrets.DOCKER_PASSWORD }} 25 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Telegraf Addon for Home Assistant", 3 | "image": "ghcr.io/home-assistant/devcontainer:addons", 4 | "appPort": [ 5 | "7123:8123", 6 | "7357:4357" 7 | ], 8 | "postStartCommand": "bash devcontainer_bootstrap", 9 | "runArgs": [ 10 | "-e", 11 | "GIT_EDITOR=code --wait", 12 | "--privileged" 13 | ], 14 | "containerEnv": { 15 | "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" 16 | }, 17 | "customizations": { 18 | "extensions": [ 19 | "timonwong.shellcheck", 20 | "esbenp.prettier-vscode" 21 | ], 22 | "settings": { 23 | "terminal.integrated.profiles.linux": { 24 | "zsh": { 25 | "path": "/usr/bin/zsh" 26 | } 27 | }, 28 | "terminal.integrated.defaultProfile.linux": "zsh", 29 | "editor.formatOnPaste": false, 30 | "editor.formatOnSave": true, 31 | "editor.formatOnType": true, 32 | "files.trimTrailingWhitespace": true 33 | } 34 | }, 35 | "mounts": [ 36 | "type=volume,target=/var/lib/docker" 37 | ], 38 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 Robert Dunne 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/tag.yml: -------------------------------------------------------------------------------- 1 | name: build and deploy 2 | 3 | on: release 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: shellcheck 13 | run: shellcheck telegraf/run.sh 14 | - name: build docker files 15 | uses: home-assistant/builder@master 16 | with: 17 | args: | 18 | --all \ 19 | --target telegraf \ 20 | --docker-hub sabuto \ 21 | --docker-user sabuto \ 22 | --docker-password ${{ secrets.DOCKER_PASSWORD }} 23 | 24 | push-config-to-main-repo: 25 | needs: build 26 | 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - name: main 31 | uses: actions/checkout@v2 32 | with: 33 | persist-credentials: false 34 | fetch-depth: 0 35 | path: main 36 | - name: secondary 37 | uses: actions/checkout@v2 38 | with: 39 | persist-credentials: false 40 | fetch-depth: 0 41 | path: secondary 42 | repository: sabuto/hassio-repo 43 | 44 | - name: setup local env 45 | run: | 46 | \cp -Rv main/telegraf/config.json secondary/telegraf/config.json 47 | \cp -Rv main/README.md secondary/telegraf/README.md 48 | cd secondary 49 | git config --local user.email "robe_dunne@hotmail.com" 50 | git config --local user.name "sabuto" 51 | git add . 52 | git commit -m "Add changes" 53 | continue-on-error: true 54 | 55 | - name: copy config to repo dir in case of change 56 | uses: ad-m/github-push-action@master 57 | with: 58 | github_token: ${{ secrets.GITHUB_PSA }} 59 | repository: sabuto/hassio-repo 60 | directory: secondary 61 | -------------------------------------------------------------------------------- /telegraf/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG BUILD_FROM=ghcr.io/hassio-addons/debian-base/amd64:6.0.0 2 | # hadolint ignore=DL3006 3 | FROM ${BUILD_FROM} 4 | 5 | # Set shell 6 | SHELL ["/bin/bash", "-o", "pipefail", "-c"] 7 | 8 | # Setup base system 9 | ARG BUILD_ARCH=amd64 10 | 11 | ARG TELEGRAF_VERSION 12 | 13 | # Setup base 14 | RUN \ 15 | apt-get update \ 16 | && apt-get install -y --no-install-recommends \ 17 | iputils-ping snmp procps lm-sensors smartmontools ipmitool \ 18 | && ARCH="${BUILD_ARCH}" \ 19 | && if [ "${BUILD_ARCH}" = "aarch64" ]; then ARCH="arm64"; fi \ 20 | && if [ "${BUILD_ARCH}" = "armv7" ]; then ARCH="armhf"; fi \ 21 | && curl -J -L -o /tmp/telegraf.deb \ 22 | "https://dl.influxdata.com/telegraf/releases/telegraf_${TELEGRAF_VERSION}-1_${ARCH}.deb" \ 23 | && dpkg --install /tmp/telegraf.deb \ 24 | && rm -fr \ 25 | /tmp/* \ 26 | /var/{cache,log}/* \ 27 | /var/lib/apt/lists/* 28 | 29 | # Copy root filesystem 30 | COPY rootfs / 31 | 32 | RUN chown root /etc/cont-init.d/telegraf.sh 33 | RUN chown root /etc/telegraf/telegraf.conf 34 | RUN chown root /etc/services.d/telegraf/run 35 | RUN chown root /etc/services.d/telegraf/finish 36 | RUN chmod 775 /etc/cont-init.d/telegraf.sh 37 | RUN chmod 775 /etc/telegraf/telegraf.conf 38 | RUN chmod 775 /etc/services.d/telegraf/run 39 | RUN chmod 775 /etc/services.d/telegraf/finish 40 | 41 | EXPOSE 8092/udp 8094 8125/udp 9273/tcp 42 | 43 | # Build arguments 44 | ARG BUILD_ARCH 45 | ARG BUILD_DATE 46 | ARG BUILD_DESCRIPTION 47 | ARG BUILD_NAME 48 | ARG BUILD_REF 49 | ARG BUILD_REPOSITORY 50 | ARG BUILD_VERSION 51 | 52 | # Labels 53 | LABEL \ 54 | io.hass.name="${BUILD_NAME}" \ 55 | io.hass.description="${BUILD_DESCRIPTION}" \ 56 | io.hass.arch="${BUILD_ARCH}" \ 57 | io.hass.type="addon" \ 58 | io.hass.version=${BUILD_VERSION} \ 59 | maintainer="Sacrementus" \ 60 | org.opencontainers.image.title="${BUILD_NAME}" \ 61 | org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ 62 | org.opencontainers.image.vendor="Sacrementus's addons" \ 63 | org.opencontainers.image.authors="Sacrementus" \ 64 | org.opencontainers.image.licenses="MIT" \ 65 | org.opencontainers.image.created=${BUILD_DATE} \ 66 | org.opencontainers.image.revision=${BUILD_REF} \ 67 | org.opencontainers.image.version=${BUILD_VERSION} 68 | -------------------------------------------------------------------------------- /README.md.save: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Telegraf Plugin for Hassio 4 | 5 | This is a very simple hassio plugin that ebnables you to run telegraf on your hassio system, I am still working on this so please bear with me, I am happy to accept PR's 6 | 7 | # Installation 8 | 9 | To Install this addon simply go to: Hassio->Addon-store. 10 | 11 | Then add https://github.com/Sabuto/hassio-repo in the add repository by URL box. 12 | 13 | Scroll down to Rob's Repo and install Telegraf. Give it a few minutes to install and update. 14 | 15 | # Config 16 | 17 | The config is simple but there are some things to consider, 18 | 19 | You must have a running influxDB instance (the hassio plugin works) 20 | 21 | ```bash 22 | influxDB 23 | ``` 24 | 25 | This allows you to specify the location and port for your influxDB instance (the port must be specified) 26 | 27 | ```bash 28 | influx_db 29 | ``` 30 | 31 | This is the database within influxDB to use (you may need to create this) 32 | 33 | ```bash 34 | influx_user 35 | ``` 36 | 37 | This is the username telegraf will use to communicate with InfluxDB 38 | 39 | ```bash 40 | influx_pw 41 | ``` 42 | 43 | This is the password to coinside with the username 44 | 45 | ```bash 46 | retention_policy 47 | ``` 48 | 49 | This is the retention policy to use (again you may need to specify this when setting up the db) 50 | 51 | ```bash 52 | docker : { 53 | enabled: false 54 | timeout: 5s 55 | } 56 | ``` 57 | 58 | This allows you to monitor your docker containers, the timeout allows you to specify how long it should try before connection is dropped *PLEASE NOTE: IN ORDER TO DO THIS YOU MUST TURN OFF PROTECTION MODE* 59 | 60 | 61 | ```bash 62 | smart_monitor : { 63 | enabled: false 64 | timeout : "30s" 65 | } 66 | ``` 67 | 68 | This allows you to monitor the temperature of the hard drives 69 | 70 | # Known issues 71 | 72 | ~~For some reason at the moment i have figured out how to communicate with the docker.sock therefore i cannot get the process' for docker contaisners. I will look into this and fix it when i can, if you have any idea please submit a PR~~ 73 | 74 | # TO-DO 75 | 76 | ~~Add dev branch~~ 77 | 78 | Add images to installation steps 79 | 80 | Add PR Template 81 | 82 | ~~Add Issue Template~~ 83 | 84 | Configure more options to edit for the inputs 85 | 86 | Configure different outputs (so it doesn't have to be influxDB dependant, would appreciate it if people could reccomend ones they would find useful.) 87 | 88 | 89 | [aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg 90 | [amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg 91 | [armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg 92 | [armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg 93 | [commits-shield]: https://img.shields.io/github/commit-activity/y/sabuto/hassio-telegraf?style=plastic 94 | -------------------------------------------------------------------------------- /telegraf/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Telegraf", 3 | "version": "1.0.0", 4 | "slug": "hassio_telegraf", 5 | "description": "An addon to add telegraf to hassio.", 6 | "url": "https://github.com/Sabuto/hassio-telegraf", 7 | "arch": [ 8 | "armhf", 9 | "armv7", 10 | "aarch64", 11 | "amd64", 12 | "i386" 13 | ], 14 | "init": false, 15 | "startup": "services", 16 | "boot": "manual", 17 | "hassio_api": true, 18 | "hassio_role": "default", 19 | "auth_api": true, 20 | "docker_api": true, 21 | "host_network": true, 22 | "apparmor": false, 23 | "map": [ 24 | "config:rw", 25 | "ssl:rw", 26 | "addons:rw", 27 | "backup:rw", 28 | "share:rw" 29 | ], 30 | "privileged": [ 31 | "SYS_ADMIN" 32 | ], 33 | "full_access": true, 34 | "options": { 35 | "custom_conf": { 36 | "enabled": false, 37 | "location": "/share/telegraf.conf" 38 | }, 39 | "hostname": "test", 40 | "influxDB": { 41 | "enabled": true, 42 | "url": "http://a0d7b954-influxdb:8086", 43 | "db": "telegraf" 44 | }, 45 | "kernel": { 46 | "enabled": true 47 | }, 48 | "swap": { 49 | "enabled": true 50 | }, 51 | "docker": { 52 | "enabled": false, 53 | "timeout": "5s" 54 | }, 55 | "thermal": { 56 | "enabled": false 57 | }, 58 | "smart_monitor": { 59 | "enabled": false, 60 | "timeout": "30s" 61 | }, 62 | "ipmi_sensor": { 63 | "enabled": false, 64 | "interval": "30s", 65 | "timeout": "20s", 66 | "server_user_id": "user", 67 | "server_password": "password", 68 | "server_protocol": "lan", 69 | "server_ip": "192.168.1.2" 70 | }, 71 | "influxDBv2": { 72 | "enabled": false, 73 | "url": "http://127.0.0.1:9999", 74 | "organization": "", 75 | "token": "", 76 | "bucket": "" 77 | }, 78 | "prometheus": { 79 | "enabled": false, 80 | "metrics_path": "/metrics" 81 | } 82 | }, 83 | "schema": { 84 | "custom_conf": { 85 | "enabled": "bool", 86 | "location": "str" 87 | }, 88 | "hostname": "str", 89 | "influxDB": { 90 | "enabled": "bool", 91 | "url": "str", 92 | "db": "str", 93 | "retention_policy": "str?", 94 | "username": "str?", 95 | "password": "str?" 96 | }, 97 | "kernel": { 98 | "enabled": "bool" 99 | }, 100 | "swap": { 101 | "enabled": "bool" 102 | }, 103 | "docker": { 104 | "enabled": "bool", 105 | "timeout": "str" 106 | }, 107 | "thermal": { 108 | "enabled": "bool" 109 | }, 110 | "smart_monitor": { 111 | "enabled": "bool", 112 | "timeout": "str" 113 | }, 114 | "ipmi_sensor": { 115 | "enabled": "bool", 116 | "interval": "str", 117 | "timeout": "str", 118 | "server_user_id": "str", 119 | "server_password": "str", 120 | "server_protocol": "str", 121 | "server_ip": "str" 122 | }, 123 | "influxDBv2": { 124 | "enabled": "bool", 125 | "url": "str", 126 | "organization": "str", 127 | "token": "str", 128 | "bucket": "str" 129 | }, 130 | "prometheus": { 131 | "enabled": "bool", 132 | "metrics_path": "str" 133 | } 134 | }, 135 | "ports": { 136 | "9273/tcp": 9273 137 | }, 138 | "image": "sabuto/{arch}-hassio-telegraf" 139 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Telegraf Plugin for Hassio 2 | 3 | [![GitHub Release][releases-shield]][releases] 4 | [![License][license-shield]](LICENSE.md) 5 | 6 | ![Supports aarch64 Architecture][aarch64-shield] 7 | ![Supports amd64 Architecture][amd64-shield] 8 | ![Supports armhf Architecture][armhf-shield] 9 | ![Supports armv7 Architecture][armv7-shield] 10 | ![Supports i386 Architecture][i386-shield] 11 | 12 | ![Travis Ci][travis-shield] 13 | [![Github Activity][commits-shield]][commits] 14 | 15 | # Please Note! 16 | Upgrading to 0.5.0 although isn't nessaserily a breaking change, hte config has been adjusted and how it is interprited so please make sure you update the config too! 17 | 18 | # Notable mentions 19 | 20 | I wanted to mention people/repos that i have borrowed code from to make this work and also who have helped me make this work. 21 | 22 | First I wanted to say thanks to [@pvizeli](https://github.com/pvizeli). He helped me with regard to building the image. and just the general work he does on a daily basis 23 | 24 | Second I want to say thanks to [@Frenck](https://github.com/frenck). He has helped me a lot on Discord getting this addon working when i was running into errors. His addon for influx db helped me migrate this from Alpine to ubuntu also. 25 | 26 | Third I want to say thanks to [@Daniel Welch](https://github.com/danielwelch). I looked at his script for travis builds, he did a write up [here](https://danielwelch.github.io/hassio-dev-env.html) that helped me form a basis of my script. 27 | 28 | All of these people are amazing! 29 | 30 | # Description 31 | 32 | This is a very simple hassio plugin that ebnables you to run telegraf on your hassio system, I am still working on this so please bear with me, I am happy to accept PR's 33 | 34 | # Installation 35 | 36 | To Install this addon simply go to: Hassio->Addon-store. 37 | 38 | Then add https://github.com/Sabuto/hassio-repo in the add repository by URL box. 39 | 40 | Scroll down to Rob's Repo and install Telegraf. Give it a few minutes to install and update. 41 | 42 | # Config 43 | 44 | The config is simple but there are some things to consider, 45 | 46 | ```yaml 47 | custom_conf: 48 | enabled: false 49 | location: /share/telegraf.conf 50 | ``` 51 | 52 | This allows you to specify a custom configuration file so you can add things for yourself if this addon doesn't currently support it. Please note this must be a full telegraf config file not just parts. 53 | 54 | ```yaml 55 | hostname: '' 56 | ``` 57 | This allows you set your hostname to something easy 58 | 59 | You must have a running influxDB instance (the hassio plugin works) 60 | 61 | ```yaml 62 | influxDB: 63 | enabled: true, 64 | url: 'http://a0d7b954-influxdb:8086' 65 | db: telegraf 66 | retention_policy: optional 67 | username: optional 68 | password: optional 69 | ``` 70 | This has been moved into it's own block as that made sense with the other options, some have been made optional (previous versions) 71 | 72 | 73 | ```yaml 74 | kernel: 75 | enabled: true 76 | ``` 77 | 78 | This monitors the kernel 79 | 80 | ```yaml 81 | swap: 82 | enabled: true 83 | ``` 84 | 85 | This monitors the swap usasge 86 | 87 | ```yaml 88 | docker: 89 | enabled: false 90 | timeout: 5s 91 | ``` 92 | 93 | This monitors the docker containers 94 | 95 | ```yaml 96 | smart_monitor: 97 | enabled: false 98 | timeout: 30s 99 | ``` 100 | 101 | This allows you to monitor the temperature of the hard drives 102 | 103 | ```yaml 104 | impi_sensor: 105 | enabled: false 106 | interval: 30s 107 | timeout: 20s 108 | server_user_id: user 109 | server_password: password 110 | server_protocol: lan 111 | server_ip: 192.168.1.2 112 | ``` 113 | 114 | This allows you to enable the impi settings. 115 | 116 | ```yaml 117 | influxDBv2: 118 | enabled: false 119 | url: 'http://127.0.0.1:9999' 120 | organization: '' 121 | token: '' 122 | bucket: '' 123 | ``` 124 | 125 | This allows you to use InfluxDBv2 if you have an instance running. 126 | 127 | ```yaml 128 | prometheus: 129 | enabled: false 130 | metrics_path: '/metrics' 131 | ``` 132 | This allows you to use the promethus output 133 | 134 | # Known issues 135 | 136 | ~~For some reason at the moment i have figured out how to communicate with the docker.sock therefore i cannot get the process' for docker contaisners. I will look into this and fix it when i can, if you have any idea please submit a PR~~ 137 | 138 | # TO-DO 139 | 140 | ~~Add dev branch~~ 141 | 142 | Add images to installation steps 143 | 144 | ~~Add PR Template~~ 145 | 146 | ~~Add Issue Template~~ 147 | 148 | Configure more options to edit for the inputs 149 | 150 | Configure different outputs (so it doesn't have to be influxDB dependant, would appreciate it if people could reccomend ones they would find useful.) 151 | 152 | ## License 153 | 154 | MIT License 155 | 156 | Copyright (c) 2019 Robert Dunne 157 | 158 | Permission is hereby granted, free of charge, to any person obtaining a copy 159 | of this software and associated documentation files (the "Software"), to deal 160 | in the Software without restriction, including without limitation the rights 161 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 162 | copies of the Software, and to permit persons to whom the Software is 163 | furnished to do so, subject to the following conditions: 164 | 165 | The above copyright notice and this permission notice shall be included in all 166 | copies or substantial portions of the Software. 167 | 168 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 169 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 170 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 171 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 172 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 173 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 174 | SOFTWARE. 175 | 176 | [aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg 177 | [amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg 178 | [armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg 179 | [armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg 180 | [i386-shield]: https://img.shields.io/badge/i386-yes-green.svg 181 | [commits-shield]: https://img.shields.io/github/commit-activity/y/sabuto/hassio-telegraf?style=plastic 182 | [commits]: https://github.com/sabuto/hassio-telegraf/commits/master 183 | [travis-shield]: https://img.shields.io/travis/sabuto/hassio-telegraf 184 | [releases-shield]: https://img.shields.io/github/v/release/sabuto/hassio-telegraf 185 | [releases]: https://github.com/sabuto/hassio-telegraf/releases 186 | [license-shield]: https://img.shields.io/github/license/sabuto/hassio-telegraf 187 | -------------------------------------------------------------------------------- /telegraf/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bashio 2 | declare influx_un 3 | declare influx_pw 4 | declare influx_ret 5 | declare hostname 6 | bashio::require.unprotected 7 | 8 | readonly CONFIG="/etc/telegraf/telegraf.conf" 9 | 10 | HOSTNAME=$(bashio::config 'hostname') 11 | INFLUX_SERVER=$(bashio::config 'influxDB.url') 12 | INFLUX_DB=$(bashio::config 'influxDB.db') 13 | INFLUX_UN=$(bashio::config 'influxDB.username') 14 | INFLUX_PW=$(bashio::config 'influxDB.password') 15 | INFLUXDBV2_URL=$(bashio::config 'influxDBv2.url') 16 | INFLUXDBV2_TOKEN=$(bashio::config 'influxDBv2.token') 17 | INFLUXDBV2_ORG=$(bashio::config 'influxDBv2.organization') 18 | INFLUXDBV2_BUCKET=$(bashio::config 'influxDBv2.bucket') 19 | RETENTION=$(bashio::config 'influxDB.retention_policy') 20 | DOCKER_TIMEOUT=$(bashio::config 'docker.timeout') 21 | SMART_TIMEOUT=$(bashio::config 'smart_monitor.timeout') 22 | IPMI_USER=$(bashio::config 'ipmi_sensor.server_user_id') 23 | IPMI_PASSWORD=$(bashio::config 'ipmi_sensor.server_password') 24 | IPMI_PROTOCOL=$(bashio::config 'ipmi_sensor.server_protocol') 25 | IPMI_IP=$(bashio::config 'ipmi_sensor.server_ip') 26 | IPMI_INTERVAL=$(bashio::config 'ipmi_sensor.interval') 27 | IPMI_TIMEOUT=$(bashio::config 'ipmi_sensor.timeout') 28 | CUSTOM_CONF_ENABLED=$(bashio::config 'custom_conf.enabled') 29 | CUSTOM_CONF=$(bashio::config 'custom_conf.location') 30 | 31 | 32 | if bashio::var.true "${CUSTOM_CONF_ENABLED}"; then 33 | bashio::log.info "Using custom conf file" 34 | rm /etc/telegraf/telegraf.conf 35 | cp "${CUSTOM_CONF}" /etc/telegraf/telegraf.conf 36 | else 37 | bashio::log.info "Updating config" 38 | 39 | if bashio::var.has_value "${HOSTNAME}"; then 40 | hostname="hostname = 'HOSTNAME'" 41 | else 42 | hostname=" hostname = ''" 43 | fi 44 | 45 | { 46 | echo "[agent]" 47 | echo " interval = \"10s\"" 48 | echo " round_interval = true" 49 | echo " metric_batch_size = 1000" 50 | echo " metric_buffer_limit = 10000" 51 | echo " collection_jitter = \"0s\"" 52 | echo " flush_interval = \"10s\"" 53 | echo " flush_jitter = \"0s\"" 54 | echo " precision = \"\"" 55 | echo " ${hostname}" 56 | echo " omit_hostname = false" 57 | } >> $CONFIG 58 | 59 | sed -i "s,HOSTNAME,${HOSTNAME},g" $CONFIG 60 | 61 | if bashio::config.true 'influxDB.enabled'; then 62 | if bashio::var.has_value "${INFLUX_UN}"; then 63 | influx_un=" username='INFLUX_UN'" 64 | else 65 | influx_un=" # INFLUX_UN" 66 | fi 67 | 68 | if bashio::var.has_value "${INFLUX_PW}"; then 69 | influx_pw=" password='INFLUX_PW'" 70 | else 71 | influx_pw=" # INFLUX_PW" 72 | fi 73 | 74 | if bashio::var.has_value "${RETENTION}"; then 75 | influx_ret=" retention_policy='RETENTION'" 76 | else 77 | influx_ret=" # RETENTION" 78 | fi 79 | 80 | { 81 | echo "[[outputs.influxdb]]" 82 | echo " urls = ['http://a0d7b954-influxdb:8086']" 83 | echo " database = \"TELEGRAF_DB\"" 84 | echo " ${influx_ret}" 85 | echo " timeout = '5s'" 86 | echo " ${influx_un}" 87 | echo " ${influx_pw}" 88 | } >> $CONFIG 89 | 90 | sed -i "s,http://a0d7b954-influxdb:8086,${INFLUX_SERVER},g" $CONFIG 91 | 92 | sed -i "s,TELEGRAF_DB,${INFLUX_DB},g" $CONFIG 93 | 94 | sed -i "s,INFLUX_UN,${INFLUX_UN},g" $CONFIG 95 | 96 | sed -i "s,INFLUX_PW,${INFLUX_PW},g" $CONFIG 97 | 98 | sed -i "s,RETENTION,${RETENTION},g" $CONFIG 99 | 100 | fi 101 | 102 | if bashio::config.true 'kernel.enabled'; then 103 | bashio::log.info "Updating config for Kernel" 104 | { 105 | echo "[[inputs.kernel]]" 106 | } >> $CONFIG 107 | fi 108 | 109 | if bashio::config.true 'swap.enabled'; then 110 | bashio::log.info "Updaing config for Swap" 111 | { 112 | echo "[[inputs.swap]]" 113 | } >> $CONFIG 114 | fi 115 | 116 | if bashio::config.true 'docker.enabled'; then 117 | bashio::log.info "Updating config for Docker" 118 | { 119 | echo "[[inputs.docker]]" 120 | echo " endpoint = 'unix:///var/run/docker.sock'" 121 | echo " timeout = 'DOCKER_TIMEOUT'" 122 | } >> $CONFIG 123 | 124 | sed -i "s,DOCKER_TIMEOUT,${DOCKER_TIMEOUT},g" $CONFIG 125 | fi 126 | 127 | if bashio::config.true 'smart_monitor.enabled'; then 128 | bashio::log.info "Updating config for Smart Monitor" 129 | { 130 | echo "[[inputs.smart]]" 131 | echo " timeout = 'SMART_TIMEOUT'" 132 | } >> $CONFIG 133 | 134 | sed -i "s,SMART_TIMEOUT,${SMART_TIMEOUT},g" $CONFIG 135 | fi 136 | 137 | if bashio::config.true 'ipmi_sensor.enabled'; then 138 | bashio::log.info "Updating config for ipmi sensor" 139 | { 140 | echo "[[inputs.ipmi_sensor]]" 141 | echo " servers = [\"USER_ID:PASSWORD@PROTOCOL(IP)\"]" 142 | echo " interval = 'INTERVAL'" 143 | echo " timeout = 'TIMEOUT'" 144 | } >> $CONFIG 145 | 146 | sed -i "s,USER_ID,${IPMI_USER},g" $CONFIG 147 | sed -i "s,PASSWORD,${IPMI_PASSWORD},g" $CONFIG 148 | sed -i "s,PROTOCOL,${IPMI_PROTOCOL},g" $CONFIG 149 | sed -i "s,IP,${IPMI_IP},g" $CONFIG 150 | sed -i "s,INTERVAL,${IPMI_INTERVAL},g" $CONFIG 151 | sed -i "s,TIMEOUT,${IPMI_TIMEOUT},g" $CONFIG 152 | fi 153 | 154 | if bashio::config.true 'thermal.enabled'; then 155 | bashio::log.info "Updating config for thermal zone sensors" 156 | for i in $(shopt -s nullglob; echo /sys/class/thermal/thermal_zone*); do 157 | bashio::log.info "...$i" 158 | name=$(basename "$i") 159 | { 160 | echo "[[inputs.file]]" 161 | echo " files = [\"$i/temp\"]" 162 | echo " name_override = \"$name\"" 163 | echo " data_format = \"value\"" 164 | echo " data_type = \"integer\"" 165 | } >> $CONFIG 166 | done 167 | fi 168 | 169 | if bashio::config.true 'influxDBv2.enabled'; then 170 | bashio::log.info "Updating config for influxdbv2" 171 | { 172 | echo "[[outputs.influxdb_v2]]" 173 | echo " urls = [\"INFLUXv2_URL\"]" 174 | echo " token = 'INFLUX_TOKEN'" 175 | echo " organization = 'INFLUX_ORG'" 176 | echo " bucket = 'INFLUX_BUCKET'" 177 | } >> $CONFIG 178 | 179 | sed -i "s,INFLUXv2_URL,${INFLUXDBV2_URL},g" $CONFIG 180 | sed -i "s,INFLUX_TOKEN,${INFLUXDBV2_TOKEN},g" $CONFIG 181 | sed -i "s,INFLUX_ORG,${INFLUXDBV2_ORG},g" $CONFIG 182 | sed -i "s,INFLUX_BUCKET,${INFLUXDBV2_BUCKET},g" $CONFIG 183 | fi 184 | 185 | if bashio::config.true 'prometheus.enabled'; then 186 | bashio::log.info "Updating config for prometheus client" 187 | { 188 | echo "[[outputs.prometheus_client]]" 189 | echo " listen = \":9273\"" 190 | echo " path = \"PROM_METRICS_PATH\"" 191 | echo " metric_version = 2" 192 | } >> $CONFIG 193 | 194 | PROM_METRICS_PATH="$( bashio::config 'prometheus.metrics_path' )" 195 | sed -i "s,PROM_METRICS_PATH,${PROM_METRICS_PATH},g" $CONFIG 196 | fi 197 | 198 | fi 199 | 200 | bashio::log.info "Finished updating config, Starting Telegraf" 201 | 202 | telegraf 203 | -------------------------------------------------------------------------------- /telegraf/rootfs/etc/cont-init.d/telegraf.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bashio 2 | # ============================================================================== 3 | # Home Assistant Community Add-on: Telegraf 4 | # Configures Telegraf 5 | # ============================================================================== 6 | declare influx_un 7 | declare influx_pw 8 | declare influx_ret 9 | declare hostname 10 | bashio::require.unprotected 11 | 12 | readonly CONFIG="/etc/telegraf/telegraf.conf" 13 | 14 | HOSTNAME=$(bashio::config 'hostname') 15 | INFLUX_SERVER=$(bashio::config 'influxDB.url') 16 | INFLUX_DB=$(bashio::config 'influxDB.db') 17 | INFLUX_UN=$(bashio::config 'influxDB.username') 18 | INFLUX_PW=$(bashio::config 'influxDB.password') 19 | INFLUXDBV2_URL=$(bashio::config 'influxDBv2.url') 20 | INFLUXDBV2_TOKEN=$(bashio::config 'influxDBv2.token') 21 | INFLUXDBV2_ORG=$(bashio::config 'influxDBv2.organization') 22 | INFLUXDBV2_BUCKET=$(bashio::config 'influxDBv2.bucket') 23 | RETENTION=$(bashio::config 'influxDB.retention_policy') 24 | DOCKER_TIMEOUT=$(bashio::config 'docker.timeout') 25 | SMART_TIMEOUT=$(bashio::config 'smart_monitor.timeout') 26 | IPMI_USER=$(bashio::config 'ipmi_sensor.server_user_id') 27 | IPMI_PASSWORD=$(bashio::config 'ipmi_sensor.server_password') 28 | IPMI_PROTOCOL=$(bashio::config 'ipmi_sensor.server_protocol') 29 | IPMI_IP=$(bashio::config 'ipmi_sensor.server_ip') 30 | IPMI_INTERVAL=$(bashio::config 'ipmi_sensor.interval') 31 | IPMI_TIMEOUT=$(bashio::config 'ipmi_sensor.timeout') 32 | CUSTOM_CONF_ENABLED=$(bashio::config 'custom_conf.enabled') 33 | CUSTOM_CONF=$(bashio::config 'custom_conf.location') 34 | 35 | 36 | if bashio::var.true "${CUSTOM_CONF_ENABLED}"; then 37 | bashio::log.info "Using custom conf file" 38 | rm /etc/telegraf/telegraf.conf 39 | cp "${CUSTOM_CONF}" /etc/telegraf/telegraf.conf 40 | else 41 | bashio::log.info "Updating config" 42 | 43 | if bashio::var.has_value "${HOSTNAME}"; then 44 | hostname="hostname = 'HOSTNAME'" 45 | else 46 | hostname=" hostname = ''" 47 | fi 48 | 49 | { 50 | echo "[agent]" 51 | echo " interval = \"10s\"" 52 | echo " round_interval = true" 53 | echo " metric_batch_size = 1000" 54 | echo " metric_buffer_limit = 10000" 55 | echo " collection_jitter = \"0s\"" 56 | echo " flush_interval = \"10s\"" 57 | echo " flush_jitter = \"0s\"" 58 | echo " precision = \"\"" 59 | echo " ${hostname}" 60 | echo " omit_hostname = false" 61 | } >> $CONFIG 62 | 63 | sed -i "s,HOSTNAME,${HOSTNAME},g" $CONFIG 64 | 65 | if bashio::config.true 'influxDB.enabled'; then 66 | if bashio::var.has_value "${INFLUX_UN}"; then 67 | influx_un=" username='INFLUX_UN'" 68 | else 69 | influx_un=" # INFLUX_UN" 70 | fi 71 | 72 | if bashio::var.has_value "${INFLUX_PW}"; then 73 | influx_pw=" password='INFLUX_PW'" 74 | else 75 | influx_pw=" # INFLUX_PW" 76 | fi 77 | 78 | if bashio::var.has_value "${RETENTION}"; then 79 | influx_ret=" retention_policy='RETENTION'" 80 | else 81 | influx_ret=" # RETENTION" 82 | fi 83 | 84 | { 85 | echo "[[outputs.influxdb]]" 86 | echo " urls = ['http://a0d7b954-influxdb:8086']" 87 | echo " database = \"TELEGRAF_DB\"" 88 | echo " ${influx_ret}" 89 | echo " timeout = '5s'" 90 | echo " ${influx_un}" 91 | echo " ${influx_pw}" 92 | } >> $CONFIG 93 | 94 | sed -i "s,http://a0d7b954-influxdb:8086,${INFLUX_SERVER},g" $CONFIG 95 | 96 | sed -i "s,TELEGRAF_DB,${INFLUX_DB},g" $CONFIG 97 | 98 | sed -i "s,INFLUX_UN,${INFLUX_UN},g" $CONFIG 99 | 100 | sed -i "s,INFLUX_PW,${INFLUX_PW},g" $CONFIG 101 | 102 | sed -i "s,RETENTION,${RETENTION},g" $CONFIG 103 | 104 | fi 105 | 106 | if bashio::config.true 'kernel.enabled'; then 107 | bashio::log.info "Updating config for Kernel" 108 | { 109 | echo "[[inputs.kernel]]" 110 | } >> $CONFIG 111 | fi 112 | 113 | if bashio::config.true 'swap.enabled'; then 114 | bashio::log.info "Updaing config for Swap" 115 | { 116 | echo "[[inputs.swap]]" 117 | } >> $CONFIG 118 | fi 119 | 120 | if bashio::config.true 'docker.enabled'; then 121 | bashio::log.info "Updating config for Docker" 122 | { 123 | echo "[[inputs.docker]]" 124 | echo " endpoint = 'unix:///var/run/docker.sock'" 125 | echo " timeout = 'DOCKER_TIMEOUT'" 126 | } >> $CONFIG 127 | 128 | sed -i "s,DOCKER_TIMEOUT,${DOCKER_TIMEOUT},g" $CONFIG 129 | fi 130 | 131 | if bashio::config.true 'smart_monitor.enabled'; then 132 | bashio::log.info "Updating config for Smart Monitor" 133 | { 134 | echo "[[inputs.smart]]" 135 | echo " timeout = 'SMART_TIMEOUT'" 136 | } >> $CONFIG 137 | 138 | sed -i "s,SMART_TIMEOUT,${SMART_TIMEOUT},g" $CONFIG 139 | fi 140 | 141 | if bashio::config.true 'ipmi_sensor.enabled'; then 142 | bashio::log.info "Updating config for ipmi sensor" 143 | { 144 | echo "[[inputs.ipmi_sensor]]" 145 | echo " servers = [\"USER_ID:PASSWORD@PROTOCOL(IP)\"]" 146 | echo " interval = 'INTERVAL'" 147 | echo " timeout = 'TIMEOUT'" 148 | } >> $CONFIG 149 | 150 | sed -i "s,USER_ID,${IPMI_USER},g" $CONFIG 151 | sed -i "s,PASSWORD,${IPMI_PASSWORD},g" $CONFIG 152 | sed -i "s,PROTOCOL,${IPMI_PROTOCOL},g" $CONFIG 153 | sed -i "s,IP,${IPMI_IP},g" $CONFIG 154 | sed -i "s,INTERVAL,${IPMI_INTERVAL},g" $CONFIG 155 | sed -i "s,TIMEOUT,${IPMI_TIMEOUT},g" $CONFIG 156 | fi 157 | 158 | if bashio::config.true 'thermal.enabled'; then 159 | bashio::log.info "Updating config for thermal zone sensors" 160 | for i in $(shopt -s nullglob; echo /sys/class/thermal/thermal_zone*); do 161 | bashio::log.info "...$i" 162 | name=$(basename "$i") 163 | { 164 | echo "[[inputs.file]]" 165 | echo " files = [\"$i/temp\"]" 166 | echo " name_override = \"$name\"" 167 | echo " data_format = \"value\"" 168 | echo " data_type = \"integer\"" 169 | } >> $CONFIG 170 | done 171 | fi 172 | 173 | if bashio::config.true 'influxDBv2.enabled'; then 174 | bashio::log.info "Updating config for influxdbv2" 175 | { 176 | echo "[[outputs.influxdb_v2]]" 177 | echo " urls = [\"INFLUXv2_URL\"]" 178 | echo " token = 'INFLUX_TOKEN'" 179 | echo " organization = 'INFLUX_ORG'" 180 | echo " bucket = 'INFLUX_BUCKET'" 181 | } >> $CONFIG 182 | 183 | sed -i "s,INFLUXv2_URL,${INFLUXDBV2_URL},g" $CONFIG 184 | sed -i "s,INFLUX_TOKEN,${INFLUXDBV2_TOKEN},g" $CONFIG 185 | sed -i "s,INFLUX_ORG,${INFLUXDBV2_ORG},g" $CONFIG 186 | sed -i "s,INFLUX_BUCKET,${INFLUXDBV2_BUCKET},g" $CONFIG 187 | fi 188 | 189 | if bashio::config.true 'prometheus.enabled'; then 190 | bashio::log.info "Updating config for prometheus client" 191 | { 192 | echo "[[outputs.prometheus_client]]" 193 | echo " listen = \":9273\"" 194 | echo " path = \"PROM_METRICS_PATH\"" 195 | echo " metric_version = 2" 196 | } >> $CONFIG 197 | 198 | PROM_METRICS_PATH="$( bashio::config 'prometheus.metrics_path' )" 199 | sed -i "s,PROM_METRICS_PATH,${PROM_METRICS_PATH},g" $CONFIG 200 | fi 201 | 202 | fi 203 | 204 | bashio::log.info "Finished updating config" --------------------------------------------------------------------------------