管理员必备的20个Linux系统监控工具2
w – 显示谁已登录,他们正在做什么?
w命令显示系统当前用户及其运行进程的信息。
# w username
# w vivek
输出样例:
17:58:47 up 5 days, 20:28, 2 users, load average: 0.36, 0.26, 0.24
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 10.1.3.145 14:55 5.00s 0.04s 0.02s vim /etc/resolv.conf
root pts/1 10.1.3.145 17:43 0.00s 0.03s 0.00s w
uptime – 告诉系统已经运行了多久?
uptime命令过去只显示系统运行多久。现在,可以显示系统运行多久、当前有多少的用户登录、在过去的1,5,15分钟里平均负载时多少。
# uptime
输入样例:
18:02:41 up 41 days, 23:42, 1 user, load average: 0.00, 0.00, 0.00
1可以被认为是最优的负载值。负载是会随着系统不同改变得。单CPU系统1-3和SMP系统6-10都是可能接受的。
ps – 显示进程
ps命令显示当前运行进程的快照。使用-A或-e显示所有进程。
# ps -A
输出样例:
PID TTY TIME CMD 1 ? 00:00:02 init 2 ? 00:00:02 migration/0 3 ? 00:00:01 ksoftirqd/0 4 ? 00:00:00 watchdog/0 5 ? 00:00:00 migration/1 6 ? 00:00:15 ksoftirqd/1 4885 tty1 00:00:00 mingetty 4886 tty2 00:00:00 mingetty 4887 tty3 00:00:00 mingetty 4888 tty4 00:00:00 mingetty 4891 tty5 00:00:00 mingetty 4892 tty6 00:00:00 mingetty 4893 ttyS1 00:00:00 agetty 12853 ? 00:00:00 cifsoplockd 12854 ? 00:00:00 cifsdnotifyd 14231 ? 00:10:34 lighttpd 14232 ? 00:00:00 php-cgi 54981 pts/0 00:00:00 vim 55465 ? 00:00:00 php-cgi 55546 ? 00:00:00 bind9-snmp-stat 55704 pts/1 00:00:00 ps
ps与top非常相似,但ps提供更多的信息。
输出长格式
# ps -Al
输出附加全格式(显示进程在执行时传入的参数)
# ps -AlF
显示进程结构
# ps –AlFH
在进程后显示线程
# ps –AlLm
打印服务器上所有进程
# ps ax
# ps axu
打印进程树
# ps -ejH
# ps axjf
# pstree
打印安全信息
# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps –eM
查看使用Vivek用户名运行的进程
# ps -U vivek -u vivek u
设置自定义输出格式
# ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
# ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
# ps -eopid,tt,user,fname,tmout,f,wchan
只显示Lighttpd的进程ID
# ps -C lighttpd -o pid=
或者
# pgrep lighttpd
或者
# pgrep -u vivek php-cgi
显示PID为55977的进程名称
# ps -p 55977 -o comm=
找出消耗内存最多的前10名进程
# ps -auxf | sort -nr -k 4 | head –10
找出使用CPU最多的前10名进程
# ps -auxf | sort -nr -k 3 | head -10
五月 9th, 2011 at 20:17
Interesting Article…
[...]some interesting sites worth visitng. We recommend all our readers go and check these out[...]……
五月 12th, 2011 at 07:08
My Recommended Websites…
[...]some new websites on the web we love, even if they are not related to ours. Check them out[...]…
五月 26th, 2011 at 01:15
Related Websites…
[...]some other related resources on the web that are worth viewing on this subject include[...]…
六月 3rd, 2011 at 02:56
Interesting Posts…
[...]some other related resources on the web that are worth viewing on this subject include[...]…