mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@413 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
88 lines
1.8 KiB
Perl
88 lines
1.8 KiB
Perl
|
|
##########################################################################
|
|
# $Id: dialup $
|
|
##########################################################################
|
|
|
|
use Logwatch ':all';
|
|
|
|
$Debug = ValueOrDefault($ENV{'LOGWATCH_DEBUG'}, 0);
|
|
$Detail = ValueOrDefault($ENV{'LOGWATCH_DETAIL_LEVEL'}, 0);
|
|
|
|
# Avoid "Use of uninitialized value" warning messages.
|
|
sub ValueOrDefault {
|
|
my ($value, $default) = @_;
|
|
return ($value ? $value : $default);
|
|
}
|
|
|
|
if ( $Debug >= 5 ) {
|
|
print STDERR "\n\nDEBUG: Inside DIALUP Filter \n\n";
|
|
$DebugCounter = 1;
|
|
}
|
|
|
|
while (defined($ThisLine = <STDIN>)) {
|
|
if ( $Debug >= 5 ) {
|
|
print STDERR "DEBUG($DebugCounter): $ThisLine";
|
|
$DebugCounter++;
|
|
}
|
|
chomp($ThisLine);
|
|
|
|
if ( $ThisLine =~ /^pppd (\d+).(\d+).(\d+) started by root, uid (\d+)/ )
|
|
{
|
|
if ($Debug >= 5)
|
|
{
|
|
print STDERR "DEBUG: Found PPP start\n";
|
|
}
|
|
$Starts++
|
|
}
|
|
elsif ( $ThisLine =~ /^Connection terminated./ )
|
|
{
|
|
if ($Debug >= 5)
|
|
{
|
|
print STDERR "DEBUG: Found PPP down\n";
|
|
}
|
|
$Downs++
|
|
}
|
|
elsif ( $ThisLine =~ /^PPP session is (\d+)/ )
|
|
{
|
|
if ($Debug >= 5)
|
|
{
|
|
print STDERR "DEBUG: Found PPP connect\n";
|
|
}
|
|
$Ups++
|
|
}
|
|
elsif ( $ThisLine =~ /^Connect time (\d+).(\d+) minutes./ )
|
|
{
|
|
if ($Debug >= 5)
|
|
{
|
|
print STDERR "DEBUG: Found PPP connecttime $1\n";
|
|
}
|
|
$Uptime += $1 + ($2 / 10);
|
|
}
|
|
}
|
|
|
|
###########################################################
|
|
|
|
if ( $Starts )
|
|
{
|
|
print "PPP Dial attempts: " . $Starts . " Time(s)\n";
|
|
}
|
|
|
|
if ( $Ups )
|
|
{
|
|
print "PPP Connected: " . $Ups . " Time(s)\n";
|
|
}
|
|
|
|
if ( $Downs )
|
|
{
|
|
print "PPP Disconnected: " . $Downs . " Time(s)\n";
|
|
}
|
|
|
|
if ( $Uptime )
|
|
{
|
|
print "Total connect time: " . $Uptime . " Minutes\n";
|
|
}
|
|
|
|
exit(0);
|
|
|
|
# vi: shiftwidth=3 tabstop=3 syntax=perl et
|