2 # fixscript will replace this line with require innshellvars.pl
4 # backlogstat - display backlog to sites
5 # based on bklog by bill davidsen <davidsen@tmr.com>
7 # breaks if backlog-directory in innfeed.conf is not "innfeed"
8 my $dir = "$inn::pathspool/innfeed";
15 use vars qw($opt_H $opt_h $opt_n $opt_t $opt_k $opt_S $opt_d);
19 &getopts('HhntkS:d:') || &Usage;
23 $dir = $opt_d if $opt_d;
25 chdir($dir) or die "Can't cd to $dir";
26 opendir(DIR, ".") or die "Can't open dir";
29 while (my $name = readdir(DIR)) {
30 # must be a file, correct name, non-zero size
33 next unless ($size = -s $name);
34 next unless $name =~ m/.*\.(in|out)put/;
36 (my $nodename = $name) =~ s/\..*//;
38 # check for only some sites wanted
39 next if ($opt_S && $nodename !~ /^${opt_S}.*/);
40 # here we do the counts if asked
42 # open the file and count lines
43 if (open(IN, "<$name")) {
44 if ($name =~ m/.*\.input/) {
45 my $offset = <IN> + 0;
49 for ($size = 0; <IN> ; ++$size) {};
53 # get the offset on .input files
54 if ($name =~ m/.*\.input/ && open(IN, "<$name")) {
55 my $offset = <IN> + 0;
60 $nodes{$nodename} = () unless defined $nodes{$nodename};
61 $nodes{$nodename}->{$io} = ( $opt_k ? $size / 1024 : $size );
65 # output the data for each node
66 if (my $numnodes = keys %nodes) {
69 print " <---------- posts ----------->\n";
71 print " <---------- bytes ----------->\n";
76 print " input(k) output(k) total(k) Feed Name\n" if $opt_H;
77 $ofmt = ( $opt_n ? "%10.2f" : "%10.1f" );
79 print " input output total Feed Name\n" if $opt_H;
82 for my $node (sort keys %nodes) {
83 my $hash = $nodes{$node};
84 my $size_in = $hash->{in} || 0;
85 my $size_out = $hash->{out} || 0;
86 my $size_tot = $size_in + $size_out;
87 printf "${ofmt} ${ofmt} ${ofmt} %s\n",
88 $size_in, $size_out, $size_tot, $node;
91 print "NO backlog!\n";
99 . "bklog - print innfeed backlog info - v$Revision\n"
102 . " bklog [ options ]\n"
105 . " -H output a header at the top of the output\n"
106 . " -k scale all numbers in k (1024) units\n"
107 . " -n count number of arts, not bytes of backlog filesize\n"
108 . " Note: this may be SLOW for large files!\n"
109 . " -Sxx Display only site names starting with xx\n"
110 . " -d dir Use \"dir\" instead of \$pathspool/innfeed\n"
112 . " -h HELP - this is all, you got it!\n"