<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: iperf recipes</title>
	<atom:link href="http://www.hackmyidea.com/wordpress/2008/06/16/iperf-recipes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackmyidea.com/wordpress/2008/06/16/iperf-recipes/</link>
	<description>stuff i'm working on</description>
	<pubDate>Sat, 22 Nov 2008 04:05:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>By: JP</title>
		<link>http://www.hackmyidea.com/wordpress/2008/06/16/iperf-recipes/#comment-131</link>
		<dc:creator>JP</dc:creator>
		<pubDate>Sun, 22 Jun 2008 01:18:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackmyidea.com/wordpress/2008/06/16/iperf-recipes/#comment-131</guid>
		<description>Little script I wrote to check network bandwidth on our AIX servers via SNMP for Nagios, and then graph the results with PNP4 nagios every 5 minutes.  Need to know the adapter # you are monitoring, do an snmpwalk usually to get the info...i.e. snmpwalk -v 1 -c public IP-address &#124;more will give you IF-MIB::ifDescr.1 = STRING: en2, en2 number is from ifDescr which is 1, then just run the script as check_band.sh IP-address 1


#!/bin/bash

bytesin1=0
bytesout1=0
bytesin2=0
bytesout2=0
time1=0
time2=0


snmpget -Cf -c public -v 1 $1 .1.3.6.1.2.1.1.3.0 .1.3.6.1.2.1.2.2.1.16.$2 .1.3.6.1.2.1.2.2.1.10.$2 &#62; /tmp/$1.bandinfo.txt

bytesin1="`grep InOctets /tmp/$1.bandinfo.txt &#124; awk '{print $4}'`"
bytesout1="`grep OutOctets /tmp/$1.bandinfo.txt &#124; awk '{print $4}'`"
time1="`grep Time /tmp/$1.bandinfo.txt &#124; awk '{print $4}' &#124; sed 's/.\(.*\)/\1/' &#124;sed 's/\(.*\)./\1/'`"

`/bin/sleep 6`

snmpget -Cf -c public -v 1 $1 .1.3.6.1.2.1.1.3.0 .1.3.6.1.2.1.2.2.1.16.$2 .1.3.6.1.2.1.2.2.1.10.$2 &#62; /tmp/$1.bandinfo2.txt

bytesin2="`grep InOctets /tmp/$1.bandinfo2.txt &#124; awk '{print $4}'`"
bytesout2="`grep OutOctets /tmp/$1.bandinfo2.txt &#124; awk '{print $4}'`"
time2="`grep Time /tmp/$1.bandinfo2.txt &#124; awk '{print $4}' &#124; sed 's/.\(.*\)/\1/' &#124;sed 's/\(.*\)./\1/'`"

bytesindiff=$(($bytesin2 - $bytesin1))
bytesoutdiff=$(($bytesout2 - $bytesout1))
timediff=$((($time2 - $time1)/100))


KBpsIN=$(($bytesindiff/($timediff*1024)))
KBpsOUT=$(($bytesoutdiff/($timediff*1024)))

perf="&#124; KBps_in=$KBpsIN;;;; KBps_out=$KBpsOUT;;;;"

if [ "$KBpsIN" -lt 0 ]; then
        echo "Bandwidth loop -- no info"
        exit -1
fi
if [ "$KBpsOUT" -lt 0 ]; then
        echo "Bandwidth loop -- no info"
        exit -1
else
        echo "IN: $KBpsIN KBps, OUT: $KBpsOUT KBps $perf "
        exit 0
fi</description>
		<content:encoded><![CDATA[<p>Little script I wrote to check network bandwidth on our AIX servers via SNMP for Nagios, and then graph the results with PNP4 nagios every 5 minutes.  Need to know the adapter # you are monitoring, do an snmpwalk usually to get the info&#8230;i.e. snmpwalk -v 1 -c public IP-address |more will give you IF-MIB::ifDescr.1 = STRING: en2, en2 number is from ifDescr which is 1, then just run the script as check_band.sh IP-address 1</p>
<p>#!/bin/bash</p>
<p>bytesin1=0<br />
bytesout1=0<br />
bytesin2=0<br />
bytesout2=0<br />
time1=0<br />
time2=0</p>
<p>snmpget -Cf -c public -v 1 $1 .1.3.6.1.2.1.1.3.0 .1.3.6.1.2.1.2.2.1.16.$2 .1.3.6.1.2.1.2.2.1.10.$2 &gt; /tmp/$1.bandinfo.txt</p>
<p>bytesin1=&#8221;`grep InOctets /tmp/$1.bandinfo.txt | awk &#8216;{print $4}&#8217;`&#8221;<br />
bytesout1=&#8221;`grep OutOctets /tmp/$1.bandinfo.txt | awk &#8216;{print $4}&#8217;`&#8221;<br />
time1=&#8221;`grep Time /tmp/$1.bandinfo.txt | awk &#8216;{print $4}&#8217; | sed &#8217;s/.\(.*\)/\1/&#8217; |sed &#8217;s/\(.*\)./\1/&#8217;`&#8221;</p>
<p>`/bin/sleep 6`</p>
<p>snmpget -Cf -c public -v 1 $1 .1.3.6.1.2.1.1.3.0 .1.3.6.1.2.1.2.2.1.16.$2 .1.3.6.1.2.1.2.2.1.10.$2 &gt; /tmp/$1.bandinfo2.txt</p>
<p>bytesin2=&#8221;`grep InOctets /tmp/$1.bandinfo2.txt | awk &#8216;{print $4}&#8217;`&#8221;<br />
bytesout2=&#8221;`grep OutOctets /tmp/$1.bandinfo2.txt | awk &#8216;{print $4}&#8217;`&#8221;<br />
time2=&#8221;`grep Time /tmp/$1.bandinfo2.txt | awk &#8216;{print $4}&#8217; | sed &#8217;s/.\(.*\)/\1/&#8217; |sed &#8217;s/\(.*\)./\1/&#8217;`&#8221;</p>
<p>bytesindiff=$(($bytesin2 - $bytesin1))<br />
bytesoutdiff=$(($bytesout2 - $bytesout1))<br />
timediff=$((($time2 - $time1)/100))</p>
<p>KBpsIN=$(($bytesindiff/($timediff*1024)))<br />
KBpsOUT=$(($bytesoutdiff/($timediff*1024)))</p>
<p>perf=&#8221;| KBps_in=$KBpsIN;;;; KBps_out=$KBpsOUT;;;;&#8221;</p>
<p>if [ "$KBpsIN" -lt 0 ]; then<br />
        echo &#8220;Bandwidth loop &#8212; no info&#8221;<br />
        exit -1<br />
fi<br />
if [ "$KBpsOUT" -lt 0 ]; then<br />
        echo &#8220;Bandwidth loop &#8212; no info&#8221;<br />
        exit -1<br />
else<br />
        echo &#8220;IN: $KBpsIN KBps, OUT: $KBpsOUT KBps $perf &#8221;<br />
        exit 0<br />
fi</p>
]]></content:encoded>
	</item>
</channel>
</rss>
