Shell analyzes which programs are occupied by the swap partition (stress simulation environment)

Source: Internet
Author: User

1. View version
Cat/etc/debian_version
7.8

2, look at the memory (my side is 256MB memory swap divided by 4G)
Free-m
Total used free shared buffers Cached
MEM:231 124 106 0 8 79
-/+ buffers/cache:36 194
swap:3814 0 3814

3. Using stress to simulate the occupied swap partition environment
Stress--cpu 1--io 1--vm 2--vm-bytes 15000000--vm-keep--verbose

4. Check to see that the swap partition is constantly in use

5, using script analysis under
#!/bin/bash
#--------------------------------------------------
#Created: 2015-05-20
#Author: Jimmygong
#Mail: [Email protected]
#Function:
#Version: 1.0
#--------------------------------------------------
function Swapoccupancy ()
{
Echo-e "Pid\tswap\tprogame"
Num=0
For PID in ' ls-1/proc|egrep "^[0-9]" '
Do
if [[$pid-lt 20]]
Then
Continue
Fi
Program= ' Ps-eo pid,command|grep-w $pid |grep-v Grep|awk ' {print $} '
For swap in ' grep swap/proc/$pid/smaps 2>/dev/null|awk ' {print $} '
Do
Let num= $num + $swap
Done
Echo-e "${pid}\t${num}\t${program}"
Num=0
Done|sort-nrk2|head
}

Swapoccupancy
Exit 0

6, my side of the script is to take the first 10 of the

This article is from the "7928217" blog, please be sure to keep this source http://7938217.blog.51cto.com/7928217/1653649

Shell analyzes which programs are occupied by the swap partition (stress simulation environment)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.