Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
devops
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
devops
Commits
dacd4007
Commit
dacd4007
authored
Jan 10, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shmtop: .
- order by top users first - print values in GB, not 512b blocks
parent
1eb58004
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
6 deletions
+44
-6
shmtop
shmtop
+44
-6
No files found.
shmtop
View file @
dacd4007
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2017-2019 Nexedi SA and Contributors.
# Julien Muchembled <jm@nexedi.com>
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""shmtop - show top-like RAM usaege of a tmpfs instance
even hidden files are accounted.
XXX text
"""
mntpt
=
'/dev/shm'
import
errno
,
os
,
pwd
os
.
chdir
(
'/proc'
)
z
=
[]
...
...
@@ -12,7 +40,7 @@ for p in os.listdir('.'):
try
:
for
y
in
os
.
listdir
(
x
):
y
=
x
+
'/'
+
y
if
os
.
readlink
(
y
).
startswith
(
'/dev/shm
/'
):
if
os
.
readlink
(
y
).
startswith
(
mntpt
+
'
/'
):
y
=
os
.
open
(
y
,
0
)
try
:
n
+=
os
.
fstat
(
y
).
st_blocks
...
...
@@ -30,7 +58,17 @@ for p in os.listdir('.'):
raise
continue
uid
=
map
(
int
,
x
[
'Uid'
].
split
())
z
.
append
((
pwd
.
getpwuid
(
uid
[
0
]).
pw_name
,
x
[
'Name'
].
strip
(),
pid
,
n
))
z
.
sort
(
key
=
lambda
x
:
x
[
3
])
from
pprint
import
pprint
as
pp
pp
(
z
)
z
.
append
((
pwd
.
getpwuid
(
uid
[
0
]).
pw_name
,
x
[
'Name'
].
strip
(),
pid
,
n
*
512
))
z
.
sort
(
key
=
lambda
x
:
x
[
3
],
reverse
=
True
)
#from pprint import pprint as pp
#pp(z)
GB
=
1024.
*
1024
*
1024
print
(
"# %s"
%
mntpt
)
rss_total
=
0.
for
user
,
name
,
pid
,
rss
in
z
:
print
'%s (%d,%s)
\
t
%7.1fGB'
%
(
name
,
pid
,
user
,
rss
/
GB
)
rss_total
+=
rss
print
(
"( total:
\
t
%.1fGB )"
%
(
rss_total
/
GB
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment