どのプロセスが最も多くのメモリを使用しているかを確認し、使用された合計メモリを要約します。

どのプロセスが最も多くのメモリを使用しているかを確認し、使用された合計メモリを要約します。

次のコマンドを使用すると、どのプロセスが最も多くのメモリを使用しているかを確認できます。

最初のフィールドには、各プロセスで使用される値がMB単位で表示されることがわかります。

awkを使用してすべての数字を合計し、MB単位で使用された最後の数字を取得できますか?

例えば

24738.3 MB

このコマンドは、すべてのプロセスとそれらが使用するMB(メモリ)を表示します。

ps aux  | awk '{print $6/1024 " MB\t\t" $01}'  | sort -n



4.74609 MB              postgres
5.01562 MB              postgres
5.19922 MB              postgres
5.3125 MB               postgres
5.33203 MB              postgres
5.35156 MB              postgres
5.43359 MB              postgres
5.53906 MB              WEPLO_qw
5.56641 MB              postgres
5.56641 MB              postgres
5.64062 MB              WEPLO_qw
5.65234 MB              postgres
5.68359 MB              postgres
5.75391 MB              postgres
5.97656 MB              postgres
6.33594 MB              postgres
6.55469 MB              postgres
6.57031 MB              postgres
6.60547 MB              postgres
6.63672 MB              postgres
7 MB            postgres
7.81641 MB              postgres
8.07812 MB              postgres
9.67578 MB              postgres
10.0234 MB              YTE
11.5156 MB              YTE
14.8828 MB              HTE_DS
15.2305 MB              hdfs
16.9297 MB              postgres
18.0781 MB              postgres
18.1172 MB              postgres
18.2812 MB              postgres
19.2695 MB              WEPLO_qw
21.1055 MB              postgres
21.1914 MB              postgres
21.6367 MB              postgres
21.9062 MB              postgres
23.5078 MB              postgres
24.4727 MB              polkitd
27.0938 MB              postgres
27.4375 MB              apache
28.0234 MB              apache
28.6445 MB              WEPLO_qw
29 MB           apache
30.4336 MB              apache
30.5664 MB              apache
32.4727 MB              apache
32.9023 MB              apache
50.1758 MB              WEPLO_qw
69.3398 MB              HTE_DS
72.7852 MB              HTE_DS
72.7891 MB              HTE_DS
72.7969 MB              HTE_DS
72.8008 MB              HTE_DS
72.8047 MB              HTE_DS
72.8125 MB              HTE_DS
72.8242 MB              HTE_DS
72.8281 MB              HTE_DS
72.832 MB               HTE_DS
72.8359 MB              HTE_DS
72.8438 MB              HTE_DS
72.8477 MB              HTE_DS
72.8516 MB              HTE_DS
72.8555 MB              HTE_DS
72.8594 MB              HTE_DS
72.8633 MB              HTE_DS
73.6602 MB              HTE_DS
74.418 MB               HTE_DS
75.2188 MB              HTE_DS
76.6641 MB              HTE_DS
76.75 MB                HTE_DS
78.4688 MB              HTE_DS
78.9492 MB              HTE_DS
85.2031 MB              WEPLO_qw
87.2344 MB              gdm
87.6367 MB              WEPLO_qw
100.711 MB              hdfs
114.703 MB              hdfs
132.32 MB               rabbitmq
191.383 MB              hdfs
204.285 MB              hdfs
298.152 MB              hdfs
360.168 MB              hdfs
360.402 MB              mapred
383.41 MB               Jko_+
387.973 MB              HTE_DS
412.961 MB              hdfs
499.574 MB              hdfs
562.395 MB              hdfs
689.383 MB              hdfs
802.691 MB              WEPLO_qw
886.816 MB              YTE
1017.73 MB              PLOT
1531.73 MB              zookeep+
1566.29 MB              HUT_OP
1739.48 MB              kafka
2275.65 MB              YTE
2738.92 MB              Grt-worker
4222.77 MB              anti-spam

ベストアンサー1

この試み、

メモリ内の列の合計を追加したい場合はps aux

ps aux  | awk '{print $6/1024}'  | xargs  | sed -E 's/ /+/g' | bc

これにより、メガバイト単位で回答が提供されます。

一方、、、、またはを使用してmemoryシステム統計を確認することもできます。詳しくは該当ページをご覧ください。sarfreevmstatpidstattopman

おすすめ記事