InfluxDB2.0: database size sensor

Yes, HA Core in a Docker container. Apologies if that wasn’t clear!

Good news though. Guy on another forum thought of a nice workaround: create a cronjob that writes data to the HA-config folder and then use a cat command to read the data. Like this.

*/10 * * * * /usr/bin/du -s /home/aeiou/docker/influxdb2/engine/data/0ffc2fcbc0fac7db | cut -f -1 > /home/aeiou/docker/hass/influxdb2size

And the sensor:

#-----InfluxDB size --- See cronjob for du command
  - platform: command_line
    name: 'InfluxDB Size'
    command: cat /config/influxdb2size # read data from du cronjob
    value_template: "{{ (value.split('\t')[0]|int/1000)|round(1) }}"
    unit_of_measurement: 'MB'

Hope this helps someone! No credit for me though!

5 Likes