3 ##############################################################################
4 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # compute capacity and scale of a host
19 #parameter used for HT(Hyper-Thread) check
22 CPU=$(grep 'physical id' /proc/cpuinfo | sort -u | wc -l)
23 # Number of physical cores in a single CPU
24 CORE=$(grep 'core id' /proc/cpuinfo | sort -u | wc -l)
25 # Total physical core number
27 # Number of logical cores
28 THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
30 MEMORY=$(grep 'MemTotal' /proc/meminfo | sort -u | awk '{print $2}')
33 CACHE=$(grep 'cache size' /proc/cpuinfo | sort -u | awk '{print $4}')
34 CACHES=$[$CACHE * $CPU]
35 HT_Value=$[$HT_Para * $CORES]
36 if [ $HT_Value -eq $THREAD ]; then
43 # write the result to stdout in json format
47 \"Cpu_number\":\"$CPU\", \
48 \"Core_number\":\"$CORES\", \
49 \"Thread_number\":\"$THREAD\", \
50 \"Memory_size\": \"$MEMORY\", \
51 \"Cache_size\": \"$CACHES\", \
52 \"HT_Open\": \"$HT_OPEN\" \