Created
January 26, 2021 00:57
-
-
Save futeng/114bba504b06b0f4e0a0695fdd7f3c07 to your computer and use it in GitHub Desktop.
[Get basic info from Linux OS ] Get Basic from Linux OS like OS version, cpu nums, mem, ie. #host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Title: Show HOST basic informations | |
# Author: tydic.com | |
# Date: 2017/05/21 | |
# 1. 内核 | |
#echo "Core: "`uname -a` | |
KERNAL=`uname -r` | |
# 2. 操作系统 | |
#echo "OS: "`head -n 1 /etc/issue` | |
OS_RELEASE=`cat /etc/redhat-release` | |
# 3. CPU信息 | |
#echo "CPU model: "`cat /proc/cpuinfo | grep "model name" | head -1 ` | |
CPU_PROCESSOR=`cat /proc/cpuinfo | grep processor | wc -l` | |
# 4. 内存 | |
MEM_TOTAL_KB=`grep MemTotal /proc/meminfo | awk '{print $2}'` | |
echo $MEM_TOTAL | |
#echo `grep MemFree /proc/meminfo` | |
# 5. 磁盘信息 | |
# 6. 主机名称 | |
HOSTNAME=`hostname` | |
# 7. IP地址 | |
IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"` | |
echo "$IP | $HOSTNAME | $OS_RELEASE - $KERNAL | $CPU_PROCESSOR | $MEM_TOTAL_KB" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment