Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Sep 2002 12:49:46 +0200 (CEST)
From:      Oliver Fromme <olli@secnetix.de>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Measure bandwidth and show it at graph in mrtg
Message-ID:  <200209211049.g8LAnkv6080628@lurza.secnetix.de>
In-Reply-To: <1032594615.3d8c24b77e6df@tarakan>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209211049.g8LAnkv6080628>