Commit 79cab1fd authored by Kirill Smelkov's avatar Kirill Smelkov

oomtop: Also print summary of total RSS used and shown

e.g. this way:

	1129511.760942 OOM ---- 8< ----
	Out of memory: Kill process 176988 (mysqld) score 374 or sacrifice child
	Killed process 176988 (mysqld) total-vm:61525744kB, anon-rss:49241736kB, file-rss:0kB
	 pid   uid tgid   total_vm rss      nr_ptes nr_pmds swapents oom_score_adj name
	 17698 980 176988 15381436 12310434   25447      79        0             0 mysqld
	   664 998   6646  2200397  1609434    3260      11        0             0 mysqld
	   467 996   4671  2075584  1488186    3027      11        0             0 mysqld
	   468 995   4685  2038413  1448825    2955      11        0             0 mysqld
	   466 997   4666  2019889  1433506    2922      10        0             0 mysqld
	 18255 980 182554  1228148  1189130    2404       7        0             0 neostorage
	 18754 993 187548  1133437   596830    1390       7        0             0 runzope
	 18918 990 189189  1053709   546716    1301       7        0             0 runzope
	  2489 990  24898   841620   360073    1015       6        0             0 runzope
	 10623 990 106232   813633   326855     925       6        0             0 runzope
	  2489 990  24899   786284   298808     879       6        0             0 runzope
	  1835 990  18358   754718   247787     752       6        0             0 runzope
	 18754 993 187546   756889   239579     714       7        0             0 runzope
	  1835 990  18356   752728   235375     759       6        0             0 runzope
	  1835 990  18359   740641   235157     730       5        0             0 runzope
	 18752 993 187529   720954   225784     673       6        0             0 runzope
	 18752 993 187522   710875   225169     662       5        0             0 runzope
	 18751 993 187516   724324   222395     685       5        0             0 runzope
	 18751 993 187515   717395   214494     657       5        0             0 runzope
	 18752 993 187523   707311   211217     648       5        0             0 runzope
	 18919 990 189190   732913   210482     661       6        0             0 runzope
	 18754 993 187543   739281   208312     659       6        0             0 runzope
	 18754 993 187544   706150   207504     651       7        0             0 runzope
	 18754 993 187549   715253   201658     640       7        0             0 runzope
	   435 993   4353   723417   195334     638       6        0             0 runzope
	 18752 993 187527   673725   184823     579       6        0             0 runzope
	   435 993   4359   712770   176883     592       5        0             0 runzope
	 18754 993 187542   688680   175773     591       6        0             0 runzope
	 18881 990 188811   685347   175249     593       5        0             0 runzope
	 18752 993 187520   654599   160298     550       6        0             0 runzope
	 18751 993 187514   643565   158168     525       6        0             0 runzope
	 18752 993 187525   636631   147606     510       5        0             0 runzope
	   435 993   4357   642729   128091     479       6        0             0 runzope
	 18799 990 187990   656397   118818     958       5        0             0 mysqld
	   807 993   8073   472649   113071     540       4        0             0 mysqld
	   435 993   4354   634811   102874     429       6        0             0 runzope
	   541   0   5417  1523000    71341     314      10        0             0 dsm_om_connsvcd
	 18753 993 187536   596366    66326     351       5        0             0 runzope
	 18945   0 189459    48872    42117      98       3        0             0 screen
	   142   0   1427    43659    28937      89       3        0             0 systemd-journal
	 ...
	( RSS total:    103.8GB  shown ^^^: 101.2GB )

with showing only 20 entries it was showing only for 90GB so I increased it to 40 along the way.

Maybe automatically detecting the interesting cutting point would be worth it
in the future.
parent 8d50e9a3
...@@ -296,11 +296,17 @@ def main(): ...@@ -296,11 +296,17 @@ def main():
outv = [] outv = []
fieldv = ('pid', 'uid', 'tgid', 'total_vm', 'rss', 'nr_ptes', 'nr_pmds', 'swapents', 'oom_score_adj', 'name') fieldv = ('pid', 'uid', 'tgid', 'total_vm', 'rss', 'nr_ptes', 'nr_pmds', 'swapents', 'oom_score_adj', 'name')
outv.append(fieldv) outv.append(fieldv)
for p in sorted(oom.procv, key = lambda _: _.rss, reverse=True)[:20]: rss_shown = 0
for p in sorted(oom.procv, key = lambda _: _.rss, reverse=True)[:40]:
outv.append( tuple(getattr(p, _) for _ in fieldv) ) outv.append( tuple(getattr(p, _) for _ in fieldv) )
rss_shown += p.rss
outv.append(('...',)) # we cut at 20 outv.append(('...',)) # we cut at 20
out_text = format_aligned(outv) out_text = format_aligned(outv)
print(out_text) print(out_text)
rss_total = 0
for p in oom.procv:
rss_total += p.rss
print('( RSS total:\t%.1fGB\t shown ^^^: %.1fGB )' % (rss_total * 4. / 1024 / 1024, rss_shown * 4. / 1024 / 1024) )
print() print()
print('\n'.join(oom.detailv)) print('\n'.join(oom.detailv))
print('---- 8< ----') print('---- 8< ----')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment