Skip to content

Instantly share code, notes, and snippets.

@dpavlin
Created April 10, 2022 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpavlin/a3250b8a287cc50e7bb6da866b9f34e5 to your computer and use it in GitHub Desktop.
Save dpavlin/a3250b8a287cc50e7bb6da866b9f34e5 to your computer and use it in GitHub Desktop.
drop oldest influxdb shards when disk space becomes too small
#!/bin/sh -e
free=`df -k /var/lib/influxdb/ | grep / | awk '{ print $4 }'`
test "$free" -gt 2097152 && exit 0
df -h /var/lib/influxdb
influx -database telegraf -execute 'show shards' | grep telegraf | head -2 | tee /dev/stderr | awk '{ print $1 }' | tail -1 | xargs -i influx -database telegraf -execute 'drop shard {}'
df -h /var/lib/influxdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment