Telegraf addon for hassio (glances alternative)

Hi!

Just to update on my issue, since Telegraf is polling SNMP I don’t actually need ports to be mapped on the host.

I found out that I had the issue here: https://github.com/influxdata/telegraf/issues/4896 with that “apt install snmp snmp-mibs-downloader” I downloaded more MIB’s and then used the solution here: https://github.com/influxdata/telegraf/issues/5837 to copy in the MIB’s, then it started working for me.
However, you need to copy the iana and ietf folder separately in to the container and then restart.

Now I only have this error from Telegraf left in the log:
2020-05-06T16:08:00Z E! [inputs.sensors] Error in plugin: failed to run command /usr/bin/sensors -A -u: exit status 1 - No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are.

For some reason I can now see that after a restart the MIB’s I copied in are cleared and not present anymore.

Can you add them in by default in the add-on maybe @Sabuto ?

UPDATE: They only disappear when stopping or restarting from HA side, not via “docker restart” command.

I haven’t had chance to add them yet, but I will when I can :slight_smile: there is an issue open on github for it. Also if you have time I’m accepting pr’s

OK, that sound good!
I’m afraid I don’t really know how to fix this from the start as I never build an add-on before :slight_smile:

@Lajo can you explain what you did exactly please? Did you do the apt get snmp-mibs-downloader, and then copy from your host computer? if so i don’t think there is a way to automatically do this. I am happy to put a hacky workaround in the readme but maybe i’ve missed something? like the mibs downloader does it automatically?

@Sabuto
I think you have to include it in the actual docker image so if you are using an existing docker image for Telegraf you/we need to request that whoever builds that adds these in.

Or maybe add the “apt install snmp snmp-mibs-downloader” in the inital install section in the Dockerfile here https://github.com/Sabuto/hassio-telegraf/blob/8c241ea157c2ba9258294515f0124711a41ee630/telegraf/Dockerfile may solve it?

These are my steps that I did:

apt install snmp snmp-mibs-downloader - This will install and download more MIB's to /usr/share/snmp/mibs/.

sudo docker exec -it <dockerid for telegraf add-on>ls /usr/share/snmp/mibs/ - This is just to see what MIBs are present in the docker container.

sudo docker cp /usr/share/snmp/mibs/. <dockerid for telegraf add-on>:/usr/share/snmp/mibs/ - This will copy the contents of mib in to the docker container.

sudo docker exec -it <dockerid for telegraf add-on> rm -r /usr/share/snmp/mibs/iana - For some reason it will copy iana and ietf directory as files in to the docker container so I have to remove them before copying the right dir.

sudo docker exec -it <dockerid for telegraf add-on> rm -r /usr/share/snmp/mibs/ietf

sudo docker cp /usr/share/snmp/mibs/iana/. <dockerid for telegraf add-on>:/usr/share/snmp/mibs/iana

sudo docker cp /usr/share/snmp/mibs/ietf/. <dockerid for telegraf add-on>:/usr/share/snmp/mibs/ietf

The problem with hassio addons is that we cant add files from every point on the computer I will put this in the readme as a workaround. I will look at maybe putting it in the share folder then symlinking let me have a think :slight_smile:

Also will you do me a favour and start a brand new hassio telegraf instance and try doing the apt get inside the container and see if it installs all the required mibs inside the container without having to copy them?

@Sabuto I tried running the “apt install snmp snmp-mibs-downloader” inside the container but it seems that the repo is not there for it.

I get this output:

lars@HA:~$ sudo docker exec -it 3ed763cd06a6 apt install snmp snmp-mibs-downloader
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package snmp-mibs-downloader is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘snmp-mibs-downloader’ has no installation candidate

To my understanding if you add this in the Dockerfile:
RUN echo “deb Index of /ubuntu/ bionic main multiverse” > /etc/apt/sources.list

The important part being the that the repo is for bionic main mutliverse.
And then add “snmp snmp-mibs-downloader” to your existing apt install section it should work.

If that cannot be done, finding a way to map the hosts local MIB directory is a good solution as well.

