From owner-freebsd-questions@FreeBSD.ORG Fri Oct 29 09:50:18 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 D407B16A4CE for ; Fri, 29 Oct 2004 09:50:18 +0000 (GMT) Received: from smtp29.singnet.com.sg (smtp29.singnet.com.sg [165.21.101.249]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1C90D43D55 for ; Fri, 29 Oct 2004 09:50:18 +0000 (GMT) (envelope-from spades@galaxynet.org) Received: from astral (bb219-74-176-135.singnet.com.sg [219.74.176.135]) by smtp29.singnet.com.sg (8.13.1/8.13.1) with SMTP id i9T9oEkI030019; Fri, 29 Oct 2004 17:50:15 +0800 Message-ID: <024801c4bd9c$b91a1a60$0300a8c0@astral> From: "Spades" To: Date: Fri, 29 Oct 2004 17:50:28 +0800 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response 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:50:19 -0000 I have pasted the Error: # /usr/local/mrtg-2/bin/mrtg /home/www/mojito.purplecards.com/mrtg/cfg/mrtg.cfg 3: not found WARNING: Problem with External get '/usr/local/etc/mrtg/ipfwmrtg.php 2 3': Expected a Number for 'in' but got '' 5: not found WARNING: Problem with External get '/usr/local/etc/mrtg/ipfwmrtg.php 4 5': Expected a Number for 'in' but got '' 7: not found WARNING: Problem with External get '/usr/local/etc/mrtg/ipfwmrtg.php 6 7': Expected a Number for 'in' but got '' 9: not found WARNING: Problem with External get '/usr/local/etc/mrtg/ipfwmrtg.php 8 9': Expected a Number for 'in' but got '' ERROR: Target[smtp][_IN_] ' $target->[1]{$mode} ' did not eval into defined data ERROR: Target[pop3][_IN_] ' $target->[2]{$mode} ' did not eval into defined data ERROR: Target[http][_IN_] ' $target->[3]{$mode} ' did not eval into defined data ERROR: Target[dns][_IN_] ' $target->[4]{$mode} ' did not eval into defined data ----- Original Message ----- From: "Spades" To: Cc: Sent: Friday, October 29, 2004 5:46 PM Subject: Re: MRTG monitoring specific ports > 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" >>> >