cache和buffer的区别
内在中cache和buffer的区别
查看系统的运行状态
12345678
Cache和buffer的区别!
#!/bin/bash
if [[ $# -eq 0 ]]
then
# Define Variable reset_terminal
#字体颜色
#深绿
fontColor='\E[36m'
#黄色
font2Color='\E[33m'
#闪烁
hostnameColor='\E[34m'
hostnameAction='\E[5m'
#绿色
successFulColor='\E[32m'
#红色
failColor='\E[31m'
#使用终端的默认颜色 白色
reset=$(tput sgr0)
# Check OS Type
os=$(uname -o)
echo -e $fontColor "Operating System Type :" $reset $os
# Check OS Release Version and Name
relVersionName=$(cat /etc/centos-release)
echo -e $fontColor "OS Release Version and Name :" $reset $relVersionName
# Check Architecture CPU 的架构
arc=$(uname -m)
# 操作系统位数
osBit=$(getconf LONG_BIT)
echo -e $fontColor "Architecture :" $reset $arc'_'$osBit
# Check Kernel Release
kernelRel=$(uname -r)
echo -e $fontColor "Kernel Release :" $reset $kernelRel
# Check hostname
# hostname=$(hostname)
# hostname=$($HOSTNAME)
hostname=$(uname -n)
echo -e $fontColor "HostName :" $hostnameAction $hostnameColor $hostname $reset
# Check Internal IP
iip=$(hostname -I)
echo -e $fontColor "Internal IP :" $font2Color $iip $reset
# Check External IP
eip=$(curl -s http://ipecho.net/plain)
echo -e $fontColor "External IP :" $font2Color $eip $reset
# Check DNS
# nameservers=$(awk '/nameserver/{print $2}' /etc/resolv.conf)
nameservers=$(cat /etc/resolv.conf | grep -E "\<nameserver[ ]+"| awk '{print $NF}')
echo -e $fontColor "NameServers :" $font2Color $nameservers $reset
# Check if connected to Internet or not
ping -c 3 www.baidu.com &>/dev/null && echo -e $fontColor "Connect Status: " $successFulColor "Connected" || echo -e $fontColor "Connect Status: " $failColor "Disconnected"
# Check Logined In Users
who>/tmp/who
echo -e $fontColor "Logined In Users :"$reset && cat /tmp/who
rm -f /tmp/who
#系统内存的使用情况
system_memory_usages=$(awk '/MemTotal/{total=$2}/MemFree/{free=$2}END{print (total-free)/1024}' /proc/meminfo)
echo -e $fontColor "System Memuserages : "$reset $system_memory_usages "M"
#应用内存的使用情况
apps_memory_usages=$(awk '/MemTotal/{total=$2}/MemFree/{free=$2}/Buffers/{buffers=$2}/^Cached/{cached=$2}END{print (total-free-buffers-cached)/1024}' /proc/meminfo)
echo -e $fontColor "Apps Memuserages : "$reset $apps_memory_usages "M"
# CPU 负载情况
#loadaverge=$(top -n 1 -b | grep "load average:" | awk '{print $10 $11 $12}')
#loadaverge=$(w | grep "load average:"| awk 'BEGIN{FS="average:"}{print $2}')
loadaverge=$(w | grep 'load average' | awk '{print $8 $9 $10}')
echo -e $fontColor "Load Averge : "$reset $loadaverge
# CPU 温度
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
rpi_temp=$(echo "$temp 1000" | awk '{print $1/$2}')
echo -e $fontColor "CPU Temperature : "$reset $rpi_temp "℃"
# 磁盘的使用情况
#disk_usages=$(df -h | grep -vE '文件系统|tmpfs'|awk "{print $1 $2 $4 $3 $5}")
df -hP | grep -vE 'tmpfs'>/tmp/disk_usages
echo -e $fontColor "Disk Usages : "$reset && cat /tmp/disk_usages
rm -f /tmp/disk_usages
fi
分析操作系统内存
应用使用内存=Total-(Free+Cached+Buffers) 系统使用内存Used=Total-Free cache buffer区别 cache: 功能:缓存主要用于打开的文件 读取策略:最少使用原则(LRU) buffer: 功能:分缓存主要用于目录项、inode等文件系 读取策略:先进先出策略
#!/bin/bash clear if [[ $# -eq 0 ]];then # define variable reset_terminal reset_terminal=$(tput sgr0) # check os type os=$(uname -o) echo -e '\e[32m'"os type:" $reset_terminal $os # check os release version and name os_name=$(cat /etc/issue | grep -e "Server") echo -e '\e[32m'"os release version" $reset_terminal $os_name # check architecture architecture=$(uname -m) echo -e '\e[32m'"architecture:" $reset_terminal $architecture # check kernel release kernel_release=$(uname -r) echo -e '\e[32m'"kernel release:" $reset_terminal $kernel_release # check hostname hostname=$HOSTNAME echo -e '\e[32m'"hostname:" $reset_terminal $hostname # check inter ip inter_ip=$(hostname -I) echo -e '\e[32m'"inter ip:" $reset_terminal $inter_ip # check dns dns_addr=$(cat /etc/resolv.conf | grep -E "\<nameserver[ ]+" | awk '{print $NF}') echo -e '\e[32m'"dns:" $reset_terminal $dns_addr fi
#!/bin/bash clear if [[ $# -eq 0 ]];then # define variable reset_terminal reset_terminal=$(tput sgr0) # check os type os=$(uname -o) # check os release version and name os_name=$(cat /etc/issue | grep -e "Server") # check architecture architecture=$(uname -m) # check kernel release kernel_release=$(uname -r) # check hostname hostname=$HOSTNAME # check inter ip inter_ip=$(hostname -I) # check dns dns_addr=$(cat /etc/resolv.conf | grep -E "\<nameserver[ ]+" | awk '{print $NF}') fi
#!/bin/bash clear if [[ $# -eq 0 ]]; then # define variable reset_terminal reset_terminal=$(tput sgr0) # check os type os=$(uname -o) # check os release version and name os_name=$(cat /etc/issue | grep -e "Server") # check architecture architecture=$(uname -m) # check kernel release kernel_release=$(uname -r) # check hostname hostname=$HOSTNAME
系统磁盘信息
CPU负载概念
系统信息——分析系统的运行状态
top命令,查看负载
tput sgr0,正常屏幕。
tput命令对终端会话进行操作和设置。
读取内存
cat /proc/meminfo
/proc文件系统目录。存储内核运行状态的的一系列特殊文件。
内存中cache和buffer的区别
dns配置文件
/etc/resolv.conf文件
登录用户名记录
who
内网IP
hostname -i
檢查PING是否成功的命令
獲取出dns ip