MRTG и SNMP настройка под Gentoo: различия между версиями
ALEX (обсуждение | вклад) (Новая: 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 ine...) |
ALEX (обсуждение | вклад) |
||
Строка 220: | Строка 220: | ||
Target[localhost_ppp0]: \ppp0:public@localhost: | Target[localhost_ppp0]: \ppp0:public@localhost: | ||
SetEnv[localhost_ppp0]: MRTG_INT_IP="78.107.250.18" MRTG_INT_DESCR="ppp0" | SetEnv[localhost_ppp0]: MRTG_INT_IP="78.107.250.18" MRTG_INT_DESCR="ppp0" | ||
MaxBytes[localhost_ppp0]: | MaxBytes[localhost_ppp0]: 125000000 | ||
Title[localhost_ppp0]: ppp0 -- router_a | Title[localhost_ppp0]: ppp0 -- router_a | ||
PageTop[localhost_ppp0]: <h1>ppp0 -- router_a</h1> | PageTop[localhost_ppp0]: <h1>ppp0 -- router_a</h1> | ||
Строка 255: | Строка 255: | ||
</pre> | </pre> | ||
'''/etc/mrtg/cpu.cfg''' | |||
<pre> | |||
WorkDir: /var/www/localhost/htdocs/mrtg | |||
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt | |||
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1 + ssCpuRawNice.0&ssCpuRawNice.0:public@127.0.0.1 | |||
RouterUptime[localhost.cpu]: public@127.0.0.1 | |||
MaxBytes[localhost.cpu]: 100 | |||
Title[localhost.cpu]: CPU Load | |||
PageTop[localhost.cpu]: <H1>Active CPU Load %</H1> | |||
Unscaled[localhost.cpu]: ymwd | |||
ShortLegend[localhost.cpu]: % | |||
YLegend[localhost.cpu]: CPU Utilization | |||
Legend1[localhost.cpu]: Active CPU in % (Load) | |||
Legend2[localhost.cpu]: | |||
Legend3[localhost.cpu]: | |||
Legend4[localhost.cpu]: | |||
LegendI[localhost.cpu]: Active | |||
LegendO[localhost.cpu]: | |||
Options[localhost.cpu]: growright,nopercent | |||
</pre> | |||
/etc/mrtg/mem.cfg | |||
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt | |||
Target[localhost.mem]: memAvailReal.0&memAvailReal.0:public@localhost | |||
PageTop[localhost.mem]: <H1>Free Memory</H1> | |||
WorkDir: /var/www/localhost/htdocs/mrtg | |||
Options[localhost.mem]: nopercent,growright,gauge,noinfo | |||
Title[localhost.mem]: Free Memory | |||
MaxBytes[localhost.mem]: 1000000 | |||
kMG[localhost.mem]: k,M,G,T,P,X | |||
YLegend[localhost.mem]: bytes | |||
ShortLegend[localhost.mem]: bytes | |||
LegendI[localhost.mem]: Free Memory: | |||
LegendO[localhost.mem]: | |||
Legend1[localhost.mem]: Free memory, not including swap, in bytes | |||
/etc/mrtg/ping.cfg | |||
WorkDir: /var/www/localhost/htdocs/mrtg | |||
Title[localhost.ping]: Round Trip Time | |||
PageTop[localhost.ping]: <H1>Round Trip Time</H1> | |||
Target[localhost.ping]: `/etc/mrtg/ping.sh` | |||
MaxBytes[localhost.ping]: 2000 | |||
Options[localhost.ping]: growright,unknaszero,nopercent,gauge | |||
LegendI[localhost.ping]: Pkt loss % | |||
LegendO[localhost.ping]: Avg RTT | |||
YLegend[localhost.ping]: RTT (ms) | |||
/etc/cron.mrtg/cpu | |||
#!/bin/sh | |||
/usr/bin/mrtg /etc/mrtg/cpu.cfg | |||
/etc/cron.mrtg/mem | |||
#!/bin/sh | |||
/usr/bin/mrtg /etc/mrtg/mem.cfg | |||
/etc/cron.mrtg/ping | |||
#!/bin/sh | |||
/usr/bin/mrtg /etc/mrtg/ping.cfg | |||
/etc/mrtg/ping.sh | |||
#!/bin/sh | |||
PING="/bin/ping" | |||
# Google, for example | |||
ADDR="google.com" | |||
DATA=`$PING -c10 -s500 $ADDR -q ` | |||
LOSS=`echo $DATA | awk '{print $18 }' | tr -d %` | |||
echo $LOSS | |||
if [ $LOSS = 100 ]; | |||
then | |||
echo 0 | |||
else | |||
echo $DATA | awk -F/ '{print $5 }' | |||
fi | |||
/bin/chmod +x /etc/cron.mrtg/* | |||
/bin/chmod +x /etc/mrtg/ping.sh | |||
Run each script 3 times (disregard the warnings) | |||
/etc/cron.mrtg/traffic | |||
/etc/cron.mrtg/cpu | |||
/etc/cron.mrtg/mem | |||
/etc/cron.mrtg/ping |
Версия 20:09, 20 ноября 2008
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]: 125000000 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>
/etc/mrtg/cpu.cfg
WorkDir: /var/www/localhost/htdocs/mrtg LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1 + ssCpuRawNice.0&ssCpuRawNice.0:public@127.0.0.1 RouterUptime[localhost.cpu]: public@127.0.0.1 MaxBytes[localhost.cpu]: 100 Title[localhost.cpu]: CPU Load PageTop[localhost.cpu]: <H1>Active CPU Load %</H1> Unscaled[localhost.cpu]: ymwd ShortLegend[localhost.cpu]: % YLegend[localhost.cpu]: CPU Utilization Legend1[localhost.cpu]: Active CPU in % (Load) Legend2[localhost.cpu]: Legend3[localhost.cpu]: Legend4[localhost.cpu]: LegendI[localhost.cpu]: Active LegendO[localhost.cpu]: Options[localhost.cpu]: growright,nopercent
/etc/mrtg/mem.cfg
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt Target[localhost.mem]: memAvailReal.0&memAvailReal.0:public@localhost
PageTop[localhost.mem]:
Free Memory
WorkDir: /var/www/localhost/htdocs/mrtg Options[localhost.mem]: nopercent,growright,gauge,noinfo Title[localhost.mem]: Free Memory MaxBytes[localhost.mem]: 1000000 kMG[localhost.mem]: k,M,G,T,P,X YLegend[localhost.mem]: bytes ShortLegend[localhost.mem]: bytes LegendI[localhost.mem]: Free Memory: LegendO[localhost.mem]: Legend1[localhost.mem]: Free memory, not including swap, in bytes
/etc/mrtg/ping.cfg
WorkDir: /var/www/localhost/htdocs/mrtg Title[localhost.ping]: Round Trip Time
PageTop[localhost.ping]:
Round Trip Time
Target[localhost.ping]: `/etc/mrtg/ping.sh` MaxBytes[localhost.ping]: 2000 Options[localhost.ping]: growright,unknaszero,nopercent,gauge LegendI[localhost.ping]: Pkt loss % LegendO[localhost.ping]: Avg RTT YLegend[localhost.ping]: RTT (ms)
/etc/cron.mrtg/cpu
- !/bin/sh
/usr/bin/mrtg /etc/mrtg/cpu.cfg
/etc/cron.mrtg/mem
- !/bin/sh
/usr/bin/mrtg /etc/mrtg/mem.cfg
/etc/cron.mrtg/ping
- !/bin/sh
/usr/bin/mrtg /etc/mrtg/ping.cfg
/etc/mrtg/ping.sh
#!/bin/sh PING="/bin/ping" # Google, for example ADDR="google.com" DATA=`$PING -c10 -s500 $ADDR -q ` LOSS=`echo $DATA | awk '{print $18 }' | tr -d %` echo $LOSS if [ $LOSS = 100 ]; then echo 0 else echo $DATA | awk -F/ '{print $5 }' fi
/bin/chmod +x /etc/cron.mrtg/* /bin/chmod +x /etc/mrtg/ping.sh
Run each script 3 times (disregard the warnings) /etc/cron.mrtg/traffic /etc/cron.mrtg/cpu /etc/cron.mrtg/mem /etc/cron.mrtg/ping