Hello all,
Little example on how to monitor the size of your influxDB database size:
This will work on a strandard linux debian installation (inc. openHABian)
Item:
Number InfluxDB_Size
Rule:
rule "Influx DB Size Data Collection"
when
Time cron "0 0 0/1 * * ?" // On the hour
then
var String databaseQueryString = executeCommandLine("sudo du -sh /var/lib/influxdb/data/openhab_db", 1000)
// logInfo("TEST1", databaseQueryString) // eg. 29M /var/lib/influxdb/data/openhab_db
var String databaseSizeString = databaseQueryString.split("\t").get(0) // Extract first part of returned string
databaseSizeString = databaseSizeString.replace("M", "") // Removes the "M"
databaseSizeString = databaseSizeString.replace("K", "") // Removes the "K"
logInfo("TEST1", databaseSizeString) // eg: 29
var Number databaseSize = Float::parseFloat(databaseSizeString) as Number // Cast into a Number
logInfo("TEST1", databaseSize.toString) // eg: 29.0
InfluxDB_Size.postUpdate(databaseSize)
end