File: logstat.pl

package info (click to toggle)
fidogate 4.2.8-3
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 5,804 kB
  • ctags: 2,843
  • sloc: ansic: 22,020; perl: 2,885; sh: 1,550; yacc: 671; makefile: 582
file content (94 lines) | stat: -rw-r--r-- 1,713 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/local/bin/perl
#
# $Id: logstat.pl,v 4.0 1996/04/17 18:17:38 mj Exp $
#
# Statistics for ftntoss/ftnroute/ftnpack log files
#

$NEWSGROUPS = "fido.de";
$SUBJECT    = "EchoMail statistics report";


$INEWS      = "/usr/bin/inews -h -S";
$SENDMAIL   = "/usr/lib/sendmail";


require "getopts.pl";
&Getopts('g:s:t:nm:');

if($opt_g) {
    $NEWSGROUPS = $opt_g;
}
if($opt_s) {
    $SUBJECT    = $opt_s;
}
if($opt_t) {
    $SUBJECT    = "$SUBJECT $opt_t";
}
if($opt_n) {
    open(OUT, "|$INEWS") || die "logreport: can't open pipe to inews\n";
    select(OUT);
    $out_flag = 1;
}
if($opt_m) {
    open(OUT, "|$SENDMAIL $opt_m")
	|| die "logreport: can't open pipe to sendmail\n";
    select(OUT);
    $out_flag = 1;
}



while(<>) {
    
    if( /^(... .. ..:..:..) ftntoss packet.*\((\d+)b\) from ([0-9:\/.]+) / ) {
	$first = $1 if(! $first);
	$size = $2;
	$node = $3;

	$in_total += $size;
	$in_node{$node} += $size;
    }

    if( /(... .. ..:..:..) ftnpack .*packet \((\d+)b\) for ([0-9:\/.]+) / ) {
	$last = $1;
	$size = $2;
	$node = $3;

	$out_total += $size;
	$out_node{$node} += $size;
    }

}


sub in_bynumber  { $in_node{$b}  <=> $in_node{$a};  }
sub out_bynumber { $out_node{$b} <=> $out_node{$a}; }



print "Newsgroups: $NEWSGROUPS\n" if($opt_n);
print "Subject: $SUBJECT\n";

print "\n";


print "Period $first -- $last\n\n";


printf "In:  total           %7ldK\n", $in_total/1024;
for $n (sort in_bynumber keys(%in_node)) {
    printf "     %-16s%7ldK\n", $n, $in_node{$n}/1024;
}

printf "\n";

printf "Out: total           %7ldK\n", $out_total/1024;
for $n (sort out_bynumber keys(%out_node)) {
    printf "     %-16s%7ldK\n", $n, $out_node{$n}/1024;
}


if($out_flag) {
    close(OUT);
}