[ previous ] [ next ] [ threads ]
 
 From:  "NewMedia42" <newmedia42 at excite dot com>
 To:  Graeme dot Davis at mci dot com, jvoigt at gmail dot com, m0n0wall at lists dot m0n0 dot ch
 Subject:  Re: [m0n0wall] Traffic Shaper/MRTG/IP usage question...
 Date:  Sun, 26 Sep 2004 07:31:42 -0400 (EDT)
Sure, this is running on Win2k, so take that into consideration, but if there are any platform
issues then they're bound to be trivial to fix.

The first thing I do is download the webpage from the m0n0 box - you can do this using curl or
cmdhttp or whatever you like.  For simplicity sake, let's call this file "mono.txt", it's just the
raw output from dump.cgi (in list archive).

Next, you need to specify the target in the MRTG config file manually with the perl script -
normally the line should look something like this:

Target[192_168_0_1]: '/mrtg/mono/monostat.pl 50005 50004 bytes'

followed by the specific MRTG config you want for this feed.  What this basically tells MRTG is to
execute the perl which extracts the two rules (50005 and 50004), specifically the number of bytes. 
You can alternatively replace bytes with packets to get the number of packets passed.  The two rules
should represent the inbound and output traffic shaper rules for the particular interface - I
specify them manually just in case I want to easily reverse the order or change them around (so if
the graph is backwards, just reverse the two rule numbers).

Then just set up a Scheduled Task or cron job to run the MRTG config file every 5 minutes and you're
good to go.  I also would recommend just running the autoconfig with MRTG and getting the SNMP dumps
as well, and using their entries in the config file as templates for these Traffic Shaper rules.

Hope that helps everyone!

# --- BEGIN PERL (monostat.pl)

#!/usr/bin/perl

# monostat <rulenumber1> <rulenumber2> <bytes | packets>

$Rule1 = $ARGV[0];
$Rule2 = $ARGV[1];
$DataType = $ARGV[2];
$Uptime = "Unknown";


open (FWSTAT, "/MRTG/mono/mono.txt")|| die "Can not decode mono stats\n";

$LineNumber = 0;
while(<FWSTAT>)
    {
    if ($LineNumber == 0)
        {
        $_ =~ s/[\015\012|\015|\012]//g;
        $Uptime = $_;
        }
    else
        {
        if ($_ =~ /^$Rule1/)
            {
            $_ =~ s/\W+/ /g;
            @WordList = split /\s/, $_;
            if ($DataType eq "bytes")
                {
                $Rule1Value = $WordList[2];
                }
            elsif ($DataType eq "packets")
                {
                $Rule1Value = $WordList[1];
                }
            }

        if ($_ =~ /^$Rule2/)
            {
            $_ =~ s/\W+/ /g;
            @WordList = split /\s/, $_;
            if ($DataType eq "bytes")
                {
                $Rule2Value = $WordList[2];
                }
            elsif ($DataType eq "packets")
                {
                $Rule2Value = $WordList[1];
                }
            }
        }

    $LineNumber += 1;
    }

print "$Rule1Value\n";
print "$Rule2Value\n";
print "$Uptime\n";
print "Rule $Rule1.$Rule2\n";

# --- END PERL






 --- On Tue 09/21, Graeme B. Davis < Graeme dot Davis at mci dot com > wrote:
From: Graeme B. Davis [mailto: Graeme dot Davis at mci dot com]
To: jvoigt at gmail dot com, m0n0wall at lists dot m0n0 dot ch
Date: Tue, 21 Sep 2004 07:35:31 -0400
Subject: Re: [m0n0wall] Traffic Shaper/MRTG/IP usage question...

Can you post/share the mrtg script that you're using to parse the<br>output?  I'm definately
interested in graphing my QoS and overall<br>bandwidth stats in
cacti/mrtg/rrdtool<br><br>Thanks!<br>Graeme<br><br>


_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!