tobert / pcstat

Page Cache stat: get page cache stats for files on Linux
Apache License 2.0
1.22k stars 152 forks source link

add -top #17

Closed silenceshell closed 5 years ago

silenceshell commented 7 years ago

16

Add a new param --top to pcstat, it reads the /proc/[pid]/stat files, and finds those processes who's rss is not 0, then collects all the files opened by those processes, gets stats and sort them by cached pages.

Here is an example:

$ sudo pcstat --top 3  --bname  
+-------------+----------------+------------+-----------+---------+
| Name        | Size (bytes)   | Pages      | Cached    | Percent |
|-------------+----------------+------------+-----------+---------|
| chrome      | 114911208      | 28055      | 25476     | 090.807 |
| pycharm.jar | 95177431       | 23237      | 11479     | 049.400 |
| atom        | 62641344       | 15294      | 10578     | 069.164 |
+-------------+----------------+------------+-----------+---------+
tobert commented 6 years ago

Hmm I don't think that we should merge the copied code since go-ps has a different license. I'll take another look at how to do this without potentially misusing someone else's license & code.