Last active
February 21, 2024 16:32
-
-
Save artkrz/c66f0b735e844a7dc4de907f203fd535 to your computer and use it in GitHub Desktop.
Remove measurements from HASS InfluxDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
host=localhost | |
db='home_assistant' | |
measurements=$1 | |
measurements=($(influx --host $host --execute 'show measurements' --database=$db | grep "$1")) | |
if (( ${#measurements[@]} )) | |
then | |
echo "Found following measurements: " | |
echo | |
for m in ${measurements[*]} | |
do | |
echo " - $m" | |
done | |
echo | |
read -p "Are you sure you want to drop these from database? (y/N)" -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
for m in ${measurements[*]} | |
do | |
echo "Dropping $m..." | |
influx --host $host --database=$db --execute "drop measurement \"$m\";" | |
done | |
else | |
echo "OK, leaving it alone..." | |
fi | |
else | |
echo "Did not found any measurements matching your query. Exiting." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment