zl程序教程

您现在的位置是:首页 >  硬件

当前栏目

一个统计 CPU 内存 硬盘 使用率的shell脚本详解程序员

内存统计CPUshell程序员 详解 一个 脚本
2023-06-13 09:20:06 时间
user=`echo $temp |awk {printf("%s/n",$13)}` system=`echo $temp |awk {printf("%s/n",$14)}` idle=`echo $temp |awk {printf("%s/n",$15)}` total=`echo|awk {print (c1+c2)} c1=$system c2=$user` echo "#CPU Utilization#" echo "Total CPU is already use: $total" echo "CPU user is already use: $user" echo "CPU system is already use: $system" echo "CPU nice is already use: $nice" echo "CPU idle is already use: $idle" echo root_use=$(df -lh | awk NR==2 | awk {print $5}) dev_use=$(df -lh | awk NR==3 | awk {print $5}) dev_shm_use=$(df -lh | awk NR==4 | awk {print $5}) echo "#Hard Utilization#" echo "/ is already use: $root_use" echo "/dev is already use: $dev_use" echo "/dev/shm is already use: $dev_shm_use" echo memery_used=$(free | awk NR==2 | awk {print $3}) memery_all=$(free | awk NR==2 | awk {print $2}) memery_percent=$(echo "scale=4;$memery_used / $memery_all" | bc) percent_part1=$(echo $memery_percent | cut -c 2-3) percent_part2=$(echo $memery_percent | cut -c 4-5) echo "#Memery Utilization#" echo "system memery is already use: $percent_part1.$percent_part2%" swap_used=$(free | awk NR==4 | awk {print $3}) swap_all=$(free | awk NR==4 | awk {print $2}) swap_percent=$(echo "scale=4;$swap_used / $swap_all" | bc) swap_part1=$(echo $swap_percent | cut -c 2-3) swap_part2=$(echo $swap_percent | cut -c 4-5) echo "swap memery is already use: $swap_part1.$swap_part2%" echo

 

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/3070.html

服务器部署程序员系统优化网站设置运维