aredn/files/usr/local/bin/snrlog

25 lines
1.6 KiB
Plaintext
Raw Normal View History

2015-07-26 22:09:34 -06:00
#!/usr/bin/perl
BEGIN {push @INC, '/www/cgi-bin'};
use perlfunc;
my $filename = '/tmp/snrlog/strongest';
my $MAXLINES=2880; # 2days worth
2015-07-26 22:09:34 -06:00
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
2015-07-28 15:16:01 -06:00
$d = sprintf ("%02d/%02d %02d:%02d:%02d",$mon, $mday,$hour, $min, $sec);
2015-07-26 22:09:34 -06:00
($s, $n) = get_wifi_signal(get_interface("wifi"));
$s = 0 if $s eq "N/A";
$n = 0 if $n eq "N/A";
2015-07-26 22:09:34 -06:00
open(my $fh, '>>', $filename) or die "Could not open file '$filename' $!";
print $fh "$d,$s,$n\n";
close $fh;
$lcount=`wc -l < $filename`;
chomp($lcount);
if($lcount>$MAXLINES)
{
$rc=`tail -n$MAXLINES $filename > $filename.tmp`;
$rc=`mv $filename.tmp $filename`;
}