MRTG и SNMP настройка под Gentoo
Required: net-analyzer/net-snmp media-libs/gd net-analyzer/mrtg sys-process/dcron
Optional: net-www/apache
This guide suggests using an mrtg config per target, this is rather inefficient as mrtg can do them all in 1 job itself SU Into root before continuing forward. Start by: mkdir /etc/mrtg mkdir /etc/cron.mrtg mkdir -p /var/www/localhost/htdocs/mrtg
/etc/snmp/snmpd.conf
#### # First, map the community name (COMMUNITY) into a security name # (local and mynetwork, depending on where the request is coming # from): # sec.name source community com2sec local 127.0.0.0/24 public #### # Second, map the security names into group names: # sec.model sec.name group MyROGroup v1 local group MyROGroup v2c local group MyROGroup usm local #### # Third, create a view for us to let the groups have rights to: # incl/excl subtree mask view all included .1 80 #### # Finally, grant the 2 groups access to the 1 view with different # write permissions: # context sec.model sec.level match read write notif access MyROGroup "" any noauth exact all none none ############################################################################### # System contact information # syslocation Russia.Moscow syscontact Alexander <gav-alex@bk.ru>
/etc/conf.d/snmpd
- Initial (empty) options.
SNMPD_FLAGS="-C -c /etc/snmp/snmpd.conf"
This makes sure SNMPD uses the above /etc/snmp/snmpd.conf, and _only_ that file.
Now the daemon: /etc/init.d/snmpd start /sbin/rc-update add snmpd default SNMPD_FLAGS="-C -c /etc/snmp/snmpd.conf"
НАСтройка
/usr/bin/cfgmaker \ --output=/etc/mrtg/traffic.cfg \ --ifdesc=ip \ --ifref=descr \ --global "WorkDir: /var/www/localhost/htdocs/mrtg" \ --global "Options[_]: bits,growright" \
public@localhost
Далее в ручную поправим файл для того чтобы активировать ppp и lo
в итоге у меня вышел вот такой файл
### Global Defaults
# to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits
EnableIPv6: no
WorkDir: /var/www/localhost/htdocs/mrtg
Options[_]: bits,growright
### Interface 1 >> Descr: 'lo' | Name: 'lo' | Ip: '127.0.0.1' | Eth: '' ###
### It is a Software Loopback interface
Target[localhost_lo]: \lo:public@localhost:
SetEnv[localhost_lo]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo"
MaxBytes[localhost_lo]: 125000000
Title[localhost_lo]: 127.0.0.1 -- router_a
PageTop[localhost_lo]: <h1>127.0.0.1 -- router_a</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>router_a in Russia.Moscow</td>
</tr>
<tr>
<td>Maintainer:</td>
<td>Alexander <gav-alex@bk.ru></td>
</tr>
<tr>
<td>Description:</td>
<td>lo </td>
</tr>
<tr>
<td>ifType:</td>
<td>softwareLoopback (24)</td>
</tr>
<tr>
<td>ifName:</td>
<td>lo</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>10.0 Mbits/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>127.0.0.1 (localhost)</td>
</tr>
</table>
</div>
### Interface 2 >> Descr: 'eth1' | Name: 'eth1' | Ip: '192.168.0.1' | Eth: '00-c0-26-ab-e9-2b' ###
Target[localhost_eth1]: \eth1:public@localhost:
SetEnv[localhost_eth1]: MRTG_INT_IP="192.168.0.1" MRTG_INT_DESCR="eth1"
MaxBytes[localhost_eth1]: 1250000000
Title[localhost_eth1]: 192.168.0.1 -- router_a
PageTop[localhost_eth1]: <h1>192.168.0.1 -- router_a</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>router_a in Russia.Moscow</td>
</tr>
<tr>
<td>Maintainer:</td>
<td>Alexander <gav-alex@bk.ru></td>
</tr>
<tr>
<td>Description:</td>
<td>eth1 </td>
</tr>
<tr>
<td>ifType:</td>
<td>ethernetCsmacd (6)</td>
</tr>
<tr>
<td>ifName:</td>
<td>eth1</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>100.0 Mbits/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>192.168.0.1 ()</td>
</tr>
</table>
</div>
### Interface 3 >> Descr: 'eth0' | Name: 'eth0' | Ip: '10.134.41.247' | Eth: '00-1d-7d-02-c3-ca' ###
Target[localhost_eth0]: \eth0:public@localhost:
SetEnv[localhost_eth0]: MRTG_INT_IP="10.134.41.247" MRTG_INT_DESCR="eth0"
MaxBytes[localhost_eth0]: 1250000000
Title[localhost_eth0]: 10.134.41.247 -- router_a
PageTop[localhost_eth0]: <h1>10.134.41.247 -- router_a</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>router_a in Russia.Moscow</td>
</tr>
<tr>
<td>Maintainer:</td>
<td>Alexander <gav-alex@bk.ru></td>
</tr>
<tr>
<td>Description:</td>
<td>eth0 </td>
</tr>
<tr>
<td>ifType:</td>
<td>ethernetCsmacd (6)</td>
</tr>
<tr>
<td>ifName:</td>
<td>eth0</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>100.0 Mbits/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>10.134.41.247 ()</td>
</tr>
</table>
</div>
### Interface 143160 >> Descr: 'ppp0' | Name: 'ppp0' | Ip: '' | Eth: '' ###
Target[localhost_ppp0]: \ppp0:public@localhost:
SetEnv[localhost_ppp0]: MRTG_INT_IP="78.107.250.18" MRTG_INT_DESCR="ppp0"
MaxBytes[localhost_ppp0]: 0
Title[localhost_ppp0]: ppp0 -- router_a
PageTop[localhost_ppp0]: <h1>ppp0 -- router_a</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>router_a in Russia.Moscow</td>
</tr>
<tr>
<td>Maintainer:</td>
<td>Alexander <gav-alex@bk.ru></td>
</tr>
<tr>
<td>Description:</td>
<td>ppp0 </td>
</tr>
<tr>
<td>ifType:</td>
<td>ppp (23)</td>
</tr>
<tr>
<td>ifName:</td>
<td>ppp0</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>0.0 bits/s</td>
</tr>
</table>
</div>