SUMMARY: snmp / mrtg stats for trunked interface

From: Steve Mickeler <steve_at_neptune.ca>
Date: Tue Feb 12 2002 - 08:59:12 EST
I created the solution to my own problem.

I ended up using a 'hack 'n' slash' method but it works, and thats what
counts.

I did things in the usual manner of doing external data for mrtg.

Heres the 4 step process:

1) the script trunk-stats.sh does the data gathering of the interfaces.

-- begin trunk-stats.sh --
#!/bin/sh

KSTATOUT=/tmp/kstatout.$$

/bin/kstat -m qfe > $KSTATOUT

rbytes=0 
obytes=0

for i in `cat $KSTATOUT | grep rbytes64 | awk '{print $2}'` 
do rbytes=`expr $i + $rbytes`
done 

for i in `cat $KSTATOUT | grep obytes64 | awk '{print $2}'` 
do obytes=`expr $i + $obytes` 
done 

echo "$rbytes"
echo "$obytes"
echo "1"
echo "`uname -n`"
-- end trunk-stats.sh --

2) make it a service via inetd:

2a) Add this line to /etc/inetd.conf

trunkstats      stream  tcp     nowait  root \
/usr/local/bin/trunk-stats.sh trunk-stats.sh

2b) Add this line to /etc/services

trunkstats      2225/tcp                                # trunkstats util
by steve

2c) HUP or restart inetd

3) perl script that runs on the mrtg server to connect to the trunked
interface host and get the stats

-- begin trunkstats.pl --
!/usr/bin/perl

$port = 2225;
$server = "your-server-here";

($d1, $d2, $prototype) = getprotobyname ("tcp");
($d1, $d2, $d3, $d4, $rawclient) = gethostbyname (`hostname`);
($d1, $d2, $d3, $d4, $rawserver) = gethostbyname ($server);
$clientaddr = pack ("Sna4x8", 2, 0, $rawclient);
$serveraddr = pack ("Sna4x8", 2, $port, $rawserver);
socket (SOCK, 2, 1, $prototype) || die ("No socket");
bind (SOCK, $clientaddr) || die ("Can't bind");
connect (SOCK, $serveraddr);

while($ReadSocket = <SOCK>) {
 chomp($ReadSocket);
 print "$ReadSocket\n";
}

close (SOCK);
-- end trunkstats.pl --

4) mrtg config for the trunked interface

Target[your.server_trunk]: `/usr/local/mrtg/bin/trunkstats.pl`
MaxBytes[your.server_trunk]: 50000000
Title[your.server_trunk]: Traffic Analysis for trunked interface --
your.server 
PageTop[your.server_trunk]: <H1>Traffic Analysis for trunked interface --
your.server</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>your.server</TD></TR>
   <TR><TD>Description:</TD><TD>trunked interface</TD></TR>
   <TR><TD>Max Speed:</TD>  <TD>50 MBytes/s</TD></TR>
 </TABLE>


And we're done.


On Mon, 11 Feb 2002, Steve Mickeler wrote:

> >From what I can tell, when trying to get the interface stats for qfe0
> which is my 'head-instance' for my trunk which contains qfe0 - qfe3 I'm
> only getting the stats for data that passed through the actual qfe0
> interface not the aggregate stats which is what I'm interested in.
> 
> Does anyone know of a way to get this info via snmp or know of an external
> script to get the aggregate throughput to pass that data back to mrtg ?
> 
> When using mrtg to graph stats on qfe0 i see 'Current In: 18.2 Mb/s'
> 
> When using nettr ( the trunking util ) I see:
> 
> 
> Name   Ipkts  Ierrs  Opkts  Oerrs  Collis  Crc     %Ipkts  %Opkts
> 
> qfe0   1664   0      585    0      0       0        25.63  19.57
> qfe1   0      0      0      0      0       0        0.00   0.00
> qfe2   4828   0      2405   0      0       0        74.37  80.43
> qfe3   0      0      0      0      0       0        0.00   0.00
>    
> (Aggregate Throughput(Mb/sec):    76.05(New Peak)    
> 		                  85.71(Past Peak)   
>                                   88.73%(New/Past))
> 
> 
> The aggregate throughput is really 76.05 Mb/s which is what I'm looking
> for.
> 
> 
> 
> Todays root password is brought to you by /dev/random
> 
> .-------------------------------------.
> | Steve Mickeler * Network Operations |
> +-------------------------------------+
> |     Neptune Internet Services       |
> `-------------------------------------'
> 
> 1024D/ACB58D4F = 0227 164B D680 9E13 9168  AE28 843F 57D7 ACB5 8D4F
> _______________________________________________
> sunmanagers mailing list
> sunmanagers@sunmanagers.org
> http://www.sunmanagers.org/mailman/listinfo/sunmanagers
> 



Todays root password is brought to you by /dev/random

.-------------------------------------.
| Steve Mickeler * Network Operations |
+-------------------------------------+
|     Neptune Internet Services       |
`-------------------------------------'

1024D/ACB58D4F = 0227 164B D680 9E13 9168  AE28 843F 57D7 ACB5 8D4F
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Feb 12 08:00:16 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:33 EST