From owner-freebsd-questions@FreeBSD.ORG Fri Oct 29 09:46:03 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 37CEE16A4CE for ; Fri, 29 Oct 2004 09:46:03 +0000 (GMT) Received: from smtp21.singnet.com.sg (smtp21.singnet.com.sg [165.21.101.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id DE7E043D31 for ; Fri, 29 Oct 2004 09:46:01 +0000 (GMT) (envelope-from spades@galaxynet.org) Received: from astral (bb219-74-176-135.singnet.com.sg [219.74.176.135]) by smtp21.singnet.com.sg (8.13.1/8.13.1) with SMTP id i9T9jxwI013437; Fri, 29 Oct 2004 17:45:59 +0800 Message-ID: <023f01c4bd9c$20793a20$0300a8c0@astral> From: "Spades" To: References: <0b8101c4bc50$e5653fc0$0300a8c0@astral> <6ce0fd1b041027235048f85f8a@mail.gmail.com> Date: Fri, 29 Oct 2004 17:46:12 +0800 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 cc: freebsd-questions@freebsd.org Subject: Re: MRTG monitoring specific ports X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Spades List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Oct 2004 09:46:03 -0000 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." To: "Spades" 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 > $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]:

smtp

> > Title[pop3]: pop3 total stats > Target[pop3]: `/usr/local/etc/mrtg/ipfwmrtg.php 4 5` > MaxBytes[pop3]: 15000000 > PageTop[pop3]:

pop3

> > Title[http]: http total stats > Target[http]: `/usr/local/etc/mrtg/ipfwmrtg.php 6 7` > MaxBytes[http]: 15000000 > PageTop[http]:

http

> > Title[dns]: dns total stats > Target[dns]: `/usr/local/etc/mrtg/ipfwmrtg.php 8 9` > MaxBytes[dns]: 15000000 > PageTop[dns]:

dns

> ////////////////// 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 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" >>