检查shell脚本

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}"\n" 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\n",('$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\n:表示打印整数部分并换行
%.1f\n :表示打印小数点后一位,并换行


posted @ 2019-12-17 14:58  凉生墨客  阅读(338)  评论(0编辑  收藏