Operating System - HP-UX
1833790 Members
2936 Online
110063 Solutions
New Discussion

Re: Real-Time Network Throughput Stats

 
SOLVED
Go to solution
Alzhy
Honored Contributor

Real-Time Network Throughput Stats

I am continously improving our home-grown system performance monitoring and stats gathering tool using Perl, and RRDTOOL. Already I have stats for just about anything except network. All I will need is actually code/script/command that will give me total network throughput(inbound+outbound) in Kbyes/sec.

Does anyone already have one written or could point me in the right direction?

Hakuna Matata.
7 REPLIES 7
Sridhar Bhaskarla
Honored Contributor

Re: Real-Time Network Throughput Stats

Hi Nelson,

RRD and MRTG are my favorites to use if I don't have perfview/measureware.

I would use the SNMP MIBs

.mgmt.mib-2.interfaces.ifTable.ifEntry

.ifOutOctets
.ifInOctets
.ifSpeed

An octet is 8 bits. So, you can keep your own counter and calculate the throughput based on the above three. You can integrate them with rrd.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Alzhy
Honored Contributor

Re: Real-Time Network Throughput Stats

Sridhar.. would you mind sharing how and possibly an example? I am a fast-tracked admin working on HPUX environments.. so far I think I've covered the essentials except network monitoring..

Hakuna Matata.
RAC_1
Honored Contributor
Solution

Re: Real-Time Network Throughput Stats

#Script for chekcing lan i/p and o/p stats.

let z=0

let y=$(lanadmin -g mibstats 0|grep -i oct|grep Inbound|awk '{print $4}')

let y2=$(lanadmin -g mibstats 0|grep -i oct|grep Outbound|awk '{print $4}')

while true

do

let x=0

sleep 1

x=$(lanadmin -g mibstats 0|grep -i oct|grep Inbound|awk '{print $4}')

x2=$(lanadmin -g mibstats 0|grep -i oct|grep Outbound|awk '{print $4}')

let t=$x-$y

let t2=$x2-$y2

let y=$x

let y2=$x2

let z=$z+1

let t=$t/1000

let t2=$t2/1000

echo "${t} Kb/s inbound, ${t2} Kb/s outbound"

done

This was posted on forum. I find it vary userful.
There is no substitute to HARDWORK
Sridhar Bhaskarla
Honored Contributor

Re: Real-Time Network Throughput Stats

Hi Nelson,

This means gathering information from my outdated memory cells. It's been almost 4 years since I used rrd/mrtg. I will try to put it as best as I can. Since you are already using rrdtool, you may be able to translate it into actual technical flow.

1. Create an rrd database with three data sources - Input Output and Throughput.

2. Gather the information of the remote systems for Input/Ouput using snmpget. For ex.,

snmpget -c "your_community" .1.3.6.1.2.1.2.2.1.16.1 |awk '{FS=":";print $3}' > outfile

Outfile will have the cumulative outoctets for the interface with the instance 1. Substract it with the previous collected value, devide with the interval of collection and multiply with 8 to get average outbound traffic (A) in bits. If the interface is reset, then the counter may start again from zero in which you will need to compare the previous and current values and arrive at the figure. Similarly calculate the inbound traffic (B). It's .1.10 OID. Add both of them and devide with the speed of the interface multipled by 100. You will get %utilization (C).

3. Use 'rrdtool update' with the above values to update the rrd database.

4. Now the database is updated, you can then graph them easily.

You can implement snmpget through perl.

On the other hand, if you have ssh/rlogin access, you can calculate the inbound and outbound octet using lanadmin command. Instead of snmpget, you will need to do an ssh to get the values.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Sridhar Bhaskarla
Honored Contributor

Re: Real-Time Network Throughput Stats

Hi (Again),

I was editing the message, left for lunch, came back finished editing and posted it.

I am talking in general about collecting information across multiple systems and loading them into rrd databases. snmp (if enabled) can get you this information irrespective of the OS.

If you are interested in only system or few HP systems with remote access , then the method described by RAC is sufficient.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Geoff Wild
Honored Contributor

Re: Real-Time Network Throughput Stats

I modified RAC's script to allow input of other lan cards:

#!/bin/sh
# Script for checking lan i/p and o/p stats.

if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "lanstats \"PPA\""
echo "Example:"
echo "lanstats 1"
exit 1
fi

#get the PPA from the command line
let LAN=$1
#initialize some variables
let z=0
let y=$(lanadmin -g mibstats $LAN|grep -i oct|grep Inbound|awk '{print $4}')
let y2=$(lanadmin -g mibstats $LAN|grep -i oct|grep Outbound|awk '{print $4}')

#run it until a control c
while true
do
let x=0
sleep 1
let x=$(lanadmin -g mibstats $LAN|grep -i oct|grep Inbound|awk '{print $4}')
let x2=$(lanadmin -g mibstats $LAN|grep -i oct|grep Outbound|awk '{print $4}')
let t=$x-$y
let t2=$x2-$y2
let y=$x
let y2=$x2
let z=$z+1
...skipping...
#!/bin/sh
# Script for checking lan i/p and o/p stats.
# Geoff Wild

if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "lanstats \"PPA\""
echo "Example:"
echo "lanstats 1"
exit 1
fi

#get the PPA from the command line
let LAN=$1
#initialize some variables
let z=0
let y=$(lanadmin -g mibstats $LAN|grep -i oct|grep Inbound|awk '{print $4}')
let y2=$(lanadmin -g mibstats $LAN|grep -i oct|grep Outbound|awk '{print $4}')

#run it until a control c
while true
do
let x=0
sleep 1
let x=$(lanadmin -g mibstats $LAN|grep -i oct|grep Inbound|awk '{print $4}')
let x2=$(lanadmin -g mibstats $LAN|grep -i oct|grep Outbound|awk '{print $4}')
let t=$x-$y
let t2=$x2-$y2
let y=$x
let y2=$x2
let z=$z+1
let t=$t/1000
let t2=$t2/1000
echo "${t} Kb/s inbound, ${t2} Kb/s outbound"
done
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
rick jones
Honored Contributor

Re: Real-Time Network Throughput Stats

Contemporary versions of Measureware/PerfView will track the bytes per second over time and keep them archived for you along with loads of other metrics. I suspect that any API/extraction information would be available on docs.hp.com.

I _believe_ there is also a monitor mode in Glance that might be usable.
there is no rest for the wicked yet the virtuous have no pillows