查看swap占用情况
查看swap被占用的情况
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
# http://northernmost.org/blog/find-out-what-is-using-your-swap/ SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
do
let SUM=$SUM+$SWAP
done
echo "PID=$PID - Swap used: $SUM - ($PROGNAME )"
let OVERALL=$OVERALL+$SUM
SUM=0 done
echo "Overall swap used: $OVERALL"
使用:
[root@standby ~]# ./swap.sh |sort -nr -k 5 |head -10
PID=13899 - Swap used: 2071424 - ([ET_NET 0] )
PID=4124 - Swap used: 741224 - (nginx )
PID=19965 - Swap used: 741212 - (nginx )
PID=19960 - Swap used: 741212 - (nginx )
PID=19969 - Swap used: 741172 - (nginx )
PID=19968 - Swap used: 741172 - (nginx )
PID=19967 - Swap used: 741172 - (nginx )
PID=19966 - Swap used: 741172 - (nginx )
PID=19964 - Swap used: 741172 - (nginx )
PID=19962 - Swap used: 741172 - (nginx )
[root@standby ~]#
查看指定进程的swap占用情况
#!/bin/bash
# Get current swap usage for input process.
# 71standby@gmail.com function Usage()
{
echo -e "Usage: /bin/sh $0 keyword \n \
keyword: which to match the process that you wanna statistics.\n \
Example: 'traffic' will match the traffic_cop,traffic_manager,traffic_server and so on."
exit 2
} function Statistics()
{
SUM=0
OVERALL=0
for PID in `ps -ef |grep $1 |grep -v grep |grep -v $0 |awk '{print $2}'`; do
PROGNAME=`ps -p $PID -o comm --no-headers`
DIR=/proc/$PID/smaps
for SWAP in `grep Swap $DIR 2>/dev/null| awk '{ print $2 }'`; do
let SUM=$SUM+$SWAP
done
echo "PID=$PID - Swap used: $SUM - ($PROGNAME)"
let OVERALL=$OVERALL+$SUM
SUM=0
done
echo "$1 swap used: $OVERALL"
} if [ $# -ne 1 ]; then
Usage
else
Statistics $1
fi
使用:
[root@standby ~]# ./swap_show.sh traffic
PID=48575 - Swap used: 764 - (traffic_cop)
PID=48577 - Swap used: 12948 - (traffic_manager)
PID=48588 - Swap used: 3823100 - ([ET_NET 0])
traffic swap used: 3836812
[root@standby ~]#
查看swap占用情况的更多相关文章
- FreeBSD查看带宽占用情况,CPU,硬盘IO 虚拟内存等命令
FreeBSD查看带宽占用情况,CPU,硬盘IO 虚拟内存等命令 来源 https://www.liurongxing.com/freebsd-tips.html 来源 http://blog.51c ...
- 26. linux查看端口占用情况
linux系统下,查看端口占用情况的命令:lsof -i[root@www ~]# lsof -i
- RC-50221 问题解决 - netstat 查看端口占用情况
查看端口占用情况 netstat -an|grep LIST|grep 15 数据库监听占用情况. netstat -an|grep 1521 1521为 ...
- Mac查看端口占用情况
Mac下使用lsof(list open files)来查看端口占用情况,lsof 是一个列出当前系统打开文件的工具. 使用 lsof 会列举所有占用的端口列表: $ lsof 使用less可以用于分 ...
- Centos查看端口占用情况和开启端口命令
Centos查看端口占用情况命令,比如查看80端口占用情况使用如下命令: lsof -i tcp:80 列出所有端口 netstat -ntlp 1.开启端口(以80端口为例)方法一: /sbin/i ...
- windows下使用命令查看端口占用情况
使用下面的命令查看端口占用情况: 比如查看3000端口的占用情况 netstat -ano|findstr 3000 运行后,结果如下: 可以看到进程号为9692的占用了该端口,使用下面的命令查看是哪 ...
- windows 下查看端口占用情况
windows下面查看端口占用情况: netstat -ano|findstr "8888" TCP 127.0.0.1:8888 0.0.0.0:0 LISTENING 6876 ...
- 【运维】linux命令查看端口占用情况,杀死进程,后台启动进程
1.查看端口占用情况:> lsof -i:port COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ...
- Centos查看端口占用情况
Centos查看端口占用情况命令,比如查看80端口占用情况使用如下命令: lsof -i tcp:80 列出所有端口 netstat -ntlp 结束进程: kill 进程代码
随机推荐
- Centos7 Install Kubernetes
环境搭建配置官方 k8s yum 源: cat <<EOF > /etc/yum.repos.d/virt7-docker-common-release.repo [virt7-do ...
- python3 fileinput模块
模块fileinput可以对一个或多个文件的内容所有行进行迭代.遍历等操作: 常用方法: fileinput.input(files=None, inplace=False, backup='', b ...
- ubuntu下查看磁盘读写情况
iostat -d -k 1 10 每秒刷新一次,共10次. 未完待续..
- 老铁,告别postman,用pycharm来调接口,顺便把接口脚本也写了
最近,一位同事在用postman调涉及到依赖的接口的时候 postman设置了环境变量,但是老是获取不到依赖接口返回的值,至于的啥原因呢,@#¥%……&*()! 其实,用pycharm一样可以 ...
- POJ-3436 ACM Computer Factory(网络流EK)
As you know, all the computers used for ACM contests must be identical, so the participants compete ...
- Win10 安装 Linux子系统 Ubuntu18.04 / Kali Linux 的体验
汇总系列:https://www.cnblogs.com/dunitian/p/4822808.html#linux 几年前就看到新闻,今天周末,突发奇想,家里电脑安装下子系统不就不用安装开发的那些环 ...
- Python3 与 C# 基础语法对比(List、Tuple、Dict、Set专栏)
Code:https://github.com/lotapp/BaseCode 多图旧版:https://www.cnblogs.com/dunitian/p/9156097.html 在线预览: ...
- javascript Object的新方法
今天复习es6,又看到Object的一堆方法,与es5的表现又有不一致,耗费了一整天,整理一下: 前几天在司徒正美的书里又看到了es5 Object的字眼,为了向下兼容,大神们也是牛逼的整理出一系列i ...
- Zabbix监控服务器硬盘状态
安装Iptables服务: [root@localhost /]# yum install iptables-services [root@localhost /]# vim /etc/sysconf ...
- 洛谷P2050 美食节
修车加强版.发现每个厨师拆成p个点太浪费了,毕竟总共用到的才p个点.于是从下往上一个一个加,加到满流就停. 论动态加点费用流的正确姿势...... 我自己加总是出现负环...我是每次加一整层,然后跑完 ...