MRTG  E-Smith/MITEL  How-To
  Ver. 0.7 (Dec-04-2001)
  Suitable for: E-Smith 4.1.2 / Mitel SME5
Author: Ruwan Jayasinghe,
Roosevelt High School, LAUSD, Los Angeles, CA
Contributors: Darrel May, Placido Sanchez, and Dan York.

Problem:  You want to monitor traffic patterns of individual ports on Cisco Switches/Routers on your network. 

Solution:  By installing the *MRTG RPM* and following the procedure here, you will wind up with an i-bay that graphically displays traffic statistics such as, input/output per switch port in bps sampled/averaged every 5mins and graphed, hourly, daily, weekly and yearly for each of your Cisco switches and routers.  For more information about MRTG or to see examples of the output, visit the MRTG Home Page. This may work on other "manageable" switches/routers if they support SNMP.  An example graph of weekday traffic:

STEP 1:  Download and install the rpm
Download MRTG RPM Here
[root@localhost]# lynx
then type "d" to "download" and "Save-to-disk". 

Then install rpm by,
[root@localhost]# rpm -ivh mrtg-2.9.6-2.i386.rpm

Or with a recent version of RPM, download and install simultaneously using,
[root@localhost]# rpm -vhU

STEP 2:  create an iBay named "mrtg" 
(cgi permissions not needed, just read access )
STEP 3:  copy/paste the shell script below, name it "create-mrtg" and save in /root
(Notes: If you have only one or two devices, it may be convenient to run these commands one at a time from the root prompt. It took me 15-20mins to create all the devices for 50-60 switches we have on ours using the script below. Also checkout the MRTG site for other options available for the  "indexmaker" and "cfgmaker" that would allow you to customize the presentation of the charts.) 
(Tip: If you are using a Windows client to access E-Smith, It is very easy to copy/paste into a shell window.
Just open a new edit session with pico, select/copy all the "small" text below, then "right-click" inside the shell/pico window to paste, then CTRL-X, Y, to save. This works when using the command line too.) 

#This script will create a folder inside the ibay "mrtg" which is named by the first variable. It will create a cfg file inside the /etc/mrtg #folder. It will also add a line to the script "/etc/mrtg/all-ip" so that crontab will run this script which in turn will run mrtg for each #device. The second variable is the IP address of each device to be monitored..This script is best run when "all" the workstations #connected to it are powered up because "cfgmaker" ignores inactive ports when it is run.
#       EX:
#                                                              Var1     Var2
#                                                                 |         | 
#           [root@e-smith /root]# create-mrtg 10001

# Create a "workdir" for this device using the first variable
mkdir -p /home/e-smith/files/ibays/mrtg/html/$1

#create the cfg file for this Ip address using the first variable (assumes community string is "public")
perl /usr/bin/cfgmaker public@$2 --global "workdir: /home/e-smith/files/ibays/mrtg/html/$1" --output /etc/mrtg/$1.cfg

#Create an index.html file for this folder using the first variable
perl /usr/bin/indexmaker /etc/mrtg/$1.cfg > /home/e-smith/files/ibays/mrtg/html/$1/index.html

#create an entry in script "all-ip" to run mrtg for each device. 
echo "/usr/bin/mrtg /etc/mrtg/$1.cfg;" >> /etc/mrtg/all-ip 

#Uncommenting the line below will create a "master" index.htm inside the ibay/html directory for all devices.
#Note that this line will create a text file called index.html. This should be edited for correct html syntax.

#echo "<br><a href=$1/index.html> Traffic on ports of Device $1 </a>" >> /home/e-smith/files/ibays/mrtg/html/index.html

STEP 4:  Make the create-mrtg script executable by,

           [root@e-smith]# chmod 755 create-mrtg

STEP 5:  Now run create-mrtg
                                                                 Var1     Var2
                                                                    |          |
      EX:   [root@e-smith /root]# ./create-mrtg 10001
  • Where "10001" is the first variable and is used to create,
    • the mrtg configuration file for this device 
      • EX: "/etc/mrtg/10001.cfg",
    • a directory to place the png and html files created when the script runs
      • EX: "/home/e-smith/files/ibays/mrtg/html/10001"
  • And "" is the ip address of the device. 
  • STEP 6: Now run these commands once from the root prompt,
    (Revised in Ver 0.2 - I found that running mrtg for 50-60 switches from crontab every five minutes caused severe thrashing of the hdd. So that they go one-by-one, a script(all-ip) will run mrtg via a cron job for each device, sequentially.) 

     [root@e-smith /root]# chmod 755 /etc/mrtg/all-ip

     [root@e-smith /root]# mkdir -p /etc/e-smith/templates-custom/etc/crontab/

     [root@e-smith /root]# echo "0-59/5 * * * * root /etc/mrtg/all-ip" > /etc/e-smith/templates-custom/etc/crontab/mrtg

     [root@e-smith /root]# /sbin/e-smith/expand-template /etc/crontab

    STEP 7:  Now wait a few minutes (20 or so) and try
    EX:  http://your.server.ip/mrtg/10001
    • If you don't know all the IP addresses of your devices, you will find a freeware Win32 utility called Checkip 1.2 here. This will scan all known IPs in a given subnet. 
    • If you use the RedHat 7X, here are more specific instructions..