[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BillMax questions -- Billmax and Switch Port Billing
this is what we've been using for years. if it's all munged, email me
directly and i'll send you a nicer copy.
this takes a service number and an RRD database. it pulls the values
from RRD and runs enter_stats for that service.
i have another wrapper script, if needed, that polls a table for all
services and their corresponding RRDs, and then feeds them all to this
script. it avoids having a bunch of ugly lines in cron, pushing it
all up to the database where you might have other customer data
anyway. you could include the RRD path as a custom field in the
service definition, etc.
--- begin cut here ---
#!/usr/local/bin/perl
# =-=-=-=-=
# $Id: get_stats,v 1.3 2004/09/21 16:12:17 root Exp root $
#
# Script to pull from RRD and stick it into MRTG
#
# Written by Adrian Goins <agoins@arces.net>
# =-=-=-=-=
use strict;
use Getopt::Std;
use vars qw( $rrd $service $rradir @output %opts $stats );
use vars qw( $rrdtool $options $command );
getopt( 'sr', \%opts ); # service, directory, rrd
$service = $opts{'s'};
$rradir = "/usr/local/apache/web-support/cacti/rra";
$rrd = $opts{'r'};
$rrdtool = "/usr/local/bin/rrdtool";
$options = " AVERAGE -s -5min";
$command = "/usr/local/billmax/bin/enter_stat";
# Get the info from RRD
@output = `$rrdtool fetch $rradir/$rrd $options`;
# Convert from RRD output to what Billmax wants
$stats = &parseout( @output );
# Enter it into Billmax
`$command Bandwidth $service $stats`;
sub parseout {
my( $in, $out, $index );
$index = $#output - 1;
$output[$index] =~ /(\d+):\s+(\S+)\s+(\S+)/;
return( "in=" . &unscinot($2) . ",out=" . &unscinot($3));
}
sub unscinot {
my( $num, $base, $digits, $final );
$num = shift;
( $base, $digits ) = split( /e\+/, $num );
$final = ( $base * ( 10 ** $digits ));
return ( $final * 8 / 1024 );
}
sub usage {
print( "Usage: get_stats -s {service} -r {rrd}\n" );
exit 1;
}
--- end cut here ---
--
Adrian Goins - President / CEO
Arces Network, LLC
http://www.arces.net
-----------------------------------------------------------------------------
To unsubscribe from the "BillMax Questions" mailing list, please
send a message to "majordomo@billmax.com" with "unsubscribe questions"
in the message body. The message must be sent from the exact email
address on the list.