12345678910 |
- #!/bin/bash
- curl 127.0.0.1:9200 || exit 1
- function purge {
- curl -X GET http://127.0.0.1:9200/_cat/indices|grep logstash|sort -k3 > /tmp/clearing.stat
- (( $(wc -l /tmp/clearing.stat|cut -f1 -d ' ') > 1 )) \
- && curl -X DELETE http://127.0.0.1:9200/$(cat /tmp/clearing.stat|awk '(NR == 1)'|cut -d ' ' -f3)
- }
- if (( $(df -h --output=pcent,target|grep elasticsearch|cut -f2 -d ' '|rev|cut -c 2-|rev) > 80 ));then purge;fi
|