×ðÁú¿­Ê±¹ÙÍøµÇ¼

linuxÔõôÉó²éÀú³ÌÕ¼ÓÃÄÚ´æ

ÔõÑùÉó²é linux Àú³ÌµÄÄÚ´æÕ¼Óã¿ÏÂÁîÐÐÒªÁ죺ps¡¢top¡¢vmstatϵͳÆÊÎö¹¤¾ß£ºhtop¡¢process explorerʹÓà api£ºÏµÍ³Å²Óã¨c/python£©

ÔõÑùÉó²é Linux Àú³ÌµÄÄÚ´æÕ¼ÓÃ

ÔÚ Linux ϵͳÖÐ £¬Éó²éÀú³ÌÄÚ´æÕ¼ÓÃÊÇÒ»ÖÖ³£¼ûµÄʹÃü¡£±¾ÎĽ«ÏÈÈݼ¸ÖÖÒªÁìÀ´»ñÈ¡ÓйØÀú³ÌÄÚ´æʹÓÃÇéÐεÄÐÅÏ¢¡£

ÏÂÁîÐÐÒªÁì

psÏÂÁî

ps -eo pid,comm,%mem,vsz,rss | sort -nrk 3

µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁÏÔʾËùÓÐÕýÔÚÔËÐеÄÀú³Ì £¬°´ÄÚ´æʹÓðٷֱÈÅÅÐò¡£

topÏÂÁî

top -o %MEM

µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁÏÔʾÀú³ÌµÄ¶¯Ì¬ÄÚ´æʹÓÃÇéÐÎ £¬°üÀ¨ÎïÀíÄڴ棨RSS£©ºÍÐéÄâÄڴ棨VSZ£©¡£

vmstatÏÂÁî

vmstat -s

µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁîÌṩϵͳµÄÄÚ´æͳ¼ÆÊý¾Ý £¬°üÀ¨Àú³ÌʹÓÃµÄ RSS ºÍ VSZ ÄÚ´æ¡£

ϵͳÆÊÎö¹¤¾ß

htop

htop ÊÇÒ»¿î»ùÓÚÎı¾µÄ½»»¥Ê½ÏµÍ³¼àÊÓÆ÷ £¬ÔÊÐíÄúÉó²éÀú³ÌµÄÏêϸÄÚ´æʹÓÃÇéÐÎ £¬°üÀ¨¹²ÏíÄڴ桢˽ÓÐÄÚ´æºÍ¿ÍÕ»¾Þϸ¡£

Process Explorer

Process Explorer ÊÇ Windows ºÍ Linux ϵͳÖÐÒ»¿îÊ¢ÐеÄͼÐλ¯Àú³ÌÖÎÀíÆ÷ £¬ÌṩÓйØÀú³ÌÄÚ´æʹÓÃÇéÐεÄÖÜÈ«ÐÅÏ¢¡£

ͨ¹ý API

Ò²¿ÉÒÔͨ¹ýʹÓà C »ò Python µÈ±à³ÌÓïÑÔÖеÄϵͳŲÓÃÀ´»ñÈ¡Àú³ÌµÄÄÚ´æʹÓÃÇéÐÎÐÅÏ¢¡£ÀýÈç £¬ÔÚ Python ÖÐ £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

import psutil
for proc in psutil.process_iter():
    mem = proc.memory_info()
    print(proc.name(), mem.rss)

µÇ¼ºó¸´ÖÆ

Õ⽫´òӡÿ¸öÀú³ÌµÄÃû³Æ¼°ÆäפÁô¼¯´óС£¨RSS£©¡£

Ñ¡ÕªÒªÁì

Ñ¡ÔñÉó²éÀú³ÌÄÚ´æÕ¼ÓõÄÒªÁìÈ¡¾öÓÚÄúÐèÒªµÄÏêϸÐÅÏ¢¼¶±ðºÍËùʹÓõÄϵͳ¹¤¾ß¡£ÏÂÁîÐÐÒªÁìÒ×ÓÚʹÓà £¬¶øϵͳÆÊÎö¹¤¾ßÌṩ¸üÖ±¹ÛµÄ½çÃæºÍ¸üÏêϸµÄÐÅÏ¢¡£Ê¹Óà API ÔÊÐíÄú×Ô½ç˵Êý¾ÝÍøÂçÀú³Ì¡£

ÒÔÉϾÍÊÇlinuxÔõôÉó²éÀú³ÌÕ¼ÓÃÄÚ´æµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