9 # Compute SLIP/PPP log times
10 # Arguments -a Process entire file with totals
11 # -t Process only totals
12 # -f File to be processed if not current
13 # -d processing start date (default is entire file)
14 # -l to return all totals for dayuse
15 # -w name of tmp work file for dayuse
23 print "Missing Arguments\n";
24 print "-a - entire file\n";
25 print "-t - totals only\n";
26 print "-f - file name to be processed\n";
27 print "-d - processing start date (yymmdd)\n";
28 print "-l - return totals for dayuse\n";
29 print "-w - tmp work file for dayuse\n";
31 } # end if test for missing arguments
33 $infile = "/usr/annex/acp_logfile";
34 $tmpfile = "/tmp/ppp";
37 for ($i = 0; $i <= $n; $i++) {
38 if ($ARGV[$i] eq "-a") {
41 elsif ($ARGV[$i] eq "-t") {
44 elsif ($ARGV[$i] eq "-f") {
48 elsif ($ARGV[$i] eq "-d") {
50 $start_yymmdd = $ARGV[$i];
52 elsif ($ARGV[$i] eq "-l") {
56 elsif ($ARGV[$i] eq "-w") {
61 ($arg_user,$arg_yymmdd) = split (/:/, $ARGV[$i]);
62 $ip_user_date {$arg_user} = $ARGV[$i];
65 } # end for 1 = 1 to n
68 || die "Can't open acp_logfile";
70 NEXTUSER: while (<IN>) {
72 ($add,$ether,$port,$date,$time,$type,$action,$user) = split(/:/);
76 if ($ip_user_date{$user}) {
77 ($ip_user, $start_yymmdd) =
78 split (/:/, $ip_user_date{$user});
82 if ($date < $start_yymmdd) {
87 if (!$ip_user_date{$user}) {
90 } # end by user or all
93 ($ip_user_date{$user})) {
94 if (($type eq 'ppp') || ($type eq 'slip')) {
96 if ($action eq 'login') {
97 $login{$user} = "$time:$date";
100 elsif ($action eq 'logout') {
101 if (!$login{$user}) {
102 $login{$user} = "010101:$date";
103 } #end pad user if carry over
104 ($stime,$sdate) = split(':',$login{$user});
105 $start = &annex2sec($stime);
106 $end = &annex2sec($time);
108 #If we went through midnight, add a day;
109 if ($end < $start) {$end += 86400;}
110 $timeon = $end - $start;
112 $elapsed{$user} += $timeon;
115 print (&fmt_user($user),
116 ' ', &fmt_date($sdate), ' In: ',
117 &fmt_time($stime),' Out: ',
119 ' Elapsed: ', &fmt_sec($timeon), "\n");
122 } # type = ppp of slip
128 open (TMPPPP, ">$tmpfile")
129 || die "Can't open ppp tmp file";
130 foreach $user ( sort((keys(%elapsed))) ) {
131 $log_time = &fmt_sec($elapsed{$user});
135 print (TMPPPP "$tmp\n");
140 print "\n\nTotal Time On For Period:\n";
141 print "-------------------------\n";
143 foreach $user ( sort((keys(%elapsed))) ) {
144 print (&fmt_user($user), " ",&fmt_sec($elapsed{$user}), "\n");
149 #-------------------------------------------------------
150 #--------------- Subroutines Start Here ----------------
151 #-------------------------------------------------------
155 return( &time2sec( &break_annex($time) ) );
161 return( substr($date,2,2).'/'.substr($date,4,2).'/'.substr($date,0,2) );
166 local($s,$m,$h) = &break_annex($time);
175 $h=substr($time,0,2);
176 $m=substr($time,2,2);
177 $s=substr($time,4,2);
183 local(@t) = &sec2time(@_);
187 if ($a < 10) {$a = "0$a";}
190 return ("@t[2]:@t[1]:@t[0]");
195 return( $user.substr($space,0,8 - length($user) ).' ' );