2. SNMP server
Initially we install the packets needed for SNMP. Yum makes this job a lot easier.
Next we make snmpd service to start automatically for the runlevels we want.
And we start the server.
We can see that it is running in port 199.
# netstat -natv | grep ':199'
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN
We run ‘snmpwalk’ which creates a “tree” of information for our network.
If you see an output like this one you may proceed with the MRTG installation. Else you should make some configuration first.
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.3 = 2
We open it
And do the follow changes:
com2sec local localhost public
com2sec mynetwork 10.0.0.0/8 public
group notConfigGroup v2c notConfigUser
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork
group MyROGroup usm mynetwork
view systemview included .184.108.40.206.220.127.116.11.1
with this one
access MyROGroup "" any noauth exact all none none
access MyRWGroup "" any noauth exact all all none
syscontact Root (configure /etc/snmp/snmp.local.conf)
syslocation Linux, Fedora Core 6
syscontact Root root@localhost
We restart the server to take affect of the notices
And we run again
Now we should see something like that
IP-MIB::ipAdEntIfIndex.10.103.0.33 = INTEGER: 2
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
Where 10.103.0.33 is your ip address.
We again use yum
We create the folder in which our graphs and html pages will be kept
And we run ‘cfgmaker’ for the configuration file to be created.
Here you should pay notice to --output /etc/mrtg/mrtg.cfg as long as to public@localhost. With this command we tell MRTG to create a configuration file with the name ‘mrtg.cfg’ for the traffic of our computer (localhost). Instead of localhost you may put the address of any computer you may monitor as long as it runs SNMP.
Next we create our default index page
3.2.1 Apache configuration
Next we have to configure apache for MRTG to work correctly. MRTG creates a file ‘mrtg.cfg’ under /etc/httpd/conf.d we contains all the necessary for Apache. We change it to contain the ips we want to have access to our MRTG graphs. Here I have added all my network.
Alias /mrtg /var/www/mrtg
<Location /mrtg> Order deny,allow
Deny from all
Allow from 127.0.0.1 10.0.0.0/8
We run the following command
In case you get an error like this
ERROR: Mrtg will most likely not work properly when the environment
variable LANG is set to UTF-8. Please run mrtg in an environment
where this is not the case. Try the following command to start:
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
you have to run the above command more than once till it runs without any error. This is normal.
23-02-2007 17:28:53, Rateup WARNING: /usr/bin/rateup Can't remove localhost_2.old updating log file
# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
Finally we open our browser and type
You should see something like this
And by clicking on it something like this
There are daily, weekly, monthly and yearly graphs which aren’t shown in the screenshot. By changing the .cfg file we can alter the information displayed to what we just want.
With the same way it is possible to add as many computers as we want and therefore have a general overview of our network. Enjoy! ;)
Alias /mrtg /var/www/mrtg Order deny,allow Deny from all Allow from 127.0.0.1