Linux: find out what process is using all the RAM?
$ nano show-memory-usage.sh
Копировать:
#!/bin/sh
clear
ps -eo rss,pid,user,command | sort -rn | head -20 | awk '{ hr[1024**2]="GB"; hr[1024]="MB";\
for (x=1024**3; x>=1024; x/=1024) {\
if ($1>=x) { printf ("%-6.2f %s ", $1/x, hr[x]); break }\
} } { printf ("%-6s %-10s ", $2, $3) }\
{ for ( x=4 ; x<=NF ; x++ ) { printf ("%s ",$x) } print ("\n") }\
'
Сохранить.
$ sh show-memory-usage.sh
Примерно такой вывод:
406.11 MB 2465 usr1cv8 /opt/1C/v8.3/x86_64/rphost -range 1560:1591 -reghost kamin -regport 1541 -pid ab8bdcae-f963-11e8-ef84-ac1f6b94ef4a
342.20 MB 1224 postgres /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf
258.63 MB 3902 postgres postgres: postgres demo 192.168.0.174(54952) idle
104.21 MB 1242 postgres postgres: checkpointer process
101.45 MB 1243 postgres postgres: writer process
97.18 MB 2305 usr1cv8 /opt/1C/v8.3/x86_64/rmngr -port 1541 -host kamin -range 1560:1591 -clstid ab3b172e-f963-11e8-ef84-ac1f6b94ef4a
31.81 MB 2297 usr1cv8 /opt/1C/v8.3/x86_64/ragent -daemon
28.42 MB 1391 root /usr/lib/snapd/snapd
21.91 MB 475 root /lib/systemd/systemd-journald
20.75 MB 1244 postgres postgres: wal writer process
15.61 MB 2221 root /usr/sbin/smbd -D
6.66 MB 2904 root sshd: user [priv]
6.57 MB 1245 postgres postgres: autovacuum launcher process
6.49 MB 2889 root sshd: user [priv]
6.29 MB 1247 root /usr/lib/accountsservice/accounts-daemon
6.16 MB 2226 root /usr/sbin/smbd -D
6.09 MB 1 root /sbin/init
5.89 MB 1492 root /usr/lib/policykit-1/polkitd --no-debug
5.64 MB 1708 root /usr/sbin/sshd -D
5.61 MB 2223 root /usr/sbin/smbd -D
$ nano show-memory-usage.sh
Копировать:
#!/bin/sh
clear
ps -eo rss,pid,user,command | sort -rn | head -20 | awk '{ hr[1024**2]="GB"; hr[1024]="MB";\
for (x=1024**3; x>=1024; x/=1024) {\
if ($1>=x) { printf ("%-6.2f %s ", $1/x, hr[x]); break }\
} } { printf ("%-6s %-10s ", $2, $3) }\
{ for ( x=4 ; x<=NF ; x++ ) { printf ("%s ",$x) } print ("\n") }\
'
Сохранить.
$ sh show-memory-usage.sh
Примерно такой вывод:
406.11 MB 2465 usr1cv8 /opt/1C/v8.3/x86_64/rphost -range 1560:1591 -reghost kamin -regport 1541 -pid ab8bdcae-f963-11e8-ef84-ac1f6b94ef4a
342.20 MB 1224 postgres /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf
258.63 MB 3902 postgres postgres: postgres demo 192.168.0.174(54952) idle
104.21 MB 1242 postgres postgres: checkpointer process
101.45 MB 1243 postgres postgres: writer process
97.18 MB 2305 usr1cv8 /opt/1C/v8.3/x86_64/rmngr -port 1541 -host kamin -range 1560:1591 -clstid ab3b172e-f963-11e8-ef84-ac1f6b94ef4a
31.81 MB 2297 usr1cv8 /opt/1C/v8.3/x86_64/ragent -daemon
28.42 MB 1391 root /usr/lib/snapd/snapd
21.91 MB 475 root /lib/systemd/systemd-journald
20.75 MB 1244 postgres postgres: wal writer process
15.61 MB 2221 root /usr/sbin/smbd -D
6.66 MB 2904 root sshd: user [priv]
6.57 MB 1245 postgres postgres: autovacuum launcher process
6.49 MB 2889 root sshd: user [priv]
6.29 MB 1247 root /usr/lib/accountsservice/accounts-daemon
6.16 MB 2226 root /usr/sbin/smbd -D
6.09 MB 1 root /sbin/init
5.89 MB 1492 root /usr/lib/policykit-1/polkitd --no-debug
5.64 MB 1708 root /usr/sbin/sshd -D
5.61 MB 2223 root /usr/sbin/smbd -D
Комментариев нет:
Отправить комментарий