日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 占用swap_查看swap占用情况

發布時間:2025/3/11 数据库 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 占用swap_查看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 ~]#

總結

以上是生活随笔為你收集整理的mysql 占用swap_查看swap占用情况的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。