统计 cpu 内存 使用率的shell脚本代码
2018-10-12 13:57
856 查看
#!/bin/sh
clear
while ((1>0))
do
NET=$(netstat -anp | grep 1000 | grep EST | wc -l)
PRC=$(ps aux | grep thread1 | grep -v grep | grep -v SCREEN | awk '{ print " CPU: " $3 "%, MEM: " $4 "%, RSS: " $6/1024 "M, VSZ: " $5/1024 "M, PID: " $2 ""}')
tput sc; echo -n -e "\b"; tput rc;
echo "SRV: thread1, NET: $NET, $PRC"
echo ""
NET=$(netstat -anp | grep 1011 | grep EST | wc -l)
PRC=$(ps aux | grep thread2 | grep -v grep | grep -v SCREEN | awk '{ print " CPU: " $3 "%, MEM: " $4 "%, RSS: " $6/1024 "M, VSZ: " $5/1024 "M, PID: " $2 ""}')
tput sc; echo -n -e "\b"; tput rc;
echo "SRV: thread2, NET: $NET, $PRC"
echo ""
NET=$(netstat -anp | grep 1022 | grep EST | wc -l)
PRC=$(ps aux | grep thread3 | grep -v grep | grep -v SCREEN | awk '{ print " CPU: " $3 "%, MEM: " $4 "%, RSS: " $6/1024 "M, VSZ: " $5/1024 "M, PID: " $2 ""}')
tput sc; echo -n -e "\b"; tput rc;
echo "SRV: thread3, NET: $NET, $PRC"
echo ""
NET=$(netstat -anp | grep 1033 | grep EST | wc -l)
PRC=$(ps aux | grep thread4 | grep -v grep | grep -v SCREEN | awk '{ print " CPU: " $3 "%, MEM: " $4 "%, RSS: " $6/1024 "M, VSZ: " $5/1024 "M, PID: " $2 ""}')
tput sc; echo -n -e "\b"; tput rc;
echo "SRV: thread4, NET: $NET, $PRC"
echo ""
NET=$(netstat -anp | grep beam.smp | grep EST | grep 222.222.18.222:800 | wc -l)
PRC=$(ps aux | grep thread | grep -v grep | awk '{CPU += $3} {MEM += $4} {RSS += $6} {VSZ += $5} END {print "CPU: " CPU "%, MEM: " MEM "%, RSS: " RSS/1024 "M, VSZ: " VSZ/1024 "M, " " "}' | awk 'END {print}')
tput sc; echo -n -e "\b"; tput rc;
echo "SRV: All, NET: $NET, $PRC"
echo ""
sleep 0.5
tput cup 0 0
done
您可能感兴趣的文章:
相关文章推荐
- 统计 cpu 内存 使用率的shell脚本代码
- 统计 CPU 内存 硬盘 使用率的shell脚本
- 一个用了统计CPU 内存 硬盘 使用率的shell脚本
- 一个用了统计CPU 内存 硬盘 使用率的shell脚本
- 一个用了统计CPU 内存 硬盘 使用率的shell脚本
- shell脚本监控cpu/内存使用率
- CPU 内存 硬盘 使用率统计shell
- 利用shell监控cpu、磁盘、内存使用率
- shell脚本监控系统负载、CPU和内存使用情况
- Linux服务器CPU 内存 磁盘 监控SHELL脚本
- 阿里云提供的一个监测cpu和内存的shell脚本(get_cpu_mem_info.sh)
- 使用shell脚本获取cpu平均使用率
- shell脚本监控系统负载、CPU和内存使用情况
- Windows系统CPU内存网络性能统计第二篇 CPU CPU整体使用率
- 监控linux中CPU 内存 磁盘数据的shell脚本(图文)
- Shell脚本实现的基于SVN的代码提交量统计工具
- 【找一找青春】Linux 性能监控之CPU&内存&IO监控Shell脚本2[转]
- linux-raspbian系统下编写python脚本显示树莓派的当前cpu温度、使用率、内存和硬盘信息
- 如何用shell脚本监控服务器负载、cpu、内存、硬盘和登录用户数
- Windows系统CPU内存网络性能统计第四篇 CPU 多核CPU各核使用率C++