5

shell脚本编程-获取系统信息

 3 years ago
source link: https://blog.51cto.com/gavenlee/5488173
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

shell脚本编程-获取系统信息

原创



#!/bin/bash
RED="\E[1;31m"
GREEN="echo -e \E[1;32m"
END="\E[0m"
HOSTNAME=$(hostname)
IP=`ifconfig | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -n1`
OS=`cat /etc/redhat-release`
KERNEL=$(uname -a | cut -d " " -f3)
CPU=`lscpu | grep "Model name" | tr -s " " | cut -d : -f2`
MEM=`lsmem | grep "Total online memory" | egrep -o [0-9]+.`
DISK=`lsblk | egrep '^sd'|tr -s " " | cut -d " " -f4`
$GREEN----------------------Host systeminfo--------------------$END
echo -e "主机名:" $HOSTNAME
echo -e "IP地址:" $IP
echo -e "系统版本:" $OS
echo -e "内核版本:" $KERNEL
echo -e "CPU型号:" $CPU
echo -e "内存大小:" $MEM
echo -e "磁盘空间大小:" $DISK
$GREEN---------------------------------------------------------$END</div


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK