#!/bin/bash

cpus=$(lscpu | awk '/^CPU\(s):/{print $2}')
req_cpus=16
if [[ -n ${req_cpus} && -n ${cpus} ]]; then
    if [[ $(awk 'BEGIN{print('"$cpus"'>'"$req_cpus"')?0:1}') -eq 0 ]]; then
        checkStatus=OK 
        Msg="cpu 核心数大于等于${req_cpus}"               
    else
        checkStatus=fail
        Msg="cpu 核心数小于${req_cpus}"
    fi
else
    checkStatus=fail
    Msg="获取宿主机cpu核心数失败"
fi

echo "{\"checkValue\": \"${cpus}\",\"checkStatus\": \"${checkStatus}\", \"msg\": \"${Msg}\"}"

