﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-点滴-随笔分类-linux基本操作</title><link>http://www.cppblog.com/chage/category/13219.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 28 Apr 2010 11:26:52 GMT</lastBuildDate><pubDate>Wed, 28 Apr 2010 11:26:52 GMT</pubDate><ttl>60</ttl><item><title>zz:mpstat (linux)</title><link>http://www.cppblog.com/chage/archive/2010/04/27/113686.html</link><dc:creator>chage</dc:creator><author>chage</author><pubDate>Tue, 27 Apr 2010 02:20:00 GMT</pubDate><guid>http://www.cppblog.com/chage/archive/2010/04/27/113686.html</guid><wfw:comment>http://www.cppblog.com/chage/comments/113686.html</wfw:comment><comments>http://www.cppblog.com/chage/archive/2010/04/27/113686.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chage/comments/commentRss/113686.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chage/services/trackbacks/113686.html</trackback:ping><description><![CDATA[
		<p>
				<strong>
						<font size="1">MPSTAT -P ALL 2 3</font>
				</strong>
		</p>
		<p>
		</p>
		<p style="text-indent: 2em;">mpstat是Multiprocessor 
Statistics的缩写，是实时系统监控工具。其报告与CPU的一些统计信息，这些信息存放在/proc/stat文件中。在多CPUs系统里，其不
但能查看所有CPU的平均状况信息，而且能够查看特定CPU的信息。下面只介绍 mpstat与CPU相关的参数，mpstat的语法如下：</p>
		<p style="text-indent: 2em;">mpstat [-P {|ALL}] [internal [count]]</p>
		<p style="text-indent: 2em;">参数的含义如下：</p>
		<p style="text-indent: 2em;">参数 解释</p>
		<p style="text-indent: 2em;">-P {|ALL} 表示监控哪个CPU， cpu在[0,cpu个数-1]中取值</p>
		<p style="text-indent: 2em;">internal 相邻的两次采样的间隔时间</p>
		<p style="text-indent: 2em;">count 采样的次数，count只能和delay一起使用</p>
		<p style="text-indent: 2em;">当没有参数时，mpstat则显示系统启动以后所有信息的平均值。有interval时，第
一行的信息自系统启动以来的平均信息。从第二行开始，输出为前一个interval时间段的平均信息。与CPU有关的输出的含义如下：</p>
		<p style="text-indent: 2em;">参数 解释 从/proc/stat获得数据</p>
		<p style="text-indent: 2em;">CPU 处理器ID</p>
		<p style="text-indent: 2em;">user 在internal时间段里，用户态的CPU时间（%） ，不包含 
nice值为负 进程 usr/total*100</p>
		<p style="text-indent: 2em;">nice 在internal时间段里，nice值为负进程的CPU时间（%） 
nice/total*100</p>
		<p style="text-indent: 2em;">system 在internal时间段里，核心时间（%） 
system/total*100</p>
		<p style="text-indent: 2em;">iowait 在internal时间段里，硬盘IO等待时间（%） 
iowait/total*100</p>
		<p style="text-indent: 2em;">irq 在internal时间段里，软中断时间（%） irq/total*100</p>
		<p style="text-indent: 2em;">soft 在internal时间段里，软中断时间（%） 
softirq/total*100</p>
		<p style="text-indent: 2em;">idle 
在internal时间段里，CPU除去等待磁盘IO操作外的因为任何原因而空闲的时间闲置时间 （%） idle/total*100</p>
		<p style="text-indent: 2em;">intr/s 在internal时间段里，每秒CPU接收的中断的次数 
intr/total*100</p>
		<p style="text-indent: 2em;">CPU总的工作时
间=total_cur=user+system+nice+idle+iowait+irq+softirq</p>
		<p style="text-indent: 2em;">total_pre=pre_user+ pre_system+ pre_nice+ 
