Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Oct 2004 17:46:12 +0800
From:      "Spades" <spades@galaxynet.org>
To:        <gerard@gedads.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: MRTG monitoring specific ports
Message-ID:  <023f01c4bd9c$20793a20$0300a8c0@astral>
References:  <0b8101c4bc50$e5653fc0$0300a8c0@astral> <6ce0fd1b041027235048f85f8a@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks, i think its well done, but i couldn't get it to work.
I have refreshed the mrtg page but doesn't seem to have the lines.

See http://mojito.purplecards.com/mrtg

http://mojito.purplecards.com/ipfwmrtg.php (you told me to create)

# cat mrtg.cfg | grep gerard@gedads.com

# ipfw -at list
00002      0        0                          count tcp from me 25 to any
00003      0        0                          count tcp from any to me 25
00004      0        0                          count tcp from me 110 to any
00005      0        0                          count tcp from any to me 110
00006      0        0                          count tcp from me 80 to any
00007      0        0                          count tcp from any to me 80
00008      0        0                          count udp from me 53 to any
00009      0        0                          count udp from any to me 53
65535 138410 17490211 Fri Oct 29 17:44:31 2004 allow ip from any to any

I have php.4.39 installed, please advise, thanks.

Spades

----- Original Message ----- 
From: "Gerard D." <gedads@gmail.com>
To: "Spades" <spades@galaxynet.org>
Sent: Thursday, October 28, 2004 2:50 PM
Subject: Re: MRTG monitoring specific ports


> I'm sure theres something better out there.. but heres a little script
> I threw togethor a long long long time ago for use on my webservers..
> I know its nasty and could easily be done in a better language but i'm
> lazy as hell.. anyway it assumes you have ipfw support enabled and the
> command line version of php installed.
>
> /******************* start ipfwmrtg.php *********/
> #!/usr/local/bin/php
> <?php
> $ipfw_out = shell_exec("ipfw show ".$_SERVER['argv'][1]."
> ".$_SERVER['argv'][2]);
> $regexp = "/([\d]+)[\s]+([\d]+)[\s]+([\d]+)[\s]+.+/";
> $ipfw = split("\n", $ipfw_out);
>
> foreach($ipfw as $pp) {
>        preg_match($regexp, $pp, $out);
>        $tmp[] = $out[3];
> }
> //print_r($tmp);
> //echo "fdc-bw 1 $tmp[1] $tmp[0] 0 0";
> echo $tmp[1]."\n";
> echo $tmp[0]."\n";
> echo "1"."\n";
> echo "name"."\n";
> /************** end ipfwmrtg.php ***************/
>
> /////////////////// code that goes in your mrtg.cfg
> Title[smtp]: smtp total stats
> Target[smtp]: `/usr/local/etc/mrtg/ipfwmrtg.php 2 3`
> MaxBytes[smtp]: 15000000
> PageTop[smtp]: <h1>smtp</h1>
>
> Title[pop3]: pop3 total stats
> Target[pop3]: `/usr/local/etc/mrtg/ipfwmrtg.php 4 5`
> MaxBytes[pop3]: 15000000
> PageTop[pop3]: <h1>pop3</h1>
>
> Title[http]: http total stats
> Target[http]: `/usr/local/etc/mrtg/ipfwmrtg.php 6 7`
> MaxBytes[http]: 15000000
> PageTop[http]: <h1>http</h1>
>
> Title[dns]: dns total stats
> Target[dns]: `/usr/local/etc/mrtg/ipfwmrtg.php 8 9`
> MaxBytes[dns]: 15000000
> PageTop[dns]: <h1>dns</h1>
> ////////////////// end code for mrtg.cfg
>
> so anyway now that you have the code you'll need to add a couple ipfw 
> rules..
>
> something like
>
> ipfw add 2 count tcp from me 25 to any
> ipfw add 3 count tcp from any to me 25
>
> ipfw add 4 count tcp from me 110 to any
> ipfw add 5 count tcp from any to me 110
>
> ipfw add 6 count tcp from me 80 to any
> ipfw add 7 count tcp from any to me 80
>
> ipfw add 8 count udp from me 53 to any
> ipfw add 9 count udp from any to me 53
>
> would count all traffic going out of your server on port 25 and the
> second line would count all inbound traffic to your server on port
> 25..
> You can add as many rules as you'd like just change the numbers for
> each new rule.. You will also need to update the #'s for the new rules
> in the Target[]: line that goes into mrtg.conf
> Okay Well i'm not good at explaining things.. I hope this can help
> you. good luck
> -Gerard
>
>
>
> On Thu, 28 Oct 2004 02:15:09 +0800, Spades <spades@galaxynet.org> wrote:
>> Hi,
>>
>> Is there anyway for us to trace the server bandwidth based on
>> specific ports on a MRTG graph?
>>
>> Such as smtp bandwidth? port 25
>> pop3 bandwidth? port 110
>> web bandwidth? port 80
>> dns bandwidth? port 53
>>
>> Is there any program or can MRTG do, please advise, thanks.
>>
>> --
>> Spades
>>
>> _______________________________________________
>> freebsd-questions@freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to 
>> "freebsd-questions-unsubscribe@freebsd.org"
>> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?023f01c4bd9c$20793a20$0300a8c0>