Linux-Bulgaria.ORG
навигация

 

начало

пощенски списък

архив на групата

семинари ...

документи

как да ...

 

 

Предишно писмо Следващо писмо Предишно по тема Следващо по тема По Дата По тема (thread)

Re: lug-bg: MRTG


  • Subject: Re: lug-bg: MRTG
  • From: raptor@xxxxxxxxxx (raptor)
  • Date: Fri, 14 Feb 2003 12:53:30 -0500



|Ako zad edin mrejov interfeis imam poveche ot edna mreji, moga li da nakaram MRTG-to da chertae grafiki za vsiaka mreja pootdelno, a ne za obshtia trafik preminavasht prez interfeisa ?

]- eto nesto tuka deto bqh pochnal da pisha.... (mai ste trqbwa da si go dowyrsha, stoto ste mi trqbwa:"))..
za ideq kak da extraktwash infoto ot iptables... posle go chrez RRDs.pm go pishesh w rrd bazi, i posle chertaesh grafiki...

=====blah.pl==============
#!/usr/bin/perl
package SA::IPTExtract;

ub new {
    my $this = shift;
    my $class = ref($this) || $this;
    my $self = {};
    bless $self, $class;
    $self->capture;
    return $self;    
}

ub display {
 my $self = shift;
 foreach my $c (keys %{$$self{stat}}) {
    print "Chain : $c\n";
    foreach my $k (keys %{$$self{stat}{$c}}) {
        print "$k ==> $$self{stat}{$c}{$k}\n"
    }
 }
}

sub capture {
 my $self = shift;
 my $output = qx{iptables -L -v -n};
 my @chains = $output =~ /(?:^|(Chain.+?))(?:\n\n|$)/gs;

 for my $c (@chains) {
    #get chain name
    my ($name) = $c =~ /Chain (\S+)?/;
    #remove header info
    $c =~ s/Chain.+destination//s;
    
    #walk all rules 
    for my $line (split /\n/, $c) {
        my ($bytes,$src,$dst) = (split /\s+/,$line)[1,7,8];
        $$self{stat}{$name}{"$src-$dst"} = $bytes;
    }

#    print "$name\n";
#    print "$c\n-----\n";
 };
} 

1;

#============
package main;
use Data::Dumper;
my $ipt = new SA::IPTExtract();
$ipt->display;
#print Dumper $ipt;
============================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora
To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
============================================================================


  • Относно:
    • lug-bg: MRTG
      • Изпратено от: lugbg@xxxxxx (Konstantin Ivanov)

 

наши приятели

 

линукс за българи
http://linux-bg.org

FSA-BG
http://fsa-bg.org

OpenFest
http://openfest.org

FreeBSD BG
http://bg-freebsd.org

KDE-BG
http://kde.fsa-bg.org/

Gnome-BG
http://gnome.cult.bg/

проект OpenFMI
http://openfmi.net

NetField Forum
http://netField.ludost.net/forum/

 

 

Linux-Bulgaria.ORG

Mailing list messages are © Copyright their authors.