﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>P.Linux Laboratory &#187; uptime</title>
	<atom:link href="http://www.penglixun.com/tag/uptime/feed" rel="self" type="application/rss+xml" />
	<link>http://www.penglixun.com</link>
	<description>MySQL DBA &#38; Linux SA</description>
	<lastBuildDate>Sun, 22 Jan 2012 16:34:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>[转]Linux中查看系统资源占用情况的命令</title>
		<link>http://www.penglixun.com/tech/system/commond_watch_linux_system_resources.html</link>
		<comments>http://www.penglixun.com/tech/system/commond_watch_linux_system_resources.html#comments</comments>
		<pubDate>Wed, 21 Oct 2009 09:54:58 +0000</pubDate>
		<dc:creator>P.Linux</dc:creator>
				<category><![CDATA[操作系统]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[iostat]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[top]]></category>
		<category><![CDATA[uptime]]></category>
		<category><![CDATA[vmstat]]></category>

		<guid isPermaLink="false">http://www.penglixun.com/PLX/Blog/?p=440</guid>
		<description><![CDATA[本文内容遵从CC版权协议, 可以随意转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明网址: http://www.penglixun.com/tech/system/commond_watch_linux_system_resources.html top: 主要参数 d：指定更... ]]></description>
			<content:encoded><![CDATA[<p><span style="color: #888888;">本文内容遵从<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" target="_blank">CC版权协议</a>, 可以随意转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明</br>网址: http://www.penglixun.com/tech/system/commond_watch_linux_system_resources.html </p>
<p></span><span style="font-size: large;"><strong>top</strong>:</span><br />
主要参数<br />
d：指定更新的间隔，以秒计算。<br />
q：没有任何延迟的更新。如果使用者有超级用户，则top命令将会以最高的优先序执行。<br />
c：显示进程完整的路径与名称。<br />
S：累积模式，会将己完成或消失的子行程的CPU时间累积起来。<br />
s：安全模式。<br />
i：不显示任何闲置(Idle)或无用(Zombie)的行程。<br />
n：显示更新的次数，完成后将会退出to<br />
显示参数:<br />
PID（Process ID）：进程标示号。<br />
USER：进程所有者的用户名。<br />
PR：进程的优先级别。<br />
NI：进程的优先级别数值。<br />
VIRT：进程占用的虚拟内存值。<br />
RES：进程占用的物理内存值。<br />
SHR：进程使用的共享内存值。<br />
S：进程的状态，其中S表示休眠，R表示正在运行，Z表示僵死状态，N表示该进程优先值是负数。<br />
%CPU：该进程占用的CPU使用率。<br />
%MEM：该进程占用的物理内存和总内存的百分比。<br />
TIME＋：该进程启动后占用的总的CPU时间。<br />
Command：进程启动的启动命令名称，如果这一行显示不下，进程会有一个完整的命令行。<br />
top命令使用过程中，还可以使用一些交互的命令来完成其它参数的功能。这些命令是通过快捷键启动的。<br />
&lt;空格&gt;：立刻刷新。<br />
P：根据CPU使用大小进行排序。<br />
T：根据时间、累计时间排序。<br />
q：退出top命令。<br />
m：切换显示内存信息。<br />
t：切换显示进程和CPU状态信息。<br />
c：切换显示命令名称和完整命令行。<br />
M：根据使用内存大小进行排序。<br />
W：将当前设置写入~/.toprc文件中。这是写top配置文件的推荐方法。</p>
<p><strong><span style="font-size: large;"><span id="more-440"></span>free</span></strong><br />
1.作用<br />
free命令用来显示内存的使用情况，使用权限是所有用户。</p>
<p>2.格式<br />
free [－b－k－m] [－o] [－s delay] [－t] [－V]</p>
<p>3.主要参数<br />
－b －k －m：分别以字节（<acronym title="Kilobyte">KB</acronym>、<acronym title="Megabyte">MB</acronym>）为单位显示内存使用情况。<br />
－s delay：显示每隔多少秒数来显示一次内存使用情况。<br />
－t：显示内存总和列。<br />
－o：不显示缓冲区调节列。</p>
<p><strong><span style="font-size: large;">uptime</span></strong><br />
18:59:15 up 25 min,  2 users,  load average: 1.23, 1.32, 1.21<br />
现在的时间<br />
系统开机运转到现在经过的时间<br />
连线的使用者数量<br />
最近一分钟，五分钟和十五分钟的系统负载<br />
参数： -V 显示版本资讯。</p>
<p><strong><span style="font-size: large;">vmstat</span></strong><br />
procs &#8212;&#8212;&#8212;&#8211;memory&#8212;&#8212;&#8212;- &#8212;swap&#8211; &#8212;&#8211;io&#8212;- &#8211;system&#8211; &#8212;-cpu&#8212;-<br />
r  b   swpd free   buff   cache    si   so    bi     bo    in    cs   us  sy  id wa<br />
0  1  24980 10792 8296  47316    5   19   205    52  1161   698  26  3  1  70<br />
1 观察磁盘活动情况<br />
磁盘活动情况主要从以下几个指标了解：<br />
bi：表示从磁盘每秒读取的块数(blocks/s)。数字越大，表示读磁盘的活动越多。<br />
bo：表示每秒写到磁盘的块数（blocks/s）。数字越大，表示写磁盘的活动越多。<br />
wa：cpu等待磁盘I／O（未决的磁盘IO）的时间比例。数字越大，表示文件系统活动阻碍cpu的情况越严重，因为cpu在等待慢速的磁盘系统提供数据。wa为0是最理想的。如果wa经常大于10，可能文件系统就需要进行性能调整了。<br />
2 观察cpu活动情况<br />
vmstat比top更能反映出cpu的使用情况：<br />
us：用户程序使用cpu的时间比例。这个数字越大，表示用户进程越繁忙。<br />
sy：系统调用使用cpu的时间比例。注意，NFS由于是在内核里面运行的，所以NFS活动所占用的cpu时间反映在sy里面。这个数字经常很大 的话，就需要注意是否某个内核进程，比如NFS任务比较繁重。如果us和sy同时都比较大的话，就需要考虑将某些用户程序分离到另外的服务器上面，以免互 相影响。<br />
id：cpu空闲的时间比例。<br />
wa：cpu等待未决的磁盘IO的时间比例。</p>
<p><strong><span style="font-size: large;">iostat</span></strong><br />
用于统计CPU的使用情况及tty设备、硬盘和<acronym title="Compact Disc">CD</acronym>-ROM的I/0量<br />
参数:<br />
-c      只显示CPU行<br />
-d      显示磁盘行<br />
-k      以千字节为单位显示磁盘输出<br />
-t       在输出中包括时间戳<br />
-x      在输出中包括扩展的磁盘指标</p>
<p>avg-cpu:  %user   %nice    %sys %iowait   %idle<br />
20.25    0.18    2.61   76.39    0.57<br />
%iowait 等待本地I/O时CPU空闲时间的百分比<br />
%idle 未等待本地I/O时CPU空闲时间的百分比</p>
<p>Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn<br />
hda               9.86       284.34        84.48     685407     2036<br />
每秒传输数（tps）、每秒512字节块读取数（Blk_read/s）、每秒512字节块写入数（Blk_wrtn/s）和512字节块读取（Blk_read）和写入（Blk_wrtn）的总数量。</p><h2  class="related_post_title">类似的文章</h2><ul class="related_post"><li>2010年08月10日 -- <a href="http://www.penglixun.com/tech/system/how_to_calc_load_cpu.html" title="Load和CPU利用率是如何算出来的">Load和CPU利用率是如何算出来的</a> (5)</li><li>2009年10月30日 -- <a href="http://www.penglixun.com/tech/system/use_iostat_analyse_linux_disks.html" title="[转]iostat来对Linux硬盘IO性能进行了解">[转]iostat来对Linux硬盘IO性能进行了解</a> (0)</li><li>2012年01月23日 -- <a href="http://www.penglixun.com/tech/database/case_about_innodb_faster_than_oracle.html" title="一个InnoDB性能超过Oracle的调优Case">一个InnoDB性能超过Oracle的调优Case</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.penglixun.com/tech/system/commond_watch_linux_system_resources.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

