<?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>Incero &#187; monitor</title>
	<atom:link href="http://www.incero.com/tag/monitor/feed" rel="self" type="application/rss+xml" />
	<link>http://www.incero.com</link>
	<description>Dedicated Server</description>
	<lastBuildDate>Fri, 03 Feb 2012 06:48:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Shell Script To Report Network Usage, bytes/sec</title>
		<link>http://www.incero.com/sysadmin/shell-script-to-report-network-usage-bytessec</link>
		<comments>http://www.incero.com/sysadmin/shell-script-to-report-network-usage-bytessec#comments</comments>
		<pubDate>Sat, 11 Jul 2009 06:26:06 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[eth0]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[usage]]></category>

		<guid isPermaLink="false">http://www.incero.com/?p=233</guid>
		<description><![CDATA[In distributed apps it is often important to know the current network throughput speed on a particular server to help balance file serving requests etc. Installing MRTG or other software is not always desirable or possible. I created the shell script below to output the eth0 outbound transfer rate in bytes/second. To calculate megabits per [...]]]></description>
			<content:encoded><![CDATA[<p>In distributed apps it is often important to know the current network throughput speed on a particular server to help balance file serving requests etc.</p>
<p>Installing MRTG or other software is not always desirable or possible. I created the shell script below to output the eth0 outbound transfer rate in bytes/second. To calculate megabits per second simply divide the output by 131072.</p>
<p>You could post the data to a remote URL (e.g. a master health server) or write it to an xml file for reading by remote server or app, etc.</p>
<p>The speed returned is the average throughput over a 55 second period, you can adjust this as needed. Tested on CentOS 5.</p>
<blockquote><p>#!/bin/bash<br />
txfirst=`ifconfig eth0 | grep &#8220;TX bytes:&#8221; | cut -d &#8220;:&#8221; -f3 | cut -d &#8221; &#8221; -f1`<br />
datefirst=`date +%s`<br />
loop=1<br />
while [ loop=1 ]<br />
do<br />
txnew=`ifconfig eth0 | grep &#8220;TX bytes:&#8221; | cut -d &#8220;:&#8221; -f3 | cut -d &#8221; &#8221; -f1`<br />
datenew=`date +%s`</p>
<p>if [ $txnew -gt $txfirst ]<br />
then<br />
transferred=$((txnew-txfirst))<br />
timelapsed=$((datenew-datefirst))<br />
if [ $x &gt; 0 ]<br />
then<br />
bytessec=$(($transferred/$timelapsed))<br />
echo &#8220;$bytessec bytes/sec&#8221;<br />
fi<br />
txfirst=$((txnew))<br />
datefirst=$((datenew))<br />
else<br />
txfirst=$((txnew))<br />
datefirst=$((datenew))</p>
<p>fi<br />
sleep 55<br />
x=$(($x+1))<br />
done</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.incero.com/sysadmin/shell-script-to-report-network-usage-bytessec/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

