(RADIATOR) Acct-Output-Octets and values larger than 4Gb
Igor Briski
igor.briski at iskon.hr
Thu Feb 3 01:33:08 CST 2005
On Thu, 2005-02-03 at 09:38 +1100, Brian Morris wrote:
> Hi Folks,
>
> I am trying to record the number of bytes (or Mb) downloaded by our
> broadband customers but Acct-Output-Octets loops back to zero once the
> customer has downloaded more than 4Gb in a session (unsigned integer
> limit).
>
> We also receive ERX attributes Unisphere-Output-Gigapackets and
> Unisphere-Output-Gigawords but these are defined as integer values so
> I am assuming they only report the number of whole Gigs.
>
> So I am looking for a way of recording the number of Mb downloaded
> with some accuracy better than whole Gb when the user has downloaded
> more than 4Gb...
>
> I guess one method would be to calculate it based on a formula
> something like TotalMb = (((gigawords div
> 4)+acctoutputoctets)/1000000)
> But is there a better way???
This is a hook I wrote for our broadband service. It is using
Acct-Input-Gigawords attribute which contains the number of times the
Acct-Input-Octets has wrapped. I believe that the
Unisphere-Output-Gigawords does the same, so just replace the attribute
names in this hook.
Maybe this could be added to goodies/ subdirectory in Radiator
distribution?
# -*- mode: Perl -*-
#
# 2004. Igor Briski, Iskon Internet d.d.
#
# Detects the presence of Acct-(Input|Output)-Gigawords
# attribute and calculates the real Acct-(Input|Output)-Octets
# values, and finally, replaces the values
sub
{
my $p = ${$_[0]};
my $code = $p->code();
if ($code eq 'Accounting-Request' &&
defined(my $ingiga = $p->get_attr('Acct-Input-Gigawords')) &&
defined(my $inoctets = $p->get_attr('Accti-Input-Octets')))
{
&main::log($main::LOG_DEBUG,
"Acct-Input-Gigawords attribute present,Counter overflowed.");
my $newinoctets = $inoctets + ($ingiga * 4294967296);
$p->change_attr('Acct-Input-Octets', $newinoctets);
&main::log($main::LOG_DEBUG,
"Acct-Input-Gigawords=$ingiga,Acct-Input-Octets =$inoctets");
&main::log($main::LOG_DEBUG,
"Calculated and replaced Acct-Input-Octets=$newinoctets");
}
if ($code eq 'Accounting-Request' &&
defined(my $outgiga = $p->get_attr('Acct-Output-Gigawords')) &&
defined(my $outoctets = $p->get_attr('Acct-Output-Octets')))
{
&main::log($main::LOG_DEBUG,
"Acct-Output-Gigawords attribute present,Counter overflowed.");
my $newoutoctets = $outoctets + ($outgiga * 4294967296);
$p->change_attr('Acct-Output-Octets', $newoutoctets);
&main::log($main::LOG_DEBUG,
"Acct-Output-Gigawords=$outgiga,Acct-Output-Octets=$outoctets");
&main::log($main::LOG_DEBUG,
"Calculated and replaced Acct-Output-Octets = $newoutoctets");
}
return;
}
--
Igor Briski <igor.briski at iskon.hr>
--
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.
More information about the radiator
mailing list