From: lace <> Date: Fri, 8 Dec 2006 15:34:53 +0000 (+0000) Subject: $IFDEV: eth0->ppp0 X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=commitdiff_plain;h=c5bcdd211390b153e7632f0472d614c9be5a454d $IFDEV: eth0->ppp0 $STABILIZE_ON reduced a bit. Implemented user-idle FUP enforcement. --- diff --git a/bin/fup b/bin/fup index c8e9144..955dc1e 100755 --- a/bin/fup +++ b/bin/fup @@ -13,12 +13,13 @@ use Data::Dumper; my $USER="adsl_303141"; my $USERNAME="Jan Kratochvil"; my $PASSWORD=&_priv_postget("uzivatel.gtsnovera.cz.pwd"); -my $IFDEV="eth0"; +my $IFDEV="ppp0"; my $SECS=4; my $RX_THRESHOLD=200000; # 226085 my $TX_THRESHOLD=200000; # 291251 my $STABILIZE_OFF=1; -my $STABILIZE_ON=5*60; +my $STABILIZE_ON=4*60; +my $INPUT_IDLE=10*60; $RX_THRESHOLD=$RX_THRESHOLD*$SECS/8; $TX_THRESHOLD=$TX_THRESHOLD*$SECS/8; @@ -116,6 +117,48 @@ my($what,$length)=@_; change($what); } +# CPU0 CPU1 +# 1: 107040 111123 Phys-irq i8042 +# 6: 3 0 Phys-irq floppy +sub input() +{ + my $fname="/proc/interrupts"; + local *F; + open F,$fname or die "open \"$fname\": $!"; + or die "header \"$fname\"";; + my $r=0; + while () { + chomp; + my @f=split; + last if $f[0]=~/^[A-Z]{3}:$/; # NMI/LOC/ERR/MIS + $f[0]=~/^\s*\d+:$/ or die $f[0]; + next if $f[$#f] ne "i8042"; + for (1..$#f-2) { + $_=$f[$_]; + /^\d+$/ or die $_; + $r+=$_; + } + } + close F or die "open \"$fname\": $!"; + return $r; +} + +my $input=input(); +my $input_last=time()+0; +sub input_idle() +{ + my $input_now=input(); + my $diff=$input_now-$input; + die $diff if $diff<0; + my $time_now=time()+0; + if ($diff) { + $input=$input_now; + $input_last=$time_now; + } + my $time_diff=$time_now-$input_last; + return $time_diff>$INPUT_IDLE; +} + for (;;) { local *F; open F,"/proc/net/dev" or die; @@ -128,11 +171,15 @@ for (;;) { $on_now=0 if ($rx-$rx_last) > $RX_THRESHOLD; $on_now=0 if ($tx-$tx_last) > $TX_THRESHOLD; } + $on_now=1 if my $input_idle=input_idle(); $rx_last=$rx; $tx_last=$tx; push @history,$on_now; - print(($ignore_read ? "_" : $on_now)); - history(1,$STABILIZE_ON); + my $print=$on_now; + $print="." if $input_idle; + $print="*" if $ignore_read; + print($print); + history(1,($input_idle ? 0 : $STABILIZE_ON)); history(0,$STABILIZE_OFF); $ignore_read=$ignore_write; $ignore_write=0;