How to use script to View system Information in Linux
How does Linux use scripts to view system information? This article uses the example code to show, the code is very detailed, which can be used for reference by interested friends. I hope it will be helpful to you.
#! / bin/bash# auth:Bertram# created Time: 2019-12-2 func:sys info check# sys:centos6.x/7.x- -[$(id-u)-ne 0] & & echo "Please execute this script with the root user!" & & exit 1sysversionmakers $(rpm-Q centos-release | cut-d-- f3) line= "- -" [- d logs] | | mkdir logs#sys_check_file= "logs/$ (ip a show dev eth0 | grep-w inet | awk'{print $2}'| awk-F'/'{print $1}')-`date +% Y% m% d`.txt "sys_check_file=" logs/$ (ifconfig | awk 'NR==2 {print $2}')-`date +% Y% m% d`.txt "# get system cpu information function get_cpu_info () {Physical_CPUs=$ (grep" physical id "/ proc/cpuinfo | sort | uniq | wc-l) Virt_CPUs=$ (grep" processor "/ proc/cpuinfo | wc-l) CPU_Kernels=$ (grep" cores "/ proc/cpuinfo | uniq | uniq | Awk-F':'{print $2}') CPU_Type=$ (grep "model name" / proc/cpuinfo | awk-F':'{print $2}'| sort | uniq) CPU_Arch=$ (uname-m) # echo-e'\ 033 [32m CPU Information:\ 033 [0m'echo-e'\ 033 [05] 32m CPU information:\ 033 [0m'cat