This works from the SSH ad Web Terminal Addon with protection mode disabled:
docker exec addon_a0d7b954_influxdb du -s /data/influxdb/data/homeassistant
However according to Frenk there is no way yo access that from within home assistant. So dead end and the only option for Home assistant users is the unreliable and (and frankly incorrect) shard method. Which is also not an option if you disable the internal database - as recommended by InfluxDB themselves.
Only solution: If you want a reliable sensor choose another install method that allows access to docker container files.
Using the file sensor I should be able to get this into home assistant as a sensor. I’m going to increase the watch time to 3000 seconds, 10 was just to test. The only downside is that the web terminal no longer works with ingress. Guess I’ll have to use the core SSH addon for access.
The confusing thing is that redirecting the command output with > should overwrite the file but instead it is appending to the file.
docker exec addon_a0d7b954_influxdb du -s /data/influxdb/data/homeassistant > /config/file_sensors/ha_influx_db_size.txt
This:
while [ 1 = 1 ]; do docker exec addon_a0d7b954_influxdb du -s /data/influxdb/data/homeassistant > /config/file_sensors/ha_influx_db_size.txt sleep 10; done
Returns:
du: cannot access '10' : No such file or directory
EDIT: I see my missing &&.
Edit 2: So the configuration is changed to this on saving:
init_commands:
- >-
while [ 1 = 1 ]; do docker exec addon_a0d7b954_influxdb du -s
/data/influxdb/data/homeassistant >
/config/file_sensors/ha_influx_db_size.txt && sleep 300; done
And while it is overwriting this 352808 /data/influxdb/data/homeassistant to the file, I still get 502: Bad Gateway when attempting to open the web terminal. Seems an awful waste of this addon.
@tom_l don’t give up hope on that amazing plugin… there’s a simple solution to your issue. Just throw ampersand at the end which turns the Linux command into a “background” task. It should just look like the below just pay attention to that last ampersand.
init_commands:
- 'while [ 1 = 1 ]; do du -s /etc > /backup/test.txt && sleep 10; done &'
That’s kinda sad… sleep is not supposed to do that. Mine did just like yours when I tried the read -t 10 command as the pause (verified with htop in the shell). Sleep does not seem to do what it’s doing to you… works like a charm for me.