[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]#
阅读(858) | 评论(0) | 转发(0) |