monitor_docker icon indicating copy to clipboard operation
monitor_docker copied to clipboard

Feature request to add disk usage

Open erkr opened this issue 2 years ago • 3 comments

Hi, I would love to have disk usage added to the monitored_conditions. Especially useful for database add ons like InfluxDB. I currently retrieve the size of the influx DB via an init command in The SSH & Web Terminal add-on: ‘ docker exec addon_a0d7b954_influxdb du -s /data/influxdb/data/homeassistant | mosquitto_pub -t …’ (For more info See: https://community.home-assistant.io/t/unreliable-influxdb-size-sensor/226871/49) So it would be great if similar disk usage sensors for particular folder (default root) inside the add ons could be created via this integration. Easier to set up and it would eliminate the need to publish them via MQTT

Best Eric

erkr avatar Feb 21 '23 14:02 erkr

This plugin exposes data that's available through interfaces such as docker container inspect .... Disk usage information is not information that is exposed.

You'd be better off creating a command_line sensor that basically does the same as what you're already doing now but skipping the MQTT workaround.

e.g.:

command_line:  
  - sensor:
      name: Influx DB size
      unique_id: influx_db_size
      unit_of_measurement: kB
      scan_interval: 300 # once every 5 minutes
      command: 'docker exec addon_a0d7b954_influxdb sh -c "du -sk Volumes/HomeAssistant/custom_components | cut -f1"'

This creates a native sensor in HomeAssistant with the size in kilobytes for the same Influx DB example you mentioned.

RoboMagus avatar Aug 09 '23 14:08 RoboMagus

Thanks, that is indeed a feasible option. Thanks for the example!

erkr avatar Aug 10 '23 17:08 erkr

Happy to help. After posting that sensor config I found out that depending on system load and directory size the time required to execute the command may exceed the default timeout. For that you may wish to increase the timeout if you run into that.

RoboMagus avatar Aug 10 '23 18:08 RoboMagus