@Sabuto I would like to use mqtt instead of the influxDB, is it possible? If so, could you give me steps to follow or point me in the direction to some docs to read. Also when I enable the custom_conf i get an error: cp: cannot stat ‘/share/telegraf.con’: No such file or directoy. One more thing, is it possible to edit the conf file that’s located at /etc/telegraf/telegraf.conf? Thank you for the addon, hope to be able to use it.

Based on the error message you’re pasting it looks like you’ve deleted the last “f” in “/share/telegraf.conf” somewhere, presumably in the hassio config page.

I don’t use SNMP, but I have a full telegraf monitor running on my Synology NAS (DS218+) using docker-composer (cli):

    telegraf:
        image: telegraf
        container_name: telegraf
        privileged: true
        hostname: telegraf.synology.lan
        command: 
          - /bin/bash
          - -c
          - | # This is so I can run smart tools
            apt update
            apt install -y smartmontools
            telegraf
        environment:
            - HOST_MOUNT_PREFIX=/hostfs
            - HOST_ETC=/hostfs/etc
            - HOST_PROC=/hostfs/proc
            - HOST_SYS=/hostfs/sys
            - HOST_VAR=/hostfs/var
            - HOST_RUN=/hostfs/run
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - /run/udev:/run/udev:ro # for `diskio` - not sure if I need it on synology...
            - /volume1/docker/influxdb/telegraf.conf:/etc/telegraf/telegraf.conf:ro
            - /:/hostfs:ro

My configuration is pretty bare. I started from a blank file, and just added things until the (default) dashboards started filling out, plus a couple extras (e.g. pihole):

[[inputs.docker]]
  endpoint = "unix:///var/run/docker.sock"

[[inputs.disk]]
  mount_points = ["/hostfs/volume1"]

[[inputs.filecount]]
  directories = ["/hostfs/var/log","/hostfs/volume1/downloads","/hostfs/volume1/homes" ]

[[inputs.smart]]

[[inputs.diskio]]

[[inputs.processes]]

[[inputs.net]]

# [[inputs.procstat]] # This requires glob patters for matching, and I don't know the details (yet) for synology

[[inputs.netstat]]

[[inputs.system]]

[[inputs.mem]]

[[inputs.kernel]]

[[inputs.cpu]]
  percpu = false
  report_active = true

[[inputs.influxdb]]
  urls = ["http://influxdb:8086/debug/vars"]

[[inputs.httpjson]]
  name = "diskless_pihole_stats"
  servers = [
    "http://pi.hole/admin/api.php",
  ]
  response_timeout = "5s"
  method = "GET"


[[outputs.influxdb]]
  urls = ["http://influxdb:8086"]

@Sabuto, I’m getting an error trying to save the config. Could something have changed in HA 0.117 that broke this?

Failed to save addon configuration, not a valid value for dictionary value @ data['options']. Got {'custom_conf': {'enabled': True, 'location': '/config/telegraf.conf'}}

Config:

custom_conf:
  enabled: true
  location: /config/telegraf.conf

I would assume you can just simply set it within your custom telegraf.conf: telegraf mqtt output

I got it working with mqtt…!

I am trying to add this to Home Assistant OS 2020.12.2 (current release, pi disk image). I am seeing this with several repositories I’ve tried to add. I can open an issue on github if you like.

And I am greeted with this message:

Repostitory structure for master is not compliant

i’m getting the error following using the hassio influxdb addon on hass OS
I have allready create a db telegraf and gave the user ALL permissions

image

influxDB:
  enabled: true
  url: 'http://a0d7b954-influxdb:8086'
  db: telegraf
  retention_policy: 7d
  username: xxx
  password: xxx

2021-01-02T16:39:20Z E! [outputs.influxdb] When writing to [http://a0d7b954-influxdb:8086]: 500 Internal Server Error: retention policy not found: 7d
2021-01-02T16:39:20Z E! [agent] Error writing to outputs.influxdb: could not write any address

same error here:
2021-01-17T21:23:50Z E! [agent] Error writing to outputs.influxdb: could not write any address
2021-01-17T21:24:00Z E! [outputs.influxdb] When writing to [http://a0d7b954-influxdb:8086]: 500 Internal Server Error: retention policy not found: null

Your retention_policy should be autogen not 7d

I will try and sort this soon, it’s because HA have updated a few things and I haven’t been able to

Any news? I have the same error…