Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Setup MRTG step by step
#1

Ok so it has been a while since I wrote a how-to for this site so here goes. This seems to be one of the more sought after confgiurations for network monitoring. You will need apache (httpd), mrt, and net-snmp-utils installed. since most noobs use RPM installations I am sure you can figure ou how to use the add remove programs or rpm -ivh <rpm>.

 

 

Below is the example of me adding my internet ip of my firewall to mrtg. First you need to make sure you can get snmp data from the device you wish to monitor.

 

Quote:snmpwalk -v 1 -c public 69.250.150.54 system
#you hould see this output for snmp walk:
Quote:[root@webfc4 ~]# snmpwalk -v 1 -c public 69.250.150.54 systemSNMPv2-MIB::sysDescr.0 = STRING: Linux fw1 2.4.9-39cp #1 Sun Jun 1 10:32:06 GMT 2003 i686

SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10

SNMPv2-MIB::sysUpTime.0 = Timeticks: (230122338) 26 days, 15:13:43.38

SNMPv2-MIB::sysContact.0 = STRING: Unknown

SNMPv2-MIB::sysName.0 = STRING: fw1

SNMPv2-MIB::sysLocation.0 = STRING: "Unknown"

SNMPv2-MIB::sysServices.0 = INTEGER: 76

SNMPv2-MIB::sysORLastChange.0 = Timeticks: (9) 0:00:00.09

SNMPv2-MIB::sysORID.1 = OID: IF-MIB::ifMIB

SNMPv2-MIB::sysORID.2 = OID: SNMPv2-MIB::snmpMIB

SNMPv2-MIB::sysORID.3 = OID: TCP-MIB::tcpMIB

SNMPv2-MIB::sysORID.4 = OID: IP-MIB::ip

SNMPv2-MIB::sysORID.5 = OID: UDP-MIB::udpMIB

SNMPv2-MIB::sysORID.6 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup

SNMPv2-MIB::sysORID.7 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance

SNMPv2-MIB::sysORID.8 = OID: SNMP-MPD-MIB::snmpMPDCompliance

SNMPv2-MIB::sysORID.9 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance

SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module to describe generic objects for network interface sub-layers

SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for SNMPv2 entities

SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing TCP implementations

SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing IP and ICMP implementations

SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing UDP implementations

SNMPv2-MIB::sysORDescr.6 = STRING: View-based Access Control Model for SNMP.

SNMPv2-MIB::sysORDescr.7 = STRING: The SNMP Management Architecture MIB.

SNMPv2-MIB::sysORDescr.8 = STRING: The MIB for Message Processing and Dispatching.

SNMPv2-MIB::sysORDescr.9 = STRING: The management information definitions for the SNMP User-based Security Model.

SNMPv2-MIB::sysORUpTime.1 = Timeticks: (5) 0:00:00.05

SNMPv2-MIB::sysORUpTime.2 = Timeticks: (5) 0:00:00.05

SNMPv2-MIB::sysORUpTime.3 = Timeticks: (5) 0:00:00.05

SNMPv2-MIB::sysORUpTime.4 = Timeticks: (5) 0:00:00.05

SNMPv2-MIB::sysORUpTime.5 = Timeticks: (5) 0:00:00.05

SNMPv2-MIB::sysORUpTime.6 = Timeticks: (5) 0:00:00.05

SNMPv2-MIB::sysORUpTime.7 = Timeticks: (9) 0:00:00.09

SNMPv2-MIB::sysORUpTime.8 = Timeticks: (9) 0:00:00.09

SNMPv2-MIB::sysORUpTime.9 = Timeticks: (9) 0:00:00.09

[root@webfc4 ~]#
 

Now you need to make the config (cfg) file for the device you want to monitor.

 

Quote:/usr/bin/cfgmaker --output=/etc/mrtg/69.250.150.54.cfg --ifref=ip --global "workdir: /var/www/mrtg" --snmp-options=:::::1 public@69.250.150.54
Now you need to run the env statement "three" times: 

Quote:#run three times#env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

env LANG=C /usr/bin/mrtg /etc/mrtg/69.250.150.54.cfg
 

#You should see this after each time ran:

 

Quote:[root@webfc4 ~]# env LANG=C /usr/bin/mrtg /etc/mrtg/69.250.150.54.cfgRateup WARNING: /usr/bin/rateup could not read the primary log file for 69.250.150.54_192.168.1.2

Rateup WARNING: /usr/bin/rateup The backup log file for 69.250.150.54_192.168.1.2 was invalid as well

Rateup WARNING: /usr/bin/rateup Can't remove 69.250.150.54_192.168.1.2.old updating log file

Rateup WARNING: /usr/bin/rateup Can't rename 69.250.150.54_192.168.1.2.log to 69.250.150.54_192.168.1.2.old updating log file

[root@webfc4 ~]# env LANG=C /usr/bin/mrtg /etc/mrtg/69.250.150.54.cfg

Rateup WARNING: /usr/bin/rateup Can't remove 69.250.150.54_192.168.1.2.old updating log file