pre_idle+ pre_iowait+ pre_irq+ pre_softirq</p>
		<p style="text-indent: 2em;">user=user_cur – user_pre</p>
		<p style="text-indent: 2em;">total=total_cur-total_pre</p>
		<p style="text-indent: 2em;">其中_cur 
表示当前值，_pre表示interval时间前的值。上表中的所有值可取到两位小数点。</p>
		<p style="text-indent: 2em;">
				<font size="4">cat /proc/stat</font>
		</p>
		<p style="text-indent: 2em;">“ctxt”给出了自系统启动以来CPU发生的上下文<a class="channel_keylink" href="http://cisco.chinaitlab.com/List_7.html" target="_blank">交换</a>的次数。</p>
		<p style="text-indent: 2em;">“btime”给出了从系统启动到现在为止的时间，单位为秒。</p>
		<p style="text-indent: 2em;">“processes (total_forks) 自系统启动以来所创建的任务的个数目。</p>
		<p style="text-indent: 2em;">“procs_running”：当前运行队列的任务的数目。</p>
		<p style="text-indent: 2em;">“procs_blocked”：当前被阻塞的任务的数目。</p>
<img src ="http://www.cppblog.com/chage/aggbug/113686.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chage/" target="_blank">chage</a> 2010-04-27 10:20 <a href="http://www.cppblog.com/chage/archive/2010/04/27/113686.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用netstat命令发现大量的TIME_WAIT现象（zz）</title><link>http://www.cppblog.com/chage/archive/2010/03/10/109371.html</link><dc:creator>chage</dc:creator><author>chage</author><pubDate>Wed, 10 Mar 2010 09:29:00 GMT</pubDate><guid>http://www.cppblog.com/chage/archive/2010/03/10/109371.html</guid><wfw:comment>http://www.cppblog.com/chage/comments/109371.html</wfw:comment><comments>http://www.cppblog.com/chage/archive/2010/03/10/109371.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chage/comments/commentRss/109371.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chage/services/trackbacks/109371.html</trackback:ping><description><![CDATA[
		<p>原文链接：<a href="http://blog.csdn.net/sungblog/archive/2006/11/15/1385345.aspx">http://blog.csdn.net/sungblog/archive/2006/11/15/1385345.aspx</a><br />用netstat命令发现大量的TIME_WAIT现象：<br />netstat -ae|grep 1521|grep root<br />……<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root<br />TIME_WAIT   root</p>
		<p>检查net.ipv4.tcp_tw当前值，将当前的值更改为1分钟：<br />[root@aaa1 ~]# sysctl -a|grep net.ipv4.tcp_tw<br />net.ipv4.tcp_tw_reuse = 0<br />net.ipv4.tcp_tw_recycle = 0<br />[root@aaa1 ~]#</p>
		<p>vi /etc/sysctl<br />增加或修改net.ipv4.tcp_tw值：<br />net.ipv4.tcp_tw_reuse = 1<br />net.ipv4.tcp_tw_recycle = 1</p>
		<p>使内核参数生效：<br />[root@aaa1 ~]# sysctl -p</p>
		<p>[root@aaa1 ~]# sysctl -a|grep net.ipv4.tcp_tw<br />net.ipv4.tcp_tw_reuse = 1<br />net.ipv4.tcp_tw_recycle = 1</p>
		<p>用netstat再观察正常</p>
		<p>
				<br />这里解决问题的关键是如何能够重复利用time_wait的值，我们可以设置时检查一下time和wait的值<br />#sysctl -a | grep time | grep wait<br />net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120<br />net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60<br />net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120</p>
		<p> </p>
		<p>本文来自CSDN博客，转载请标明出处：<a href="http://blog.csdn.net/sungblog/archive/2006/11/15/1385345.aspx">http://blog.csdn.net/sungblog/archive/2006/11/15/1385345.aspx</a></p>
<img src ="http://www.cppblog.com/chage/aggbug/109371.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chage/" target="_blank">chage</a> 2010-03-10 17:29 <a href="http://www.cppblog.com/chage/archive/2010/03/10/109371.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>