<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[给fast-cgi方式的php做一个检查脚本]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Wed, 05 Aug 2009 08:08:36 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	http://www.sunnyu.com/?p=93<br/>给fast-cgi方式的php做一个检查脚本<br/><br/>使用fast-cgi方式的php在使用，有时候由于编写的代码问题，使处理代码的php-cgi进程的运行占用很多时间，在将所有活动的 php-cgi 进程都占用后，web服务器对php的请求就失去响应了。<br/><br/>通过命令查看服务器上一共开了多少的 php-cgi 进程<br/><br/>&nbsp;&nbsp; 1.<br/><br/><div class="code">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ps -fe &#124;grep &quot;php&quot; &#124; grep -v &quot;grep&quot; &#124; wc -l</div><br/><br/>使用如下命令查看已经有多少个php-cgi进程用来处理tcp请求<br/><br/>&nbsp;&nbsp; 1.<br/><br/><div class="code">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;netstat -anop &#124; grep &quot;php&quot; &#124; grep -v &quot;grep&quot; &#124; wc -l</div><br/><br/>当被使用的php进程接近所开启的php进程数时，可以考虑将被耗用的php进程释放一下，以防止网站访问的阻塞。<br/><br/>按照以上思路编写了一个检查脚本。<br/><br/>1.<br/><br/><div class="code">#<br/> <br/>#!/bin/sh<br/> <br/>#<br/> <br/> <br/> <br/>echo &quot;begin check&quot;<br/> <br/> <br/> <br/>#define default check delta num<br/> <br/>defdeltacount=10<br/> <br/> <br/><br/>phpcount=`ps -fe &#124;grep &quot;php&quot; &#124; grep -v &quot;grep&quot; &#124; wc -l`<br/><br/>netstatcount=`sudo netstat -anop &#124; grep &quot;php&quot; &#124; grep -v &quot;grep&quot; &#124; wc -l`<br/><br/> <br/><br/>echo &quot;&nbsp;&nbsp;php process count is $phpcount<br/><br/> netstat process count is $netstatcount&quot;<br/><br/> <br/><br/>deltacount=`expr $phpcount - $netstatcount`<br/><br/> <br/><br/>if &#91; -n &quot;$1&quot; &#93;; then<br/><br/>&nbsp;&nbsp;defdeltacount=$1<br/><br/>fi<br/><br/> <br/><br/>echo &quot;deltacount is $deltacount, defdeltacount is $defdeltacount&quot;<br/><br/> <br/><br/>if &#91; $deltacount -lt $defdeltacount &#93;; then<br/><br/>&nbsp;&nbsp;echo &quot;&nbsp;&nbsp;need reset&quot;<br/><br/>&nbsp;&nbsp;sudo /root/tools/resetphp.sh<br/><br/>else<br/><br/>&nbsp;&nbsp;echo &quot;&nbsp;&nbsp;not need reset&quot;<br/><br/>fi<br/><br/> <br/><br/>echo &quot;check end&quot;</div><br/><br/>其中 /root/tools/resetphp.sh 为编写的php重启脚本。<br/>脚本可以放到 crontab 中，做自动定时检查处理。
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 给fast-cgi方式的php做一个检查脚本]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>