Multi Router Traffic Grapher
Contents
Server Setup
this document assumes that you already have a Apache and net-snmp working and configured properly
The following should all be performed as root.
- Install the necessary programs
# pacman -S mrtg perl-net-snmp
- create an mrtg user
# useradd -d /srv/http/mrtg mrtg
- create the user home directory and change the owner ship to the user
# mkdir /srv/http/mrtg/ # chown mrtg:mrtg /srv/http/mrtg
MRTG Setup
there are meny ways to configure the mrtg for your local server. this document will describe the must easest way to expend the application for other server and network appliances when and if needed.
The following should all be performed as the mrtg user we created.
- create an HTML directory to hold the png files and the index.html file
# mkdir /srv/http/mrtg/html
now we will begin dealing with the application scripts first we will create a basic mrtg.cfg file
- the next script will scan our localhost for it's interfaces and create for us the relevent configuration for each interface
# cfgmaker --output=/srv/http/mrtg/mrtg2.cfg --ifref=name --ifref=descr --global "WorkDir: /srv/http/mrtg" public@localhost
- the mrtg.cfg files contains all the server interfaces. we do not need the "lo" interface so we are going to delete it and edit the global configuration
mrtg.cfg Global configuration
remove the lines that are irrelevant to the interface and add the fallowing lines at the top:
### Global configuration ### LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt EnableIPv6: no HtmlDir: /srv/http/mrtg/html ImageDir: /srv/http/mrtg/html LogDir: /srv/http/mrtg ThreshDir: /srv/http/mrtg RunAsDaemon: Yes Interval: 5 Refresh: 600
the global configuration lines are :
- 1) to load the Linux MIB to the mrtg Applicaiton
- 2) to enable/disable IPv6
- 3) HTML home directory
- 4) the png files home directory
- 5) the log dir files locations
- 6) the Thres Directory
- 7) wether or not we want to run the application as a daemon , in this case : yes
- 8) the daemon interval (minimum 5 min)
- 9) the interval to refresh the html files
resource monitoring
now that we have the global configuration set we need to add the resources and devices we want to monitor.
in this tutorial we are going to monitor:
- 1)CPU
- 2)memory Usage
- 3)swap
- 4)Load Average
- 5)processes
- 6)the server interfaces
- 7)users count
- 8)the server mount points
CPU Monitoring
for monitoring the CPU we need to add the next lines :
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1 + ssCpuRawNice.0&ssCpuRawNice.0:public@127.0.0.1 RouterUptime[localhost.cpu]: public@127.0.0.1 MaxBytes[localhost.cpu]: 100 Title[localhost.cpu]: CPU Load PageTop[localhost.cpu]: Active CPU Load % Unscaled[localhost.cpu]: ymwd ShortLegend[localhost.cpu]: % YLegend[localhost.cpu]: CPU Utilization Legend1[localhost.cpu]: Active CPU in % (Load) Legend2[localhost.cpu]: Legend3[localhost.cpu]: Legend4[localhost.cpu]: LegendI[localhost.cpu]: Active LegendO[localhost.cpu]: Options[localhost.cpu]: growright,nopercent