2 #---------------------------------------------------------------------------
4 # Copyright (c) 1996, 1998 Hellmuth Michaelis. All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #---------------------------------------------------------------------------
29 # accounting report script for the isdnd daemon accounting info
30 # -------------------------------------------------------------
32 # last edit-date: [Fri May 25 15:28:20 2001]
36 #---------------------------------------------------------------------------
38 # where the isdnd accounting file resides
39 $ACCT_FILE = "/var/log/isdnd.acct";
41 # the charge for a unit, currently 0,12 DM
44 # open accounting file
45 open(IN, $ACCT_FILE) ||
46 die "ERROR, cannot open $ACCT_FILE !\n";
51 # process file line by line
54 # remove ( and ) from length and bytecounts
57 # split line into pieces
58 ($from_d, $from_h, $dash, $to_d, $to_h, $name, $units, $secs, $byte)
64 $from = "$from_d $from_h";
69 ($inb, $outb) = split(/\//, $byte);
72 $a_secs{$name} += $secs;
74 $a_units{$name} += $units;
75 $a_charge{$name} += $units * $UNIT_PRICE;
76 $a_inbytes{$name} += $inb;
77 $a_outbytes{$name} += $outb;
78 $a_bytes{$name} = $a_bytes{$name} + $inb + $outb;
81 # close accouting file
86 print " ISDN Accounting Report ($from -> $to_d $to_h)\n";
87 print " =====================================================================\n";
89 #write the sum for each interface/name
90 foreach $name (sort(keys %a_secs))
92 $o_secs = $a_secs{$name};
94 $o_calls = $a_calls{$name};
95 $gt_calls += $o_calls;
96 $o_units = $a_units{$name};
97 $gt_units += $o_units;
98 $o_charge = $a_charge{$name};
99 $gt_charge += $o_charge;
100 $o_inbytes = $a_inbytes{$name};
101 $gt_inbytes += $o_inbytes;
102 $o_outbytes = $a_outbytes{$name};
103 $gt_outbytes += $o_outbytes;
104 $o_bytes = $a_bytes{$name};
105 $gt_bytes += $o_bytes;
110 $o_calls = $gt_calls;
111 $o_units = $gt_units;
112 $o_charge = $gt_charge;
113 $o_inbytes = $gt_inbytes;
114 $o_outbytes = $gt_outbytes;
115 $o_bytes = $gt_bytes;
118 print "======= ====== ===== ===== ======== ============ ============ ============\n";
127 Name charge units calls secs inbytes outbytes bytes
128 ------- ------ ----- ----- -------- ------------ ------------ ------------
133 @<<<<<< @##.## @#### @#### @####### @########### @########### @###########
134 $name, $o_charge, $o_units, $o_calls, $o_secs, $o_inbytes, $o_outbytes, $o_bytes