OK already, enough with the preliminaries. Your SNMP and HTTP daemons are installed and running, and you want to get going with MRTG and start making nice network graphs like everyone else. What do you do now?
First, we'll have MRTG monitor all the up network interfaces on our server.
Run this command to create the initial MRTG configuration file.
password
is whatever SNMP community
string you set:
# cfgmaker --output=/etc/mrtg.cfg \
--global "workdir: /var/www/mrtg" -ifref=ip \
--global 'options[_]: growright,bits' \
password@localhost
Then, start it manually:
# mrtg /etc/mrtg.conf ----------------------------------------------------------------------- ERROR: Mrtg will most likely not work properly when the environment variable LANG is set to UTF-8. Please run mrtg in an environment where this is not the case. Try the following command to start: env LANG=C /usr/bin/mrtg /etc/mrtg.cfg -----------------------------------------------------------------------
So, do that:
# env LANG=C mrtg /etc/mrtg.cfg
If your default is already LANG=C
, then you won't see that message. If
you get "Rateup WARNING" error messages, repeat the command until they
go away. This usually takes three tries.
Run this command to create the HTML index file:
# indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfg
Now, point a web browser to localhost (http://localhost/mrtg/), and you should see nice graphs tracking all of your up interfaces, like in Figure 14-2.
Click on any graph to view detailed statistics, as shown in Figure 14-3.
This shows that it is working correctly.
Let's take a look at what we did in the command:
--output=/etc/mrtg.cfg
This tells the cfgmaker
command where to create the MRTG configuration file.
--global"workdir:/var/www/mrtg"-ifref=ip
This setting goes in the global section of
mrtg.cfg, and defines the directory where
the HTML files are stored. -ifref=ip
tells MRTG to track your
network interfaces by IP address.
--global'options[_]:growright,bits'
This means your graphs will expand to the right, and network traffic will be measured in bits.
password@localhost
The community string (password) for snmpd.
Debian installs a crontab for MRTG in /etc/cron.d/mrtg that updates the graphs every five minutes, so you don't need to take any additional steps to keep it running.
Running env
LANG=Cmrtg/etc/mrtg.cfg
commonly emits error messages like
this:
Rateup WARNING: /usr/bin/rateup could not read the primary log file for localhost_ 192.168.1.10 Rateup WARNING: /usr/bin/rateup The backup log file for localhost_192.168.1.10 was invalid as well Rateup WARNING: /usr/bin/rateup Can't remove localhost_192.168.1.10.old updating log file Rateup WARNING: /usr/bin/rateup Can't rename localhost_192.168.1.10.log to localhost_ 192.168.1.10.old updating log file
It's just complaining about routine business. Ignore it, and keep running the command until it doesn't emit any more error messages; three times usually does the job.
man 1 cfgmaker
man 1
mrtg-reference
MRTG home page: http://oss.oetiker.ch/mrtg/