From owner-freebsd-questions Sat Sep 21 3:49:50 2002 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 E7F2C37B401 for ; Sat, 21 Sep 2002 03:49:48 -0700 (PDT) Received: from lurza.secnetix.de (lurza.secnetix.de [212.66.1.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id 19E2043E6A for ; Sat, 21 Sep 2002 03:49:48 -0700 (PDT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [IPv6:::1]) by lurza.secnetix.de (8.12.5/8.12.5) with ESMTP id g8LAnkmC080629 for ; Sat, 21 Sep 2002 12:49:47 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.12.5/8.12.5/Submit) id g8LAnkv6080628; Sat, 21 Sep 2002 12:49:46 +0200 (CEST) Date: Sat, 21 Sep 2002 12:49:46 +0200 (CEST) Message-Id: <200209211049.g8LAnkv6080628@lurza.secnetix.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG Reply-To: freebsd-questions@FreeBSD.ORG Subject: Re: Measure bandwidth and show it at graph in mrtg In-Reply-To: <1032594615.3d8c24b77e6df@tarakan> X-Newsgroups: list.freebsd-questions User-Agent: tin/1.5.4-20000523 ("1959") (UNIX) (FreeBSD/4.6-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG chojin@chojin.info wrote: > I would like to measure bandwidth used by a game server on an UDP port. I would > like to have a graph in mrtg that shows upload and download rate too. There are quite a lot of ways to do that. One of them is to setup SNMP, but for such a simple task it is not necessary. I would do it like this: Add two pass-rules to the IPFW configuration which serve as counters for that specific UDP port (one rule for outgoing, and one rule for incoming). Then you can use a trivial small shell script that calls "/sbin/ipfw show" to find the number of bytes (in the 3rd column) for those two rules. Then configure mrtg to call that script every 5 minutes. For example, if your address is 1.2.3.4 and the port number is 5678, given these two rules: add pass udp from any to 1.2.3.4 5678 # incoming add pass udp from 1.2.3.4 5678 to any # outgoing The following shellscript should do for mrtg: #!/bin/sh - /sbin/ipfw show | awk '/1\.2\.3\.4 5678/ {print $3}' That's all. Configure mrtg to call that script (the syntax in mrtg.conf is to use backticks, see the mrtg docs), and enjoy your bandwidth graphics. :) Regards Oliver -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message