On several occasions my homeassistant_v2.db (SQLlite database) has been corrupted, causing my hass.io instance to behave strangely. As a last resort I delete this file, restart, and everything returns to normal operation. (The corruption is probably due to a network hang up where I cannot connect to perform a graceful shutdown.)
I would like a sensor that can be set to scan the database at a user specified interval and report back on the integrity of the database. I could use the sensor to trigger a notification. I have seen the “SQL Sensor” component but I have no idea how to program it to detect a corrupt database.