From 6460453fba4004e2ef23945faf8ed0b64e8e6278 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 27 Jun 2010 18:04:42 +0100 Subject: [PATCH] debug level 1 shows creation and unknown stuff only --- newstailer | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/newstailer b/newstailer index 6fcbc89..5a4f7e9 100755 --- a/newstailer +++ b/newstailer @@ -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); -- 2.30.2