Using MRTG to monitor ZXTM

MRTG is a graphing tool that can be used to monitor network services and draw graphs showing traffic trends. It can easily be integrated with ZXTM to allow monitoring of traffic to a site.

Step 1 - Enabling SNMP

SNMP support needs to be enabled on each ZXTM machine that you wish to monitor. To turn on support, go to the Administration Server for each machine, and enable it on the System -> SNMP page. You can select port and community string, but for this example we will assume you use '161' and 'private' as the port and community string respectively.

Once SNMP is enabled, you should be able to request snmp values from a ZXTM using 'snmpget':

$ snmpget -M /usr/share/snmp/mibs:$ZEUSHOME/zxtm/etc -mALL -v1 -c private zxtm1 totalBytesInLo.0
ZXTM-MIB::totalBytesInLo.0 = Counter32: 140113170
$

If this works, then SNMP is working correctly.

Step 2 - Installing MRTG and RRDtool

For this demonstration we will use MRTG and RRDtool. Using RRDtool has the advantage that the images are generated on the fly when they are viewed rather than every 5 minutes when the data is collected. MRTG and RRDtool do not need to be located on the ZXTM machine, they can be any machine that has the ability to communicate with ZXTM via SNMP.

The method of installation of MRTG and RRDtool will depend on your operating system, e.g. on Debian Linux you can use the apt tool to install them.

Step 3 - Configure MRTG

Before you configure MRTG you need to decide where the docroot of the website (that will display the graphs) will be, and where to store the raw data. For this demonstration we will use /data/mrtg/data and /data/mrtg/docroot respectively.

Create a MRTG configuration file called /data/mrtg/docroot/14all.cfg :

HtmlDir: /data/mrtg/docroot
ImageDir: /data/mrtg/docroot
IconDir: /data/mrtg/docroot
LogDir: /data/mrtg/data
LoadMIBs: /data/mrtg/mibs/ZXTM-MIB.txt
WriteExpires: No
Interval: 5
NoMib2: Yes
LogFormat: rrdtool
Options[_]: growright
Title[zxtm1_traffic]: ZXTM - Traffic
PageTop[zxtm1_traffic]: <H1>Total traffic through ZXTM</H1>
Target[zxtm1_traffic]: totalBytesInLo.0&totalBytesOutLo.0:private@zxtm1
MaxBytes[zxtm1_traffic]: 1250000
Title[zxtm1_conns]: ZXTM - Current Connections
PageTop[zxtm1_conns]: <H1>Number of current connections to ZXTM</H1>
Target[zxtm1_conns]: totalCurrentConn.0&totalCurrentConn.0:private@zxtm1
MaxBytes[zxtm1_conns]: 10000
Options[zxtm1_conns]: gauge, noo, nopercent
YLegend[zxtm1_conns]: Current conns
ShortLegend[zxtm1_conns]: conns
Legend1[zxtm1_conns]: Current Connections
LegendI[zxtm1_conns]: Conns 

You will also need the ZXTM MIB, which you can download through the ZXTM Administration Server on the Security -> SNMP page. The MIB should be saved into /data/mrtg/mibs .

To check that mrtg is working correctly, run:

$ mrtg /data/mrtg/docroot/14all.cfg

If nothing is printed on stdout, then mrtg is configured correctly, and you should now have some data stored in /data/mrtg/data

Now add a cron job to call mrtg every 5 minutes:

0-55/5 * * * * root /usr/bin/mrtg /data/mrtg/data/14all.cfg

Step 4 - And Finally

One last step is to create a website that can show the MRTG graphs. You configure the docroot to /data/mrtg/docroot and to run cgi scripts from anywhere.

Once the site is created, download the 14all.cgi script from http://my14all.sourceforge.net/ and save it in the docroot.

You should now be able view the mrtg graphs by going to http://mrtgwebsite/14all.cgi:

Crispin Flowerday [Zeus Dev Team] 01 July 2005 Bookmark with del.icio.us Post this article to Digg Post this article to reddit Post this article to Facebook Tweet this article 2 comments  

Comments:

This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.

Comment from: jean barbezat [Visitor]
Just a quickie:

I find it a bit frustrating that the ZXTM mib is using hyphens circled values for some of its OIDs.

ie: ZXTM-MIB::virtualserverMaxConn."blah" = Gauge32: 15177
Permalink 27 September 2006 @ 11:36
Comment from: Crispin Flowerday [Zeus Dev Team]
The "blah" above is a 'string index' into the table of virtualservers. This is a standard SNMP practise, and the use of double quotes is enforced by the SNMP client application, not ZXTM.

MRTG doesn't seem to able to cope with these successfully (I get errors about "failing to find string terminator"). However you can use either a numeric suffix or a numeric oid.

To find the numeric OID use 'snmpget -On':

$ snmpget -On -M /usr/share/snmp/mibs:$ZEUSHOME/zxtm/etc/mibs -mALL -v1 -c private zxtm1 ZXTM-MIB::virtualserverMaxConn.\"blah\"
.1.3.6.1.4.1.7146.1.2.2.2.1.10.4.98.108.97.104 = Gauge32: 0

Or you can get the OID with a numeric suffix using 'snmpget -Ob':

$ snmpget -Ob -M /usr/share/snmp/mibs:$ZEUSHOME/zxtm/etc/mibs -mALL -v1 -c private zxtm1 ZXTM-MIB::virtualserverMaxConn.\"blah\"
ZXTM-MIB::virtualserverMaxConn.4.98.108.97.104 = Gauge32: 0

Hope that helps!



Permalink 27 September 2006 @ 14:54
Leave a comment ...
Your email address will not be displayed.
Your URL will be displayed.
This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Options:
 
(Line breaks become <br />)
(Set cookies for name, email & url)

Recently...

Other Resources