Document 176767

2/22/2010
HOW TO: INSTALL AND
CONFIGURE MRTG
PETE&C, February 21-24, 2010
Matthew Frederickson
AGENDA
What’s MRTG?
A Typical K-12 Network Environment/A Typical K-12
Problem
Pre-requisites
Installing MRTG
Configuring MRTG
Using MRTG
What’s Next?
1
2/22/2010
WHAT IS MRTG?
Multi-Router Traffic Grapher (MRTG)
A tool to monitor the traffic load on network links.
MRTG generates HTML pages containing PNG images
which provide a LIVE visual representation of this traffic.
Developed in 1994 by Tobi Oetiker
Released to public in 1995
Relies on SNMP
Perl, C and some scripts
http://oss.oetiker.ch/mrtg/index.en.html
TYPICAL ENVIRONMENT
Each School Has A Network
Schools Are Networked Together
Computers are connected to switches
Servers are connected to switches
Fiber
CAT5/6
Microwave
Districts Are Connected to the Internet
School based (individual)
WAN Based – one single connection
2
2/22/2010
TYPICAL PROBLEM
Who’s hogging the bandwidth?
MRTG PRE-REQUISITES
Server
OS
Used to run MRTG and provide web site
Hardware must support Windows/Ubuntu
Windows – XP, 2000, 2003, 2008
Ubuntu – 9.10 (any version will work)
Software
Perl – with modules
Apache/IIS
3
2/22/2010
MRTG PRE-REQUISITES
Tools (for Windows)
putty http://www.chiark.greenend.org.uk/~sgtatham/putty/
winscp - http://winscp.net/eng/index.php
mibbrowser http://www.ireasoning.com/mibbrowser.shtml
text editor
MY TYPICAL ENVIRONMENT
Server
Old desktop
OS
486 or better, 1 GB RAM or better
40 GB Hard Drive or better, 10/100 NIC or better
Ubuntu 9.10
Software – my standard Ubuntu Install
LAMP
Open SSH Server
Webmin 1.4
4
2/22/2010
INSTALL PROCEDURE
Install Ubuntu
Install Apache2 – already installed with LAMP
Install Perl – already installed
Install SNMPD
Install MRTG
INSTALL PROCEDURES
Install Ubuntu
See other guide
Change root password
Not recommended
sudo passwd
5
2/22/2010
INSTALL PROCEDURES
Perform Updates
apt-get update
Perform Upgrades
apt-get upgrade
INSTALL PROCEDURES
Install SNMPD
apt-get install snmpd
6
2/22/2010
INSTALL PROCEDURES (MY WAY)
Install MRTG
apt-get install mrtg
INSTALL PROCEDURES (MY WAY)
7
2/22/2010
INSTALL PROCEDURES (MY WAY)
Now what?
INSTALL DEMO (IF WIRELESS WORKS)
8
2/22/2010
CONFIGURE MRTG
Tweak installation
Create initial configuration
cfgmaker
Create initial index.html
Create config directory
Create web directory
indexmaker
Test
CREATE CONFIG DIRECTORY
Default location
/etc/mrtg.cfg
Separate for multiple configuration files
cd /etc
mkdir mrtg
mv /etc/mrtg.cfg /etc/mrtg/
9
2/22/2010
CREATE WEB DIRECTORY
Auto install does not create this
cd /var
cd www
mkdir mrtg
CREATE INITIAL CONFIGURATION
Select a device
Know the SNMP read only string
Know IP address
cfgmaker --global 'WorkDir:/var/www/mrtg' -global 'Options[_]: bits,growright' --output
/etc/mrtg/mrtg.cfg public@<yourrouterip>
10
2/22/2010
CFGMAKER
cfgmaker
--global 'WorkDir:/var/www/mrtg‘
--global 'Options[_]: bits,growright'
--output /etc/mrtg/mrtg.cfg
public@<yourrouterip>
crsd@10.19.2.134
public@192.168.10.1
EDIT INITIAL CONFIGURATION FILE
Add some other global option:
nano /etc/mrtg/mrtg.cfg
make it run as daemon
11
2/22/2010
CREATE INDEX.HTML FILE
indexmaker --output=/var/www/mrtg/index.html
/etc/mrtg/mrtg.cfg
SET ENVIRONMENT VARIABLE
Environment variables
just like Windows – allows applications to find things
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
12
2/22/2010
GETTING IT TO RUN
Create Script
Make Executable
mv /etc/mrtg/mrtg /etc/init.d/
Link it
chmod +x /etc/mrtg/mrtg
Move It
Script posted to Ning web site
nano /etc/mrtg/mrtg
ln -s /etc/init.d/mrtg /etc/rc2.d/S99mrtg
ln -s /etc/init.d/mrtg /etc/rc2.d/K99mrtg
Start It
/etc/init.d/mrtg start
TEST
http://192.168.22.134/mrtg
13
2/22/2010
MRTG CONFIGURATION FILE (GLOBAL)
WorkDir: /var/www/mrtg
EnableSnmpV3: yes
Specifies where the logfiles and the webpages should
be created
Enable SNMP V3
Refresh: 600
Sets timeframe for web page refresh (default 300
seconds – 5 minutes)
MRTG CONFIGURATION FILE (GLOBAL)
Interval: 10
Sets the interval for how often MRTG is called
Default is five minutes
MaxAge: 7200
Tells MRTG how long to update log files
Above example – log files older than 2 hours are
ignored
14
2/22/2010
MRTG CONFIGURATION FILE (GLOBAL)
SingleRequest: Yes
SnmpOptions
Forces SNMP single requests
Used to tweak SNMP settings
LoadMIBs: /usr/share/snmp/mibs/HOSTRESOURCES-MIB.txt
Load MIBS for devices
MRTG CONFIGURATION FILE (GLOBAL)
RunAsDaemon: Yes
forces MRTG to run once (one process)
used with Interval: command
Interval: 5
Sets polling process in minutes
Usually used with RunAsDaemon command
15
2/22/2010
MRTG CONFIGURATION FILE (GLOBAL)
Global Information
MRTG CONFIGURATION FILE (DEVICE)
Target
Target[router]: 2:crsd@10.19.2.134
Reversing – add (-) negative sign
OIDs – specific SNMP value
Target[router]: -2:crsd@10.19.2.134
Target[router]: 1.3.6.1.2.1.2.2.1.14.1&1.3.6.1.2.1.2.2.1.20.1:crsd@10.19.2.134
MIB Variables – specific SNMP value
Target[router]: ifInErros.1&ifOutErrors.1:crsd@10.19.2.134
16
2/22/2010
MRTG CONFIGURATION FILE (DEVICE)
SetEnv[router]: <value>
MaxBytes[router]: 1250000
The maximum value monitored variables can have
Title[router]: Traffic Analysis for
Passes text (quotes required) to environment
variables for use inside external scripts
Sets HTML title for graph
Comments
# sign
MRTG CONFIGURATION FILE (DEVICE)
PageTop[router]:
IPv4Only[router]: Yes
Sets text to add to top of HTML page
As many lines as you want – first column must be a
space
Forces MRTG to use IPv4 when talking to router
Much, much more here:
http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html
17
2/22/2010
MRTG.CFG
Device Information
18
2/22/2010
SNMP
Which Is It?
Security Not My Problem
Simple Network Management Protocol
Sick Nerd Munching Prozac
SNMP
Simple Network Management Protocol
UDP Based
Exposes information about devices for management
purposes
Currently 3 versions
V2 added more information
V3 addressed lack of security in V1 and V2
Operates at Layer 7 of the OSI Model (Application)
Ports 161 (agent) and 162 (manager)
Slave (where agent runs)
Master (collects the data or sends commands)
MRTG is the master
19
2/22/2010
MIBS
Management Information Base
SNMP reads these files to know what information to
monitor/send
Hierarchy of namespaces (objects)
Structured “database” of objects
OID – Object Identifiers
Supports single instance objects (router uptime)
Supports tables of objects (interfaces)
Follows standard numbering system
ASCII Text Files
Follows RFC’s
SNMP AND MIBS
If device supports SNMP
Supports standard MIBS
snmpd loads these automatically
May have special SNMP values
turn things on
turn things off
support special information retrieval
load ONLY if you need info to graph
If device does NOT support SNMP
can cheat – use PING command in device config
20
2/22/2010
BACK TO OUR REGULARLY SCHEDULED
PROGRAM
ADD A SECOND DEVICE
Backup config file now
Use cfgmaker
add devices in order and recreate file each time
Or add it by hand
cp /etc/mrtg/mrtg.cfg /etc/mrtg/mrtg.cfg.20100201
use editor, cut and paste and edit
Or create separate files
use the Include: directive
21
2/22/2010
ADD ANOTHER DEVICE
Use cfgmaker – add info to existing file
Use cfgmaker – recreate it
cfgmaker snmp@device >> /etc/mrtg/mrtg.cfg
delete duplicate global info
cfgmaker snmp@device1 snmp@device2 >
/etc/mrtg/mrtg.cfg
Use cfgmaker – create separate file
cfgmaker snmp@device > /etc/mrtg/host1.cfg
use Include directive
WHAT ELSE CAN YOU MONITOR
Computers and Servers
Temperature Monitors
Security Cameras/Systems
Anything that supports SNMP
22
2/22/2010
ONE MORE EXAMPLE – WINDOWS PC
Monitor Network Traffic
Could Possibly Monitor
CPU Utilization
Memory
Hard Drive Space
My Experience – use Nagios for that!
PC SNMP SETTINGS
23
2/22/2010
PC SNMP SETTINGS
OTHER USES/RESOURCES
Stock quotes
Temperature and Humidity
http://howto.aphroland.org//HOWTO/MRTG/Tempera
tureAndHumidity
Special Devices Help
http://howto.aphroland.org//HOWTO/MRTG/Tracking
StocksWithMRTG
http://oss.oetiker.ch/mrtg/3party.en.html
Dummies Guides – Windows Based
http://www.netmon.org/dummies.htm
http://www.netmon.org/indexmaker.htm
24
2/22/2010
WHAT’S NEXT
Who, What, Where, When and Why
Online Resources
You Do What You Measure
MRTG Website
Ubuntu Forums
Wiki’s
Books
One book (Using MRTG with RRDtool and Routers2 )
Several “references”
QUESTIONS?
Session Number:
Session Title:
HOW TO: Install and Configure MRTG
Act 48 Code:
AL10
AL102020
Contact Info
Matt Frederickson
mfrederickson@crsd.org
215-944-1092
25