显示系统基本信息
#!/bin/bash clear if [[ $# -eq 0 ]];then echo -e '\E[33m'"###########系统分析##########" fi output=$(tput sgr0) os=$(uname -o) echo -e '\E[32m'"系统类型:"$output $os os_name=$(cat /etc/issue |grep -e "Server") echo -e '\E[33m'"系统版本:"$output $os_name os_bit=$(uname -m) echo -e '\E[34m'"系统位数:"$output $os_bit os_kernel=$(uname -r) echo -e '\E[35m'"内核版本:"$output $os_kernel echo -e "\E[33m主机名: \033[0m" $(hostname) ipinner=$(hostname -i) echo -e '\E[36m'"内网ip:"$output $ipinner outer=$(curl -s http://ipecho.net/plain) echo -e '\E[29m'"外网ip:"$output $outer nameservers=$(cat /etc/resolv.conf |grep -E "\<nameserver[ ]"+|awk '{print $NF}') echo -e '\E[31m'"系统DNS:"$output $nameservers ping -c 2 www.toutiao.com &>/dev/null && echo "网络连通:Yes" || echo "网络连通:No" who > /tmp/who echo -e '\E[32m'"当前登录用户:"$output && cat /tmp/who rm -rf /tmp/whoecho Mbsystem_men=$(awk '/MemTotal/{total=$2}/MemFree/{free=$2}END{print (total-free)/1024}' /proc/meminfo) Mbapp_men=$(awk '/MemTotal/{total=$2}/MemFree/{free=$2}/^Cached/{cached=$2}/Buffers/{buffers=$2}END{print (total-free-cached-buffers)/1024}' /proc/meminfo) free_mem=$(free -m |awk '/Mem/{print $4}') echo -e '\E[36m'"系统使用内存:" $output $Mbsystem_men"M" echo -e '\E[36m'"应用程序使用内存: "$output $Mbapp_men"M" echo -e '\E[36m空闲内存: \033[0m' "$free_mem"M echo -e '\E[33m #################################\033[0m'
好记性不如烂笔头