Test Run Environment: SLES12SP2
#!/bin/bash
#系统名称;
os_type=$ (Uname-o | awk ' {print ' | ' +} ')
#系统位数; 32/64
os_bit=$ (uname-m | awk ' {print ' | ' +} ')
#内核发型版本
kernal_version=$ (uname-r | awk ' {print ' | ' +} ')
#系统版本信息
sys_info=$ (cat/etc/issue | awk ' {if ($ ~/^\w/) {print ' | ' +}} ')
#物理CPU个数:
cpu_actual_number=$ (cat/proc/cpuinfo| grep "Physical id" | sort| uniq| wc-l | awk ' {print ' | +} ')
#逻辑cpu个数:
cpu_virtal_number=$ (cat/proc/cpuinfo| grep "Processor" | wc-l | awk ' {print ' | " +} ')
#cpu型号
cpu_version=$ (cat/proc/cpuinfo | grep name | cut-f2-d: | uniq-c | awk ' {for (i=2; i<=nf; i++) {printf $i ""}} ' | awk ' {print ' | +} ')
#内存:
mem_info_total=$ (free-h | awk ' {print ' | ' +} ')
#联网情况:
net_conditon=$ (ping-c 1 baidu.com | grep ttl | wc-l)
#磁盘信息:
disk_info=$ (fdisk-l | grep "Disk/dev" | awk ' {print ' | " +} ')
disk_info_using=$ (df-h)
#主机名称
htname=$ (hostname | awk ' {print ' | ' +} ')
#网卡列表
eth_list=$ (IP addr | awk ' {if ($ ~/^[0-9]\:(. *) $/) {print $}} ' | Cut-d ":"-F 1 | awk ' {print ' | +} ')
#IP信息
ip_list=$ (IP addr | grep-e ' inet\b ' | awk ' {print $} ' | cut-d '/'-F 1 | awk ' {print ' | ' +} ')
Echo-e "\ n"
echo "System basic Information"
echo "---------------------------------------------------------------------------------------"
echo "System name: $os _type"
echo "Host name: $htname"
echo "Number of system bits: $os _bit"
echo "kernel version: $kernal _version"
echo "System version: $sys _info"
echo "Number of physical CPUs: $cpu _actual_number"
echo "Number of logical CPUs: $CPU _virtal_number"
echo "CPU Model: $CPU _version"
echo "Nic list:"
IP Addr | awk ' {if ($/^[0-9]\:(. *) $/) {print $}} ' | Cut-d ":"-F 1 | awk ' {print ' | +} '
echo "IP"
IP Addr | Grep-e ' inet\b ' | awk ' {print $} ' | Cut-d "/"-F 1 | awk ' {print ' | +} '
echo "Memory Information"
free-h | awk ' {print ' | +} '
echo "Disk Information"
Fdisk-l | grep "Disk/dev" | awk ' {print ' | +} '
Df-h
:
Shell script to get basic information about Linux server