Solaris ÖеÄÃüÁî·Ç³£Ö®¶à£¬ÒÔÖºÜÄÑ´ÓÖзÖÀë³öÄÇЩºÜ¿áµÄÃüÁî¡£ÀýÈ磬ÓÐЩÃüÁ¸æ³ÌÐò½øÐÐÿ¸öϵͳµ÷ÓÃʱËùÒª»¨·ÑµÄʱ¼ä£¬ÓÐЩÃüÁ̬µØÏÔʾϵͳ»î¶¯ÐÅÏ¢£¬¶øÇÒÕâЩÃüÁî´ó²¿·Ö¶¼Í¬Ê±°üº¬ÔÚÁË Solaris 8 ºÍ Solaris 9 ÖС£ÕâÀÎÒ½«Öصã½éÉÜÆäÖÐһЩÃüÁÄú»òÐí»á·¢ÏÖËüÃÇÌرðÓÐÓá£
ϵͳ¹ÜÀíÔ±Êǹ¤¾ßµÄʹÓÃÕß¡£Í¨¹ýʵ¼ù¾Ñ飬ÎÒÃÇÕÆÎÕÁ˸ü¶à¹¤¾ß£¬²¢ÇÒÔöÇ¿ÁËÕï¶ÏÎÊÌâÒÔ¼°ÊµÊ©½â¾ö·½°¸µÄÄÜÁ¦¡£±¾´ÎרÀ¸Öаüº¬µÄÃüÁîÊÇͨ¹ý¾Ñé¡¢ÅóÓÑ¡¢ÊìÈËÒÔ¼°³öϯ 9 Ô¾ÙÐÐµÄ SunNetwork 2002 ´ó»áÊÕ¼¯µ½µÄ¡£Solaris Äں˵Ŀª·¢ÈËÔ± Brian Cantrill ºÍ Mike Shapiro Ëù½²µÄ"The /procodile Hunter"ÈÃÈ˺ÜÓÐÆô·¢²¢ÁîÈ˸е½¾ª¿Ö£¬ÒòΪ Cantrill ±àд´úÂëÀ´ËµÃ÷Ò»¸ö¹ÛµãµÄËÙ¶È±È Shapiro Äܹ»½²½â¸Ã¹ÛµãµÄËٶȻ¹Òª¿ì£¡
ÓÐÓÃµÄ Solaris ÃüÁî
truss -c (Solaris >= 8)£ºÕâÊǸöÁîÈËÕð¾ªµÄ truss Ñ¡ÏËüÌṩÁ˱»×·×ÙÃüÁîµÄÈ«Ãæ¸ÅÒªÐÅÏ¢£º
$ truss -c grep asdf work.doc
syscall seconds calls errors
_exit .00 1
read .01 24
open .00 8 4
close .00 5
brk .00 15
stat .00 1
fstat .00 4
execve .00 1
mmap .00 10
munmap .01 3
memcntl .00 2
llseek .00 1
open64 .00 1
---- --- ---
sys totals: .02 76 4
usr time: .00
elapsed: .05
Ëü»¹ÄÜÏÔʾÕýÔÚÔËÐеĽø³ÌµÄ¸ÅÒªÊý¾Ý¡£ÔÚ±¾ÀýÖУ¬Êý¾Ý±íÃ÷ÁË´ÓÆô¶¯ truss ÃüÁîµ½Óà control-c À´ÖÕÖ¹ truss Ö´ÐеÄÆڼ䣬½ø³Ìµ½µ××öÁËЩʲô¡£Õâ¶ÔÓÚÅжϽø³ÌΪºÎ±»¹ÒÆðÊǺÜÀíÏëµÄ£¬ÒòΪÄúÎÞÐë·ÑÁ¦ä¯ÀÀÕû¸ö truss µÄÊä³ö¡£
truss -d ºÍ truss -D (Solaris >= 8)£ºÕâÁ½¸öÑ¡Ïî±íÃ÷ÓëtrussÏÔʾµÄÿ¸öϵͳµ÷ÓÃÏà¹ØµÄʱ¼äÐÅÏ¢¡£Õâ¶ÔÓÚÕÒ³ö¶¨ÖÆ´úÂë»òÉÌÒµ´úÂëÖеÄÎÊÌâºÜÓаïÖú¡£ÀýÈ磺
$ truss -d who
Base time stamp: 1035385727.3460 [ Wed Oct 23 11:08:47 EDT 2002 ]
0.0000 execve("/usr/bin/who", 0xFFBEFD5C, 0xFFBEFD64) argc = 1
0.0032 stat("/usr/bin/who", 0xFFBEFA98) = 0
0.0051 fstat(3, 0xFFBEF42C) = 0
. . .
truss -D ¶ÔÓÚÏÔʾϵͳµ÷ÓüäµÄÑÓ³Ùʱ¼ä¸ü¼ÓÓÐÓãº
Dilbert> truss -D who
0.0000 execve("/usr/bin/who", 0xFFBEFD5C, 0xFFBEFD64) argc = 1
0.0028 stat("/usr/bin/who", 0xFFBEFA98) = 0
0.0004 fstat(3, 0xFFBEF42C) = 0
Õâ¸öÀý×ÓÖУ¬stat Õâ¸öϵͳµ÷ÓÃÒª±ÈÆäËûϵͳµ÷ÓÃÕ¼Óøü³¤µÄʱ¼ä¡£
truss -T£ºÕâÊǸöºÜ°ôµÄµ÷ʽ°ïÖúÑ¡Ïî¡£ÔÚÖ´ÐÐÖ¸¶¨µÄϵͳµ÷ÓÃʱ£¬Ëü¿ÉÒÔÖÕÖ¹½ø³Ì£¨"-U"Ò²Ö´ÐÐͬÑùµÄ²Ù×÷£¬²»¹ýÊÇÔÚ½øÐÐÓû§¼¶µÄº¯Êýµ÷ÓÃʱ£©¡£´Ëʱ£¬½«»á»ñÈ¡ÓÃÓÚ½øÒ»²½·ÖÎöµÄ core Îļþ£¬»òÕßʹÓÃһЩ /proc ¹¤¾ßÀ´È·¶¨½ø³Ì¸÷¸ö·½ÃæµÄ״̬¡£
truss -l£¨ÔÚ Solaris 9 ÖÐÒѸĽø£©£ºÏÔʾ¶àÏ߳̽ø³ÌÖÐÿ¸öµ÷ÓõÄÏ̺߳š£Solaris 9 ÖÐµÄ truss -l ¾¹ýÁ˸Ľø£¬×îºó»¹¿ÉÒÔ¼àÊÓ¶àÏ̵߳ÄÓ¦ÓóÌÐòµÄÖ´ÐС£
Truss µÄÈ·ÊǸö¹¦ÄÜÇ¿´óµÄ¹¤¾ß¡£ÀýÈ磬¿ÉÔÚ core ÎļþÖÐÓÃÓÚ·ÖÎöÎÊÌâ²úÉúµÄÔÒò¡£»¹¿ÉÒÔͨ¹ý"-u"Ñ¡ÏîÀ´ÏÔʾÓû§¼¶µÄ¿â£¨¼È¿ÉÒÔΪϵͳ¿â£¬Ò²¿ÉΪ³ÌÐòÔ±¿â£©µ÷ÓõÄÏêϸÐÅÏ¢¡£
Plimit (Solaris >= 8)£ºÕâ¸öÃüÁîÓÃÓÚÏÔʾ²¢ÉèÖÃÕýÔÚÔËÐеĽø³ÌÖеÄÿ¸ö½ø³ÌµÄÏÞÖÆ¡£Èç¹ûÒ»¸ö³¤Ê±¼äÔËÐеĽø³Ì³¬¹ýÁËij¸öÏÞÖÆ£¨Èç´ò¿ªµÄÎļþÊýÄ¿£©£¬Ê¹ÓøÃÃüÁî¾ÍÊ®·Ö·½±ã¡£ÒòΪÎÞÐëʹÓà limit ÃüÁîºóÖØÐÂÔËÐиýø³Ì£¬plimit ¾Í¿ÉÒÔÐÞ¸ÄÕýÔÚÔËÐеĽø³Ì¡£
pgrep (Solaris >= 8)£ºpgrep ÔÚ /proc ÖÐËÑË÷·ûºÏ¸ø¶¨¹æÔòµÄ½ø³Ì£¬²¢·µ»Ø½ø³ÌµÄ ID¡£ÆäÖÐÒ»¸öºÜ°ôµÄÑ¡ÏîÊÇ"-n"£¬Ëü·µ»ØµÄÊÇ×îеÄÂú×ãÌõ¼þµÄ½ø³ÌºÅ¡£
preap (Solaris >= 9)£º³ýÈ¥½©Ê¬½ø³Ì¡£ÈκÎÀ§ÓÚ"z"״̬£¨ÓÉ ps ÃüÁîÏÔʾ£©µÄ½ø³Ì£¬¸ÃÃüÁ¿É½«Ö®´ÓϵͳÖÐÇå³ý¡£
pargs (Solaris >= 9)£ºÏÔʾ½ø³ÌµÄ²ÎÊý¼°»·¾³±äÁ¿¡£
nohup -p (Solaris >= 9)£ºnohup ÃüÁî¿ÉÒÔÓÃÓÚÆô¶¯Ò»¸ö½ø³Ì£¬Òò´Ë¼´Ê¹ÓÃÓÚÆô¶¯½ø³ÌµÄ shell ±»¹Ø±Õ£¨¼´½ø³Ì»ñµÃ"SIGHUP"Ðźţ©£¬¸Ã½ø³ÌÈÔÈ»¿ÉÒÔ¼ÌÐøÔËÐС£Õâ¶ÔÓÚÈÃÒ»¸öºǫ́ÈÎÎñ²»¹ÜÅöµ½ºÎÖÖÇé¿öÈÔÈ»¿ÉÒÔ¼ÌÐøÔËÐÐÊǺÜÓÐÓõġ£µ«ÊÇÈç¹ûÄúÒѾÆô¶¯ÁËÒ»¸ö½ø³Ì£¬µ«ÉÔºóÏ£ÍûʹËüÃâÊÜ HUP ÐźŵÄÓ°Ï죬¸ÃÔõô°ìÄØ£¿ÔÚSolaris 9ÖУ¬ nohup -p ¿ÉÒÔ»ñÈ¡½ø³Ì ID ²¢Ê¹Ö®ºöÂÔ SIGHUP Ðźš£
prstat (Solaris >= 8)£ºprstat Ò²ÊÇ top ÃüÁµ«ÓµÓиü¶à¹¦ÄÜ¡£ÕâÁ½¸öÃüÁ¿ÉÒÔÌṩһ¸öÆÁÄ»µÄ¹ØÓÚ½ø³ÌµÄÓÐÓÃÐÅÏ¢ÒÔ¼°ÆäËûµÄÏà¹ØÐÅÏ¢£¬²¢ÇÒÄÜƵ·±µØ¸üУ¬×ÜÖ®ÊǸöºÜ°ôµÄÏÔʾϵͳÐÔÄܵĴ°¿Ú¡£µ« prstat Òª±È top ¸ü¼Ó¾«È·¡£Ëü»¹ÌṩÁËһЩºÜºÃµÄÑ¡Ïî¡£"-a"¿ÉÒÔͬʱÏÔʾ½ø³ÌÓëÓû§µÄÐÅÏ¢£¨Ä¬ÈÏÓÉ CPU hog ÅÅÐò£©¡£"-c"ʹÆäÖ´ÐкÜÏñ vmstat£¨ÔÚÇ°Ò»¸ö±¨¸æÏÂÃæ½Ó×ÅÏÔʾеı¨¸æ£©¡£"-C"ÏÔʾÔÚ´¦ÀíÆ÷¼¯ÖеĽø³Ì¡£"-j"ÏÔʾһ¸ö"¹¤³Ì"ÖеĽø³Ì¡£"-L"ÏÔʾÿ¸öÏ̺߳Íÿ¸ö½ø³ÌµÄÐÅÏ¢¡£"-m"ºÍ"-v"ÏÔʾÿ¸ö½ø³ÌµÄºÜ¶àÏêϸµÄÐÔÄÜÐÅÏ¢£¨°üÀ¨ pages¡¢traps¡¢lock wait ºÍ CPU wait£©¡£ËùÓÐÊä³öÊý¾Ý¶¼¿ÉÒÔ°´ÕÕÔÚÄÚ´æÖÐÉèÖõĴóС¡¢ÐéÄâÄÚ´æ´óС¡¢ÔËÐÐʱ¼äµÈµÈÌõ¼þÀ´ÅÅÁС£prstat ÔÚûÓÐ top µÄϵͳÖÐÊǸöÊ®·ÖÓÐÓõŤ¾ß£¬²¢ÇÒÓÉÓÚËüµÄ¾«È·ÐÔ£¬ËùÒԺܿÉÄÜÈ¡´ú top£¨ÓÐЩµØ·½¿¼Âǵ½ËüÊǸö±»Ö§³ÖµÄ³ÌÐò¶øʹÓÃËü£©¡£
trapstat (Solaris >= 9)£ºtrapstat ÒÔ¼° lockstat ºÍ kstat ÊÇ Solaris ÖÐ×îÄÑÒÔÀí½âµÄÃüÁî¡£ËüÃÇÏÔʾһ¸öÔËÐеIJÙ×÷ϵͳÄÚ²¿ÖÐ×î¾ßÌåµÄϸ½ÚÐÅÏ¢¡£Ã¿¸öÃüÁî¶ÔÓÚ½â¾ö Solaris ϵͳÖз¢ÉúµÄ¹Å¹ÖÎÊÌⶼÊDZز»¿ÉÉٵġ£×îºÃÊǽ«ËüÃǵÄÊä³öËæ´íÎ󱨸æÒ»ÆðÌá½»£¬µ«½øÒ»²½µÄÑо¿½Òʾ£¬ËüÃÇÒ²ÄÜΪһ°ãÓ¦ÓÃÌṩÓÐÓÃÐÅÏ¢¡£
vmstat -p (Solaris >= 8)£ºÔÚÕâ¸öÑ¡Ïî¿ÉÒÔʹÓÃ֮ǰ£¬ÒªÈ·¶¨ÊÇÄÄÖÖÀàÐ͵ÄÄÚ´æÃüÁîµ¼ÖÂϵͳҳÃæµ÷¶È¼¸ºõÊDz»¿ÉÄܵģ¨Çë²éÔÄ"se toolkit"£©¡£vmstat -p ¿ÉÒÔ½â¾ö´ËÎÊÌ⣬ÒòΪËü²»µ«ÏÔʾÄúµÄϵͳÊÇ·ñ´¦ÓÚÄÚ´æ½ôȱµÄÇé¿ö£¨Í¨¹ý"sr"À¸£©£¬¶øÇÒ»¹ÏÔʾÊÇ·ñÊÇÓÉÒÔÏÂÄÚÈݵ¼ÖµģºÓ¦ÓóÌÐòµÄ´úÂ룬ӦÓóÌÐòµÄÊý¾Ý»ò I/O ¡£"-p"Äܹ»ÕæÕý°ïÖúÕÒ³ö Solaris Öе¼ÖÂÉñÃصÄÄÚ´æÎÊÌâµÄÔÒò¡£
pmap -x £¨Solaris >= 8£¬Solaris >= 9ÖнøÐÐÁË´íÎóÐÞ¸´£©£ºÈç¹ûÒѾµÃÖª½ø³ÌÖÐÓÐÄÚ´æÎÊÌ⣬²¢ÇÒÐèÒª»ñµÃ¸ü¶àÄÚ´æʹÓõÄÏêϸÐÅÏ¢£¬¾Í¿ÉÒÔʹÓà pmap -x¡£¸ÃÃüÁ½âÊÍÖ¸¶¨ ID µÄÄ¿±ê½ø³ÌµÄÕû¸öÄÚ´æÓ³ÉäÐÅÏ¢£¬ÈçÏ£º
# pmap -x 1779
1779: -ksh
Address Kbytes RSS Anon Locked Mode Mapped File
00010000 192 192 - - r-x-- ksh
00040000 8 8 8 - rwx-- ksh
00042000 32 32 8 - rwx-- [ heap ]
FF3B0000 8 8 8 - rwx-- [ anon ]
FFBFE000 8 8 8 - rw--- [ stack ]
-------- ------- ------- ------- -------
total Kb 1848 1728 40 -
ÕâÀÎÒÃÇ¿ÉÒÔ¿´µ½Ã¿Ò»¿éÄڴ棬ËüÃDZ»ÓÃÓÚ×öʲô£¬Õ¼ÓÃÁ˶à´óµÄ£¨ÐéÄâµÄºÍÕæʵµÄ£©¿Õ¼äÒÔ¼°ÆäģʽÐÅÏ¢¡£
df -h (Solaris >= 9)£ºÕâ¸öÃüÁîÔÚ Linux ÉÏÒѾӦÓÃÊ®·ÖÆձ飬¸Õ¸ÕתÒƵ½ÁË Solaris ƽ̨¡£df -h ÒÔÒ»ÖÖ·½±ãÔĶÁµÄÐÎʽÏÔʾÎļþϵͳµÄ¸ÅÒªÐÅÏ¢£º
$ df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c0t0d0s0 4.8G 1.7G 3.0G 37% /
/proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
fd 0K 0K 0K 0% /dev/fd
swap 848M 40K 848M 1% /var/run
swap 849M 1.0M 848M 1% /tmp
/dev/dsk/c0t0d0s7 13G 78K 13G 1% /export/home
½áÊøÓï
ÿ¸ö¹ÜÀíÔ±¶¼ÓÐÒ»Ì×ÈÕ³£Ê¹ÓõŤ¾ß£¬ÒÔ¼°ÁíÍâÒ»Ì×ÔÚ½ô¼±Çé¿öÏ°ïÖú½â¾öÎÊÌâµÄ¹¤¾ß¡£±¾ÎĽéÉÜÁ˸÷ÖÖ¸÷ÑùµÄµÄÃüÁî¼°Ñ¡ÏËüÃDz»¹ãΪÈËÖªµ«È´Ê®·ÖÓÐÓá£ÄúÊÇ·ñÒ²±£´æÁËÕâÑùһЩƫ°®µÄ¹¤¾ßÄØ£¿Èç¹ûÓУ¬ÇëÒ²·¢Ë͸øÎÒ£¬ÈÃÎÒ¿ÉÒÔÀ©Õ¹×Ô¼ºµÄ¹¤¾ß¼¯¡£ÁíÍ⣬¿ÉÒÔ·¢ËÍһЩÄú²»Ï²»¶»òÊǸоõÓÐΣÏյŤ¾ß£¬ËüÃÇ»òÐíÒ²¿ÉÒÔ±ä³ÉÓÐÓõÄÄØ£¡