功能一、提取操作系统信息(内核、系统版本、网络地址)
功能二、分析系统的运行状态(CPU负载、内存及磁盘使用率等)
#! /bin/bash
clear
if [[ $# -eq 0 ]]
then
reset_terminal=$(tput sgr0)
#Check OS Type
os=$(uname -o)
echo -e '\E[32m' "Operating System Type:" $reset_terminal $os
#Check OS Release Version and Name
os_name=$(cat /etc/centos-release)
echo -e '\E[32m' "Check OS Release Version and Name:" $reset_terminal $os_name
#Check Architecture
architeture=$(uname -m)
echo -e '\E[32m' "Check Architecture:" $reset_terminal $architeture
#Check Kernel Release
kernerrelease=$(uname -r)
echo -e '\E[32m' "Check Kernel Release" $reset_terminal $kernerrelease
#Check hostname
hostname=$(hostname)
echo -e '\E[32m' "Check hostname:" $reset_terminal $hostname
#check Internal IP
Internet=$(hostname -I)
echo -e '\E[32m' "check Internal IP:" $reset_terminal $Internet
#Check External IP
External=$(curl -s http://ipecho.net/plain)
#Check DNS
nameserver=$(cat /etc/resolv.conf | grep -E "\
echo -e '\E[32m' "Check DNS:" $reset_terminal $nameserver
#Check if connected to Internet or not
ping -c 2 www.baidu.com &>/dev/null && echo "Internet:Connected"|| echo "Internet:Disconnected"
#Check Logged In Users
who>/tmp/who
echo -e '\E[32m' "Logged In Users:" $reset_terminal && cat /tmp/who
rm -rf /tmp/who
###########################################################
system_mem_usages=$( awk '/MemTotal/{total=$2}/MemFree/{free=$2}END{print (total-free)/1024}' /proc/meminfo )
apps_mem_usages=$( awk '/MemTotal/{total=$2}/MemFree/{free=$2}/^Cached/{cached=$2}/Buffers/{buffers = $2}END{print (total-free-cached-buffers)/1024}' /proc/meminfo )
echo -e '\E[32m' "Check system memuserages:" $reset_terminal $system_mem_usages
echo -e '\E[32m' "Check apps memuserages:" $reset_terminal $apps_mem_usages
loadaverge=$( top -n 1 -b | grep "load average:" | awk '{print $10,$11,$12}')
echo -e '\E[32m'"Load averges" $reset_terminal $loadaverge
fi
网友评论