• 本帖最后由 Gim 于 2018-9-16 15:58 编辑 *

1、怎么判断当前小鸡的swap 大小,如果小于512M ,执行 command1

2、怎么判断当前小鸡是否是阿里云主机(仅限linux 系统),如果是 执行 command2

3、怎么判断当前的小鸡系统是centos or ubuntu ,若果是 centos 执行 command3 否则,command4

系统判断,如有错误,请大佬指正:

  • if [[ -f /usr/bin/lsb_release ]]; then
  • OS=$(/usr/bin/lsb_release -a |grep Description |awk -F : '{print $2}' |sed 's/^[ \t]*//g')
  • else
  • OS=$(cat /etc/issue |sed -n '1p')
  • fi
  • - echo -e "OS:\n${OS}"复制代码

判断swap (不知道swap值是不是和pid值一样,是固定字节第 17-20 )大佬帮测试看看

  • swap=$(free -m | grep ~wap | cut -c 17-20)
  • - if [ ${swap -le 500}] ; then
  • echo ${swap}
  • fi
  • - 复制代码

![](lol.gif)