centos 7 : mrtg setup Hint

# yum -y install net-snmp net-snmp-utils mrtg

 

# vi /etc/snmp/snmpd.conf

-----------------------

#com2sec notConfigUser  default       public

 

com2sec local     localhost       owl

com2sec mynetwork 192.168.0.10      owl

 

group MyRWGroup  v2c        local

group MyROGroup  v2c        mynetwork

 

view all    included  .1                               80

 

access MyROGroup ""      v2c       noauth    exact      all    none   none

access MyRWGroup ""      v2c       noauth    exact      all    all    all

-----------------------

 

# systemctl enable snmpd 

# systemctl start snmpd 

 

# snmpwalk -v2c -c owl localhost system 

 

# cfgmaker --snmp-options=:::::2 --ifref=descr --ifdesc=descr owl@192.168.0.10 > /etc/mrtg/mrtg.cfg 

 

# vi /etc/mrtg/mrtg.cfg

-----------------------

WorkDir: /var/www/mrtg

Options[_]: growright, bits

-----------------------

 

or 

 

# sed -i 's/# WorkDir: \/home\/http\/mrtg/WorkDir: \/var\/www\/mrtg/g' /etc/mrtg/mrtg.cfg

# sed -i 's/# Options\[_\]: growright, bits/Options\[_\]: growright, bits, nobanner, nolegend/g' /etc/mrtg/mrtg.cfg

 

or 

 

cfgmaker --snmp-options=:::::2 --ifref=descr,ip,name,nr --ifdesc=ip,name \

--global "WorkDir: /var/www/mrtg" \

--global "Options[_]: growright, bits, nobanner, nolegend" \

owl@localhost > /etc/mrtg/mrtg.cfg 

 

 

# for (( i=1 ; i <= 3 ; i++ )); do env LANG=C mrtg /etc/mrtg/mrtg.cfg; done 

#  indexmaker --columns=1 --nolegend --title "owl46" /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

 

 

# vi /etc/cron.d/mrtg

*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok

 

or

 

# echo "*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok" > /etc/cron.d/mrtg

 

 

# vi /etc/httpd/conf.d/mrtg.conf

-----------------------

# comment all, use .htaccess

#Alias /mrtg /var/www/mrtg

#<Location /mrtg>

#    Require local

#    # Require ip 10.1.2.3

#    # Require host example.org

#</Location>

-----------------------

 

or 

 

# sed -i -e 's/^/#/' /etc/httpd/conf.d/mrtg.conf

 

 

# vi /var/www/mrtg/.htaccess

-----------------------

Header set X-Robots-Tag "noindex, nofollow"

 

AuthType Basic

AuthName "restricted area"

AuthUserFile /var/www/mrtg/.htpasswd

require valid-user

------------------------

 

# htpasswd -c /var/www/mrtg/.htpasswd admin

 

 

# systemctl restart httpd