Signed-off-by: Zhang Yu 2134782174@qq.com --- tests/host-info | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tests/host-info b/tests/host-info index 46f43f93..efa38075 100755 --- a/tests/host-info +++ b/tests/host-info @@ -1,20 +1,23 @@ #!/bin/bash
-get_node() +get_mem() { - echo "nr_node: $(grep -Eo 'Node [0-9]+,' /proc/zoneinfo | uniq | wc -l)" - echo "nr_cpu: $(nproc)" memory_total=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}') memory_new=$(awk 'BEGIN{printf "%0.2f", '$memory_total'/1024/1024/16}') memory=$(echo `expr $(echo $memory_new | awk '{print int($0)+1}') * 16`)G echo "memory: $memory" }
-get_model_name() +get_cpu() { - echo "model_name: $(lscpu |grep "Model name" | awk '{print $3}')" + echo $1: $(lscpu | awk -F': *' '/'$2':/{print $2}') }
+get_cpu arch 'Architecture' +get_cpu nr_node 'NUMA\snode(s)' +get_cpu nr_cpu '^CPU(s)' +get_cpu model_name 'Model\sname' + get_nr_disk() { nr_hdd_disks=$(lsblk -d -o name,ROTA | grep -v loop | awk '{print $2}' | grep 1 | wc -l) @@ -101,11 +104,10 @@ get_ipmi_ip()
main() { - get_node + get_mem get_nr_disk get_partitions get_mac - get_model_name get_ipmi_ip }
On Fri, Oct 23, 2020 at 12:01:10PM +0800, Zhang Yu wrote:
Signed-off-by: Zhang Yu 2134782174@qq.com
tests/host-info | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tests/host-info b/tests/host-info index 46f43f93..efa38075 100755 --- a/tests/host-info +++ b/tests/host-info @@ -1,20 +1,23 @@ #!/bin/bash
-get_node() +get_mem() {
- echo "nr_node: $(grep -Eo 'Node [0-9]+,' /proc/zoneinfo | uniq | wc -l)"
- echo "nr_cpu: $(nproc)"
local memory_total=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}') echo memory: $(($memory_total/1024/1024 + 1))G Thanks sunyukui
memory_new=$(awk 'BEGIN{printf "%0.2f", '$memory_total'/1024/1024/16}') memory=$(echo `expr $(echo $memory_new | awk '{print int($0)+1}') * 16`)G }
-get_model_name() +get_cpu() {
- echo "model_name: $(lscpu |grep "Model name" | awk '{print $3}')"
- echo $1: $(lscpu | awk -F': *' '/'$2':/{print $2}')
}
+get_cpu arch 'Architecture' +get_cpu nr_node 'NUMA\snode(s)' +get_cpu nr_cpu '^CPU(s)' +get_cpu model_name 'Model\sname'
get_nr_disk() { nr_hdd_disks=$(lsblk -d -o name,ROTA | grep -v loop | awk '{print $2}' | grep 1 | wc -l) @@ -101,11 +104,10 @@ get_ipmi_ip()
main() {
- get_node
- get_mem get_nr_disk get_partitions get_mac
- get_model_name get_ipmi_ip
}
-- 2.23.0
On Fri, Oct 23, 2020 at 03:16:27PM +0800, Sun Yukui wrote:
+get_mem() {
- echo "nr_node: $(grep -Eo 'Node [0-9]+,' /proc/zoneinfo | uniq | wc -l)"
- echo "nr_cpu: $(nproc)"
local memory_total=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}') echo memory: $(($memory_total/1024/1024 + 1))G
$memory_total/1024/1024 this not a integet, it's decimal and divide by 16 and multiply by 16 to be more accurate, because the memory would have some loss.
Thanks, Zhangyu