天达云 科技型企业
|
亚太互联网络信息中心(APNIC)成员
|
注册免费体验
[
加载中...
] - [
免费注册
]
|
用户中心
|
在线充值
|
投诉举报
首页
域名注册
云虚拟主机
云服务器
网站模板
网站制作
渠道合作
帮助中心
天达云首页
>
互联网学习教程
>
建站服务器
> 使用Hcache查看是谁占用了系统Buffer&Cache?
使用Hcache查看是谁占用了系统Buffer&Cache?
更新:HHH 时间:2023-1-7
一、hcache
Linux用户可能经常遇到的一个问题是内存大部分都被Buffer和Cache占用了,但是有时候我们想知道到底Cache了些什么内容却没有一个直观好用的工具。今天给你介绍一个可以查看Linux当前缓存了哪些文件的小工具hcache。
Hcache作者:伊布
前几天看到有个人用go写了个pcstat,可以查看某个文件是否被缓存(作者的目的是数据库调优),也可以根据进程pid来查看都缓存了哪些文件,但是不能查看整个操作系统都cache了哪些文件。因此,我基于pcstat写了个hcache,增加了查看当前操作系统cache的前top个文件的特性,你可以从这里下载下来试用,如果有什么建议的话也欢迎反馈给我:hubottle@gmail
.
com
官网:https
:
/
/
github
.
com/silenceshell/hcache
二、安装
hcache是使用GO开发的,安装非常简单,开箱即用。
$ wget http
:
/
/
7xir15
.
com1
.
z0
.
glb
.
clouddn
.
com/hcache
$ chmod
+
x hcache
$ mv hcache /usr/
local
/
bin/
1
2
3
$ wget http
:
/
/
7xir15
.
com1
.
z0
.
glb
.
clouddn
.
com/hcache
$ chmod
+
x hcache
$ mv hcache /usr/
local
/
bin/
三、使用
$ free
-
m
total used free shared buff/cache available
Mem
:
7823 1952 174 9 5696 5518
Swap
:
0 0 0
1
2
3
4
$ free
-
m
total used free shared buff/cache available
Mem
:
7823 1952 174 9 5696 5518
Swap
:
0 0 0
查看使用Cache最多的3个进程。
$ hcache
-
-
top 3
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
|
Name
|
Size
(
bytes
)
|
Pages
|
Cached
|
Percent
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
|
|
/usr/bin/dockerd
|
33368760
|
8147
|
8147
|
100
.
000
|
|
/usr/bin/docker
-
containerd
|
7115584
|
1738
|
1738
|
100
.
000
|
|
/etc/udev/hwdb
.
bin
|
6711310
|
1639
|
1639
|
100
.
000
|
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
1
2
3
4
5
6
7
8
$ hcache
-
-
top 3
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
|
Name
|
Size
(
bytes
)
|
Pages
|
Cached
|
Percent
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
|
|
/usr/bin/dockerd
|
33368760
|
8147
|
8147
|
100
.
000
|
|
/usr/bin/docker
-
containerd
|
7115584
|
1738
|
1738
|
100
.
000
|
|
/etc/udev/hwdb
.
bin
|
6711310
|
1639
|
1639
|
100
.
000
|
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
默认情况下会显示cache文件的全路径,会比较长。可以使用
-
-
bname选项来仅显示文件名。
$ hcache
-
-
top 3
-
-
bname
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
|
Name
|
Size
(
bytes
)
|
Pages
|
Cached
|
Percent
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
|
|
dockerd
|
33368760
|
8147
|
8147
|
100
.
000
|
|
docker
-
containerd
|
7115584
|
1738
|
1738
|
100
.
000
|
|
hwdb
.
bin
|
6711310
|
1639
|
1639
|
100
.
000
|
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
1
2
3
4
5
6
7
8
$ hcache
-
-
top 3
-
-
bname
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
|
Name
|
Size
(
bytes
)
|
Pages
|
Cached
|
Percent
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
|
|
dockerd
|
33368760
|
8147
|
8147
|
100
.
000
|
|
docker
-
containerd
|
7115584
|
1738
|
1738
|
100
.
000
|
|
hwdb
.
bin
|
6711310
|
1639
|
1639
|
100
.
000
|
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
查看指定进程的Cache使用情况。
$ hcache
-
pid 2903
-
bname
1
$ hcache
-
pid 2903
-
bname
另外还可使用指定格式输出,比如:JSON、纯文本。更多使用方法可参考hcache
-
h。
$ hcache
-
h
Usage
of
hcache
:
-
bname
convert paths to basename to narrow the output
-
histo
print a simple histogram instead
of
raw data
-
json
return data
in
JSON format
-
nohdr
omit the header from terse & text output
-
pid
int
show all open maps
for
the given pid
-
plain
return data with no box characters
-
pps
include
the per
-
page status
in
JSON output
-
terse
show terse output
-
top
int
convert paths to basename to narrow the output
-
unicode
return data with unicode box characters
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ hcache
-
h
Usage
of
hcache
:
-
bname
convert paths to basename to narrow the output
-
histo
print a simple histogram instead
of
raw data
-
json
return data
in
JSON format
-
nohdr
omit the header from terse & text output
-
pid
int
show all open maps
for
the given pid
-
plain
return data with no box characters
-
pps
include
the per
-
page status
in
JSON output
-
terse
show terse output
-
top
int
convert paths to basename to narrow the output
-
unicode
return data with unicode box characters
完结。。
返回建站服务器教程...
新手上路
全站内容搜索
互联网教程
域名购买流程
域名解析方法
产品管理
域名解析管理
云虚拟主机管理
数据库 . 管理
云服务器. 管理
支付方式
在线支付
付款方式
银联付款
发票开具
关于我们
关于我们
公司资质
代理加盟
代理登录
400-837-6568
7 * 24小时全天全国服务热线400电话