I’m using Advanced SSH & Web Terminal and Mosquitto to generate sensors for tracking each addon /data directory size.
The setup is pretty straight forward, make sure Advanced SSH & Web Terminal is running in privileged mode, and add the following to init commands:
init_commands:
- >-
for c in `docker ps --format '{{.Names}}' | grep -vE
'(hassio|homeassistant)'`;do name=`echo $c | sed -E
's/[^_]+_[^_]+?_(.*)/\1/'` ; docker exec addon_core_mosquitto mosquitto_pub
-r -h localhost -u <MQTT_USER> -P <MQTT_PASSWORD> -t
"homeassistant/sensor/${name}_data_size/config" -m "{\"name\": \"${name^}
Data Size\", \"device_class\": \"data_size\", \"state_topic\":
\"addons/addon_data_size/${name}\", \"unit_of_measurement\": \"MB\",
\"icon\": \"mdi:harddisk\", \"device\": {\"identifiers\":
\"addon_data_size\", \"name\":\"Addons\", \"manufacturer\":\"Addons\"},
\"unique_id\": \"addon_data_size_${name}\", \"object_id\":
\"addon_data_size_${name}\"}"; done
- >-
while [ 1 = 1 ]; do for c in `docker ps --format '{{.Names}}' | grep -vE
'(hassio|homeassistant)'`;do name=`echo $c | sed -E
's/[^_]+_[^_]+?_(.*)/\1/'` ; val=`docker exec $c du -sb /data 2>/dev/null |
awk '{printf "%.2f", $1 / 1024^2}'`; docker exec addon_core_mosquitto
mosquitto_pub -h localhost -u <MQTT_USER> -P <MQTT_PASSWORD> -t
"addons/addon_data_size/${name}" -m "${val}"; done && sleep 60; done &
Make sure to change <MQTT_USER> and <MQTT_PASSWORD> to your credentials
The resulting MQTT device/sensors in my case:
Hope it helps!