Shell script to get basic information about Linux server

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.