head	1.4;
access;
symbols
	RELENG_4_11_0_RELEASE:1.3.2.1
	RELENG_4_11:1.3.2.1.0.16
	RELENG_4_11_BP:1.3.2.1
	RELENG_4_10_0_RELEASE:1.3.2.1
	RELENG_4_10:1.3.2.1.0.14
	RELENG_4_10_BP:1.3.2.1
	RELENG_4_9_0_RELEASE:1.3.2.1
	RELENG_4_9:1.3.2.1.0.12
	RELENG_4_9_BP:1.3.2.1
	RELENG_4_8_0_RELEASE:1.3.2.1
	RELENG_4_8:1.3.2.1.0.10
	RELENG_4_8_BP:1.3.2.1
	RELENG_4_7_0_RELEASE:1.3.2.1
	RELENG_4_7:1.3.2.1.0.8
	RELENG_4_7_BP:1.3.2.1
	RELENG_4_6_2_RELEASE:1.3.2.1
	RELENG_4_6_1_RELEASE:1.3.2.1
	RELENG_4_6_0_RELEASE:1.3.2.1
	RELENG_4_6:1.3.2.1.0.6
	RELENG_4_6_BP:1.3.2.1
	RELENG_4_5_0_RELEASE:1.3.2.1
	RELENG_4_5:1.3.2.1.0.4
	RELENG_4_5_BP:1.3.2.1
	RELENG_4_4_0_RELEASE:1.3.2.1
	RELENG_4_4:1.3.2.1.0.2
	RELENG_4_4_BP:1.3.2.1
	RELENG_4_3_0_RELEASE:1.3
	RELENG_4_3:1.3.0.4
	RELENG_4_3_BP:1.3
	RELENG_4_2_0_RELEASE:1.3
	RELENG_4_1_1_RELEASE:1.3
	PRE_SMPNG:1.3
	RELENG_4_1_0_RELEASE:1.3
	RELENG_3_5_0_RELEASE:1.1.2.2
	RELENG_4_0_0_RELEASE:1.3
	RELENG_4:1.3.0.2
	RELENG_4_BP:1.3
	RELENG_3_4_0_RELEASE:1.1.2.2
	RELENG_3_3_0_RELEASE:1.1.2.1
	RELENG_3_2_PAO:1.1.0.4
	RELENG_3_2_PAO_BP:1.1
	RELENG_3_2_0_RELEASE:1.1
	RELENG_3_1_0_RELEASE:1.1
	RELENG_3:1.1.0.2
	RELENG_3_BP:1.1;
locks; strict;
comment	@# @;


1.4
date	2001.05.25.13.25.58;	author hm;	state dead;
branches;
next	1.3;

1.3
date	99.08.28.00.19.20;	author peter;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	99.05.20.10.07.28;	author hm;	state Exp;
branches;
next	1.1;

1.1
date	99.01.18.14.05.23;	author hm;	state Exp;
branches
	1.1.2.1;
next	;

1.1.2.1
date	99.08.29.16.45.07;	author peter;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	99.11.16.17.28.44;	author joe;	state Exp;
branches;
next	;

1.3.2.1
date	2001.08.12.01.57.09;	author obrien;	state dead;
branches;
next	;


desc
@@


1.4
log
@Add the contributed directory from the i4b tarball and the files from it
which would be nice to have.
Move isdnd_acct and isdnctl to the contrib directory where they belong to.
@
text
@#!/usr/bin/perl
#---------------------------------------------------------------------------
#
# Copyright (c) 1996, 1998 Hellmuth Michaelis. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.

# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#---------------------------------------------------------------------------
#
#	accounting report script for the isdnd daemon accounting info
#	-------------------------------------------------------------
#
# $FreeBSD: src/share/examples/isdn/isdnd_acct,v 1.3 1999/08/28 00:19:20 peter Exp $
#
#	last edit-date: [Wed May  5 16:24:16 1999]
#
#	-hm	updated for isdnd support
#
#---------------------------------------------------------------------------

# where the isdnd accounting file resides
$ACCT_FILE = "/var/log/isdnd.acct";

