2005-11-23, 04:08 PM
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.54Now 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.cfgNow 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