linux查看系统监控命令

linux查看系统监控命令

ps

ps 是一个强大的查看进程状态的命令。那些进程正在运行。进程的状态,进程占用的资源等等

主要监控后台进程。相关参数

-e显示所有进程,-f全格式,-h不显示标题 -l长格式,-w宽输出

-a显示终端上的所有进程,包括其他用户的进程。

-r只显示正在运行的进程 -x显示没有控制终端的进程

最常用的

是ps -aux。这个显示所有进程,

显示项的意义

user,pid不考虑

VGZ--进程占用的虚拟记忆体的大小。

RSS--占用的共享存储区大小

STAT

STAT--进程状态,这是非常重要的一项。其中的状态如下

R: 正在执行中

S: 静止状态

T: 暂停执行

Z: 不存在但暂时无法消除,也就是僵尸进程(zombie)

W: 没有足够的记忆体分页可分配

N:低优先级

L: 有记忆体分页分配并锁在记忆体内

START:进程开始的时间

TIME:进程执行的时间

command进程命令行

2 top

第一行:开机时间,用户数,1s,5s,15s的cpu工作负载。

第二行:从上次刷新以来总进程数,睡眠进程数,运行进程数,僵死进程数,停止进程数

第三行:内存使用状态。总的,已用的,空闲的,共享的,缓存的。

第四行:交换分区(虚拟内存)使用状态

下面的和ps显示的差不多,不过默认情况下每5秒刷新一次

例子

[root@localhost root]# top

 18:11:19  up  1:37,  2 users,  load average: 0.00, 0.00, 0.00

67 processes: 66 sleeping, 1 running, 0 zombie, 0 stopped

CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle

           total    0.9%    0.0%    0.0%   0.0%     0.0%    0.0%   99.0%

Mem:   254140k av,  145172k used,  108968k free,       0k shrd,   13888k buff

       108536k active,              15592k inactive

Swap: 2096440k av,       0k used, 2096440k free                   68736k cached

  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND

 2593 root      20   0  1092 1092   884 R     0.9  0.4   0:00   0 top

    1 root      15   0   492  492   436 S     0.0  0.1   0:04   0 init

    2 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 keventd

    3 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kapmd

    4 root      34  19     0    0     0 SWN   0.0  0.0   0:00   0 ksoftirqd/0

    7 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 bdflush

    5 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kswapd

    6 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kscand

    8 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kupdated

    9 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 mdrecoveryd

   17 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald

   72 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 khubd

 1363 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald

 1364 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald

 1365 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald

 1366 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald

 1367 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald

 1731 root      18   0  1004 1004   724 S     0.0  0.3   0:00   0 dhclient

 1781 root      15   0   580  580   500 S     0.0  0.2   0:00   0 syslogd

 1785 root      15   0   464  464   400 S     0.0  0.1   0:00   0 klogd

 1813 rpc       15   0   568  568   496 S     0.0  0.2   0:00   0 portmap

 1833 rpcuser   25   0   716  716   636 S     0.0  0.2   0:00   0 rpc.statd

 1845 root      15   0   404  404   344 S     0.0  0.1   0:00   0 mdadm

 1904 root      24   0   504  504   456 S     0.0  0.1   0:00   0 apmd

 1948 root      15   0  1956 1956  1440 S     0.0  0.7   0:00   0 cupsd

 1974 root      15   0  1548 1548  1296 S     0.0  0.6   0:00   0 sshd

 1990 root      15   0   884  884   768 S     0.0  0.3   0:00   0 xinetd

 2020 root      15   0  2548 2548  1876 S     0.0  1.0   0:00   0 sendmail

 2029 smmsp     15   0  2296 2288  1752 S     0.0  0.9   0:00   0 sendmail

可以通过h查看交互名令列表

free

3 free 插看内存状态[root@localhost root]# free -m

             total       used       free     shared    buffers     cached

Mem:           248        141        106          0         13         67

-/+ buffers/cache:         60        187

Swap:         2047          0       2047

第一行从内核角度看内存使用,第二行从应用程序角度看内存使用。

free=free+buffers+cached.

4 vmstat

     vmstat命令报告关于内核线程、虚拟内存、磁盘、陷阱和 CPU 活动的统计信息。由vmstat命令生成的报告可以用于平衡系统负载活动。系统范围内的这些统计信息(所有的处理器中)都计算出以百分比表示的平均值,或者计算其总和。

[root@localhost root]# vmstat -m 2 5

procs                      memory      swap          io     system         cpu

 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa

 1  0      0    104     14     67    0    0    12     5  103    72  0  1 99  0

 0  0      0    104     14     67    0    0     0    20  104   132  0  0 100  0

 0  0      0    104     14     67    0    0     0     0  103   122  0  0 100  0

 1  0      0    104     14     67    0    0     0    44  107   134  0  0 100  0

 1  0      0    104     14     67    0    0     0     0  103   122  0  0 100  0

process

       r 为置于运行队列的内核线程数目

       b为置于等待对列的内核线程数目

cache

       free  : the amount of free physical memory (in KB by default)

       buff  : the amount of memory consumed by buffers (in KB by default)

       inact : the amount of memory on the inactive list (in KB by default)

       active: the amount of memory on the active list (in KB by default)

   swap

       si: 从磁盘写出的物理页总数(in KB/s by default)

       so: 写入磁盘的物理页总数(in KB/s by default)

   io

       bi: 从磁盘获取的数据块总数 (in blocks/s).

       bo: 写入磁盘的数据块总数 (in blocks/s).

   system

       in: the number of interrupts received (in interrupts/s)

       cs: the number of context switches (in switches/s)

   cpu

       us: 用户空间消耗的cpu百分比

       sy: 内黑消耗的cpu百分比

       wa: i/o等待的cpu百分比

       id: 空闲时间的百分比

<script type="text/javascript"></script>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值