# the charge for a unit, currently 0,12 DM
$UNIT_PRICE = 0.12;

# open accounting file
open(IN, $ACCT_FILE) ||
	die "ERROR, cannot open $ACCT_FILE !\n";

# set first thru flag
$first = 1;

# process file line by line
while (<IN>)
{
	# remove ( and ) from length and bytecounts
	tr/()//d;

	# split line into pieces
	($from_d, $from_h, $dash, $to_d, $to_h, $name, $units, $secs, $byte)
		= split(/ /, $_);

	# get starting date
	if($first)
	{
		$from = "$from_d $from_h";
		$first = 0;
	}
		
	# split bytecount
	($inb, $outb) = split(/\//, $byte);

	# process fields
	$a_secs{$name} += $secs;
	$a_calls{$name}++;
	$a_units{$name} += $units;
	$a_charge{$name} += $units * $UNIT_PRICE;
	$a_inbytes{$name} += $inb;
	$a_outbytes{$name} += $outb;
	$a_bytes{$name} = $a_bytes{$name} + $inb + $outb;
}

# close accouting file
close(IN);

# write header
print "\n";
print "     ISDN Accounting Report   ($from -> $to_d $to_h)\n";
print "     =====================================================================\n";

#write the sum for each interface/name
foreach $name (sort(keys %a_secs))
{
	$o_secs = $a_secs{$name};
	$gt_secs += $o_secs;
	$o_calls = $a_calls{$name};
	$gt_calls += $o_calls;
	$o_units = $a_units{$name};
	$gt_units += $o_units;
	$o_charge = $a_charge{$name};
	$gt_charge += $o_charge;
	$o_inbytes = $a_inbytes{$name};
	$gt_inbytes += $o_inbytes;
	$o_outbytes = $a_outbytes{$name};
	$gt_outbytes += $o_outbytes;
	$o_bytes = $a_bytes{$name};
	$gt_bytes += $o_bytes;
	write;
}

$o_secs = $gt_secs;
$o_calls = $gt_calls;
$o_units = $gt_units;
$o_charge = $gt_charge;
$o_inbytes = $gt_inbytes;
$o_outbytes = $gt_outbytes;
$o_bytes = $gt_bytes;
$name = "Total";

print "======= ====== ===== ===== ======== ============ ============ ============\n";
write;

print "\n\n";
exit;

# top of page header
format top =

Name    charge units calls     secs      inbytes     outbytes        bytes
------- ------ ----- ----- -------- ------------ ------------ ------------
.

# record template
format STDOUT =
@@<<<<<< @@##.## @@#### @@#### @@####### @@########### @@########### @@###########
$name,  $o_charge, $o_units, $o_calls, $o_secs, $o_inbytes, $o_outbytes, $o_bytes
.

# EOF
@


1.3
log
@$Id$ -> $FreeBSD$
@
text
@d32 1
a32 1
# $FreeBSD$
@


1.3.2.1
log
@MFC: update to 1.01.

Approved by:	jkh
@
text
@d32 1
a32 1
# $FreeBSD: src/share/examples/isdn/isdnd_acct,v 1.3 1999/08/28 00:19:20 peter Exp $
@


1.2
log
@upgrade isdn4bsd from version 0.71 to the just released version 0.81
@
text
@d32 1
a32 1
#	$Id: isdnd_acct,v 1.2 1999/05/05 14:25:59 hm Exp $
@


1.1
log
@Add ISDN (i4b) documentation and examples
@
text
@d32 1
a32 1
#	$Id: isdnd_acct,v 1.1 1998/01/23 13:38:53 hm Exp $
d34 3
a36 1
#	last edit-date: [Mon Jan 18 14:08:10 1999]
d89 1
a89 1
print "     ==================================================================\n";
@


1.1.2.1
log
@$Id$ -> $FreeBSD$
@
text
@d32 1
a32 1
# $FreeBSD$
@


1.1.2.2
log
@MFC: Merge the examples from 0.83.
@
text
@d34 1
a34 3
#	last edit-date: [Wed May  5 16:24:16 1999]
#
#	-hm	updated for isdnd support
d87 1
a87 1
print "     =====================================================================\n";
@


