chiark / gitweb /
debug level 1 shows creation and unknown stuff only
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 27 Jun 2010 17:04:42 +0000 (18:04 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 27 Jun 2010 17:05:27 +0000 (18:05 +0100)
newstailer

index 6fcbc89b9b9fa274f983d370c956718b2b712180..5a4f7e9ab3bbbf7c7fc0864c015e65086c8e7843 100755 (executable)
@@ -13,6 +13,7 @@ our %dohosts;
 our $outpfx= './';
 our $sep= '_';
 our $debug= 0;
+our $interval= 30;
 
 open DEBUG, ">/dev/null" or die $!;
 
@@ -23,6 +24,7 @@ while (@ARGV && $ARGV[0] =~ m/^\-./) {
        if (s/^-h//) { $dohosts{$_}=1; last; }
        elsif (s/^-O//) { $outpfx=$_; last; }
        elsif (s/^-s//) { $sep=$_; last; }
+       elsif (s/^-i([1-9]\d{0,5})$//) { $interval= $1; }
        elsif (s/^-D/-/) { $debug++; }
        else { die "bad option $_"; }
     }
@@ -138,7 +140,7 @@ sub actually_update_rrds () {
 
        my @args= ($rrd->{Path}, '--template',$rrd->{Template},
                   join(':',$rrd_blockedupdate_time,@$vals));
-       print DEBUG "update @args\n";
+       print DEBUG "update @args\n" if $debug>=2;
        RRDs::update(@args);
        my $err= RRDs::error;
        die "$err [@args]" if defined $err;
@@ -150,11 +152,11 @@ sub actually_update_rrds () {
 our %in_conns;
 
 sub inbound_connected () {
-    print DEBUG "inbound connected $host $peer $conn\n";
+    print DEBUG "inbound connected $host $peer $conn\n" if $debug>=2;
     $in_conns{$host,$peer,$conn} = [ (0) x @fields_in ];
 }
 sub inbound_closed () {
-    print DEBUG "inbound closed $host $peer $conn\n";
+    print DEBUG "inbound closed $host $peer $conn\n" if $debug>=2;
     delete $in_conns{$host,$peer,$conn};
 }
 sub inbound_stats () {
@@ -166,7 +168,7 @@ sub inbound_stats () {
        print DEBUG "inbound UNKNOWN $host $peer $conn $stats\n";
        $in_conns{$host,$peer,$conn}= $hpc= [ (undef) x @fields_in ];
     } else {
-       print DEBUG "inbound stats $host $peer $conn $stats\n";
+       print DEBUG "inbound stats $host $peer $conn $stats\n" if $debug>=2;
     }
     while (s/^([a-z_]+) (\d+)\s//) { $s{$1}= $2; }
     my @v;
@@ -238,7 +240,7 @@ foreach my $staticpath (@ARGV) {
 exit 0 if $totail eq '';
 
 my $tailer= new File::Tail name=>$totail,
-    interval=>60, adjustafter=>2, ignore_nonexistant=>1, tail=>-1
+    interval=>$interval, adjustafter=>2, ignore_nonexistant=>1, tail=>-1
     or die "$totail $!";
 
 run($tailer);