[root@webfc4 ~]# env LANG=C /usr/bin/mrtg /etc/mrtg/69.250.150.54.cfg

[root@webfc4 ~]#
 

Now you need to make the actual index files for each machine:

#Very important you need to append the new machine to the line each time, if you do not you will only see

the newest entry.

 

Quote:indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg /etc/mrtg/192.168.1.100.cfg /etc/mrtg/192.168.1.102.cfg /etc/mrtg/192.168.1.204.cfg /etc/mrtg/192.168.1.2.cfg /etc/mrtg/69.250.150.54.cfg
Now lets edit mrtg to poll ever 5 minutes: 

Quote:vi /etc/cron.d/mrtg 

#Enter in you machines like my example below:

 

0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/192.168.1.100.cfg

0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/192.168.1.102.cfg

0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/192.168.1.204.cfg

0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/192.168.1.2.cfg

0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/69.250.150.54.cfg
 

Now restart the crond service.

 

Quote:service crond restart
 

Strabo

Reply
#2
Great tutorial Strabo thanks alot for taking the time to write this up for people to use.
Reply
#3

Hi,

 

Yea that was an excellent tutorial :)

Reply
#4

I almost forgot the simple one security is turned on by default and you can't connect remotely unless you change it. In the example below I canged it to allow all so I could connect to it from anywhere I wanted to from the internet or local lan.

 

Quote:vi /etc/httpd/conf.d/mrtg.conf 

 

#

# This configuration file maps the mrtg output (generated daily)

# into the URL space. By default these results are only accessible

# from the local host.

#

Alias /mrtg /var/www/mrtg

 

<Location /mrtg>

Order allow,deny

Allow from all

</Location>
Reply
#5

pinned and moved to apache

 

thanks Strabo !

 

cheers

anyweb

Reply
#6

Im getting this error

 



Code:
indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/216.171.237.69.cfg
Use of uninitialized value in hash element at /usr/bin/indexmaker line 340.




 

 

any ideas?

Reply
#7

can you possibly give more details about where you are getting the error, what your setup is like, and so on

 

at what point are you getting the failure ?

 

cheers

anyweb

Reply
#8

Quote:can you possibly give more details about where you are getting the error, what your setup is like, and so on 

at what point are you getting the failure ?

 

cheers

anyweb
 

I have almost the same error when running mrtg.cron :

"Use of uninitialized value in hash element at /usr/bin/indexmaker line 307."

 

here's my mrtg.cron content :

Quote:#!/bin/bash 

DIRCFG=/etc/mrtg

DIRHTML=/var/www/mrtg

LISTCFG="mrtg.cfg"

 

for CFG in $LISTCFG

do

env LANG=C /usr/bin/mrtg $DIRCFG/$CFG

done

 

# Make index file

cd $DIRCFG

/usr/bin/indexmaker --columns=1 $LISTCFG > $DIRHTML/index.html
 

And the output of "snmpwalk -v 1 -c public localhost system" :

Quote:SNMPv2-MIB::sysDescr.0 = STRING: Linux wpc0799.amenworld.com 2.6.10-1.771_FC2 #1 Mon Mar 28 00:50:14 EST 2005 i686SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10

SNMPv2-MIB::sysUpTime.0 = Timeticks: (246619) 0:41:06.19

SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)

SNMPv2-MIB::sysName.0 = STRING: wpc0799.amenworld.com

SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)

SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORID.1 = OID: IF-MIB::ifMIB

SNMPv2-MIB::sysORID.2 = OID: SNMPv2-MIB::snmpMIB

SNMPv2-MIB::sysORID.3 = OID: TCP-MIB::tcpMIB

SNMPv2-MIB::sysORID.4 = OID: IP-MIB::ip

SNMPv2-MIB::sysORID.5 = OID: UDP-MIB::udpMIB

SNMPv2-MIB::sysORID.6 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup

SNMPv2-MIB::sysORID.7 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance

SNMPv2-MIB::sysORID.8 = OID: SNMP-MPD-MIB::snmpMPDCompliance

SNMPv2-MIB::sysORID.9 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance

SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module to describe generic objects for network interface sub-layers

SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for SNMPv2 entities

SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing TCP implementations

SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing IP and ICMP implementations

SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing UDP implementations

SNMPv2-MIB::sysORDescr.6 = STRING: View-based Access Control Model for SNMP.

SNMPv2-MIB::sysORDescr.7 = STRING: The SNMP Management Architecture MIB.

SNMPv2-MIB::sysORDescr.8 = STRING: The MIB for Message Processing and Dispatching.

SNMPv2-MIB::sysORDescr.9 = STRING: The management information definitions for the SNMP User-based Security Model.

SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00

SNMPv2-MIB::sysORUpTime.9 = Timeticks: (0) 0:00:00.00
It's not the same line number but I'd bet It's the same line anyway. Seems like "host" in this /usr/bin/indexmaker (line 307) is undefined. I don't have any idea, and nothing came out from my google searches.

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)