1
2
3
4
|
# free
total used
free
shared buff
/cache
available
Mem: 3882572 762388 398412 194732 2721772 2586636
Swap:
|
1
2
3
4
5
6
7
8
9
10
11
12
|
# linux-fincore
fincore version 1.3.0
fincore [options] files...
-s --summarize When comparing multiple files, print a summary report
-p --pages Print pages that are cached
-o --only-cached Only print stats
for
files that are actually
in
cache.
-g --graph Print a visual graph of each
file
's cached page distribution.
-S --min-size Require that each files size be larger than N bytes.
-C --min-cached-size Require that each files cached size be larger than N bytes.
-P --min-perc-cached Require percentage of a
file
that must be cached.
-h --help Print this message.
-L --vertical Print the output of this script vertically.
|
1
2
3
4
5
6
7
|
# linux-fincore -o /usr/lib64/libz.so.1.2.7
linux-fincore: invalid option --
'o'
filename size total_pages min_cached page cached_pages cached_size cached_perc
-------- ---- ----------- --------------- ------------ ----------- -----------
/usr/lib64/libz
.so.1.2.7 90,632 23 0 23 94,208 100.00
---
total cached size: 94,208
|
1
2
3
|
VIRT -- Virtual Memory Size (KiB)
The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have
been swapped out and pages that have been mapped but not used.
|
1
2
3
4
5
6
|
$
ps
-a -o pid,pmem,cmd,vsz,drs,trs
PID %MEM CMD VSZ DRS TRS
3870 0.0
ps
-a -o pid,pmem,cmd,vsz,d 148912 148822 89
10906 0.0
screen
-dr 129744 129744 0
16116 0.0
sudo
-i 195524 195524 0
16117 0.3 -zsh 156876 156876 0
|
1
2
|
RES -- Resident Memory Size (KiB)
The non-swapped physical memory a task is using.
|
1
2
3
|
SHR -- Shared Memory Size (KiB)
The amount of shared memory available to a task, not all of
which
is typically resident. It simply reflects memory that could be potentially
shared with other processes.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/bash
#Author: Shanker
#Time: 2016/06/08
#set -e
#set -u
#you have to install linux-fincore
if
[ ! -f
/usr/local/bin/linux-fincore
]
then
echo
"You haven't installed linux-fincore yet"
exit
fi
#find the top 10 processs' cache file
ps
-e -o pid,rss|
sort
-nk2 -r|
head
-10 |
awk
'{print $1}'
>
/tmp/cache
.pids
#find all the processs' cache file
#ps -e -o pid>/tmp/cache.pids
if
[ -f
/tmp/cache
.files ]
then
echo
"the cache.files is exist, removing now "
rm
-f
/tmp/cache
.files
fi
while
read
line
do
lsof
-p $line 2>
/dev/null
|
awk
'{print $9}'
>>
/tmp/cache
.files
done
<
/tmp/cache
.pids
if
[ -f
/tmp/cache
.fincore ]
then
echo
"the cache.fincore is exist, removing now"
rm
-f
/tmp/cache
.fincore
fi
for
i
in
`
cat
/tmp/cache
.files`
do
if
[ -f $i ]
then
echo
$i >>
/tmp/cache
.fincore
fi
done
linux-fincore -s `
cat
/tmp/cache
.fincore`
rm
-f
/tmp/cache
.{pids,files,fincore}
|