Skip to content

Instantly share code, notes, and snippets.

@achmadns
Created October 9, 2017 03:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achmadns/5b029ca3c4b0907db5f7780136d5f6be to your computer and use it in GitHub Desktop.
Save achmadns/5b029ca3c4b0907db5f7780136d5f6be to your computer and use it in GitHub Desktop.
Show retention policies on InfluxDB through CLI
#!/bin/bash
for x in `influx -execute 'show databases' | grep -v -e ^name -e --- -e ^_internal`;do printf "RETENTION POLICIES ON $x \n"; influx -execute "SHOW RETENTION POLICIES ON $x";done
@jmorcar
Copy link

jmorcar commented May 26, 2021

Thanks a lot! an fix update when database is named with "-" hyphen character :

  • only include back slashes on to variable like: \"$x\"
  • And I add params to exect from a remote client:
#!/bin/bash
for x in `influx -host <IP-HOSTANAME> -port 8086 -execute 'show databases' | grep -v -e ^name -e --- -e ^_internal`;do printf "RETENTION POLICIES ON \"$x\" \n"; influx -host 10.206.194.25 -port 8086 -execute "SHOW RETENTION POLICIES ON \"$x\" ";done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment