среда, 26 июля 2017 г.

Bash script old elasticsearch indices cleanup when not enough space (>90%) when watermark

Delete elk old indices when not enough space




#!/bin/bash

CAPACITY=`df | grep '/dev/disk1' | awk '{print $5}' | tr -d '%'`

while [  $CAPACITY -gt 90 ]; do
  INDEXNAME=`curl -s localhost:9200/_cat/indices/cloudwatch* | sort -n | head -1 | awk '{print $3}'`
  curl -XDELETE localhost:9200/$INDEXNAME
  echo "Deleted $INDEXNAME"
  CAPACITY=`df | grep '<change this to disk>' | awk '{print $5}' | tr -d '%'`
  sleep 60
done



Комментариев нет:

Отправить комментарий

Bash: MySql backup (file per db), restore+ users and privileges

Backup Mysql DB (file per db) #!/bin/bash USER="root" databases=`mysql -u $USER -e "SHOW DATABASES;" | tr -d "|...