1、检查solr服务监控脚本:
#/bin/bash starttime=$(date +%Y-%m-%d %H:%M:%S) http_code=$(curl -I -m 10 -o /dev/null -s -w %{http_code}" " 127.0.0.1:18983/solr/trade/select?q=*:*) if [ "$http_code" != "200" ]; then echo $starttime /etc/init.d/solr restart fi
2、检查内存使用脚本
#!/bin/bash phymem=`free | grep "Mem:" |awk '{print $2}'` phymemused=`free | grep 'buffers/cache' | awk '{print $3}'` jg=`awk 'BEGIN{printf"%.0f ",('$phymemused'/'$phymem')*100}'` echo $jg if [ $jg -gt 85 ];then echo "Memory is greater than 85%, restart and release" /etc/init.d/solr restart fi
%.0f :表示打印整数部分并换行
%.1f :表示打印小数点后一位,并换行