Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3660353
  • 博文数量: 880
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 6155
  • 用 户 组: 普通用户
  • 注册时间: 2016-11-11 09:12
个人简介

To be a better coder

文章分类

全部博文(880)

文章存档

2022年(5)

2021年(60)

2020年(175)

2019年(207)

2018年(210)

2017年(142)

2016年(81)

分类: LINUX

2018-12-06 11:05:47

[root@localhost scripts]# cat license_check.sh
#!/bin/bash
result=0
result0=0
ip=""
cpu=""
hz=""
uuid=""
http=""
time=10

while :
do

uuid=`cat /uuid`
cpu=`lscpu | grep "CPU(s):" | grep -v NUMA | awk '{print $2}'`
hz=`lscpu | grep "CPU MHz" | awk '{print $3}'`
ip=`cat /etc/yunhai.ini | grep cloud | cut -d "=" -f2 | cut -d "/" -f1`
curl --connect-timeout 8 -s > /cpu_license
result=`sed 's/.*data"://g' /cpu_license | cut -c 1`
if [ ! -n "$result" ];then
result=0
fi
if [ $result -ne $result0 ] ; then
    if [ $result -eq 1 ] ; then
    systemctl restart openstack-nova-compute.service
    elif [ $result -eq 0 ] ; then
    systemctl stop openstack-nova-compute.service
    fi
result0=$result
fi

sleep $time
done
[root@localhost scripts]#

阅读(824) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~