<?xml version="1.0" encoding="UTF-8"?><!-- generator="lyceum/1.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Tips and tricks:  How do I capture the output of &#8220;top&#8221; to a file?</title>
	<link>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/</link>
	<description>Red Hat Magazine</description>
	<pubDate>Thu, 24 Jul 2008 16:06:19 +0000</pubDate>
	<generator>http://lyceum.ibiblio.org/?v=1.0.2</generator>

	<item>
		<title>by: vikas sharma</title>
		<link>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/#comment-81905</link>
		<pubDate>Fri, 09 May 2008 13:31:02 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/#comment-81905</guid>
					<description>This command is similar to ps command
give ps -el &#62; /usr/process.txt</description>
		<content:encoded><![CDATA[<p>This command is similar to ps command<br />
give ps -el &gt; /usr/process.txt
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: mesrik</title>
		<link>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/#comment-71294</link>
		<pubDate>Sat, 26 Apr 2008 05:06:54 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/#comment-71294</guid>
					<description>Just to point out that you certainly can use pipes too. 

Here's snippet from my quick radiusguard script that makes sure radiusd stays running and does not take more than 20% of the cpu.

...
runlevel=$(who -r &#124; sed 's/.*run-level *\([3-5]\) .*$/\1/')

if [ $(chkconfig --list radiusd &#124; grep -c "$runlevel:on") -eq 1 ]; then
    # get radiusd cpu usage
    CPU_USAGE=$(top -b -n 1 &#124;\
        awk '/^[0-9]+ radiusd/ { cpu = $9 } 
        END { printf("%i\n", length(cpu) == 0 ? -1 : cpu); }')
    export CPU_USAGE
    echo "$CPU_USAGE" &#62;/var/tmp/radiusguard.last
    if [ $CPU_USAGE -eq -1 ]; then
        act 'service radiusd stop ; service radiusd start'
    else
        if [ $CPU_USAGE -ge 20 ]; then
            act 'service radiusd restart'
        fi
    fi
fi

act is a function that sends email on event including outputs of the commands run. Runlevel is checked against chkconfig so that it won't run berzerk when startup script is intentionally disabled or similar situations.

Needed that script before last upgrade with radius, it just was occationally acting a cpu hog or died mysterioysly. Cpu hogging was really bad, it rendered the LDAP service in the same host unuseable.

Cheers,

:-) riku

</description>
		<content:encoded><![CDATA[<p>Just to point out that you certainly can use pipes too. </p>
<p>Here&#8217;s snippet from my quick radiusguard script that makes sure radiusd stays running and does not take more than 20% of the cpu.</p>
<p>&#8230;<br />
runlevel=$(who -r | sed &#8217;s/.*run-level *\([3-5]\) .*$/\1/&#8217;)</p>
<p>if [ $(chkconfig &#8211;list radiusd | grep -c &#8220;$runlevel:on&#8221;) -eq 1 ]; then<br />
    # get radiusd cpu usage<br />
    CPU_USAGE=$(top -b -n 1 |\<br />
        awk &#8216;/^[0-9]+ radiusd/ { cpu = $9 }<br />
        END { printf(&#8221;%i\n&#8221;, length(cpu) == 0 ? -1 : cpu); }&#8217;)<br />
    export CPU_USAGE<br />
    echo &#8220;$CPU_USAGE&#8221; &gt;/var/tmp/radiusguard.last<br />
    if [ $CPU_USAGE -eq -1 ]; then<br />
        act &#8217;service radiusd stop ; service radiusd start&#8217;<br />
    else<br />
        if [ $CPU_USAGE -ge 20 ]; then<br />
            act &#8217;service radiusd restart&#8217;<br />
        fi<br />
    fi<br />
fi</p>
<p>act is a function that sends email on event including outputs of the commands run. Runlevel is checked against chkconfig so that it won&#8217;t run berzerk when startup script is intentionally disabled or similar situations.</p>
<p>Needed that script before last upgrade with radius, it just was occationally acting a cpu hog or died mysterioysly. Cpu hogging was really bad, it rendered the LDAP service in the same host unuseable.</p>
<p>Cheers,</p>
<p>:-) riku
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Saida do Top para um arquivo &#171; Tecnologia Livre!</title>
		<link>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/#comment-69299</link>
		<pubDate>Tue, 22 Apr 2008 00:11:22 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/#comment-69299</guid>
					<description>[...] Fonte: Red Hat Magazine [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Fonte: Red Hat Magazine [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jim Campbell</title>
		<link>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/#comment-67438</link>
		<pubDate>Wed, 16 Apr 2008 19:34:37 +0000</pubDate>
		<guid>http://www.redhatmagazine.com/2008/04/16/tips-and-tricks-how-do-i-capture-the-output-of-top-to-a-file/#comment-67438</guid>
					<description>This is a very simple, but very helpful tip.  Thanks!</description>
		<content:encoded><![CDATA[<p>This is a very simple, but very helpful tip.  Thanks!
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
