Website XXL

Grafice Trafic cu MRTG pe FreeBSD

Grafice Trafic cu MRTG pe FreeBSD

Acest tutorial prezinta cum se pot genera graficele pentru trafic pe sistem FreeBSD folosing MRTG si SNMPD

Vom instala pachetele necesare folosind FreeBSD Ports

 

 

 

 

 

Instalam colectia de porturi FreeBSD Ports

root@bsdpc[~/work/src] # portsnap fetch && portsnap extract && portsnap fetch update

Instalam SNMPd, p5-SNMP-Util, p5-SNMP_Session, p5-SNMP-Simple din FreeBSD ports

root@bsdpc[~/work/src] # cd /usr/ports/net-mgmt/net-snmp
root@bsdpc[/usr/ports/net-mgmt/net-snmp] # make install clean
root@bsdpc[/usr/ports/net-mgmt/net-snmp] # cd /usr/ports/net-mgmt/p5-SNMP-Util
root@bsdpc[/usr/ports/net-mgmt/p5-SNMP-Util] # make install clean
root@bsdpc[/usr/ports/net-mgmt/p5-SNMP-Util] # cd /usr/ports/net-mgmt/p5-SNMP_Session/
root@bsdpc[/usr/ports/net-mgmt/p5-SNMP_Session] # make install clean
root@bsdpc[/usr/ports/net-mgmt/p5-SNMP_Session] # cd /usr/ports/net-mgmt/p5-SNMP-Simple/
root@bsdpc[/usr/ports/net-mgmt/p5-SNMP-Simple] # make install clean

Instalam MRTG din FreeBSD ports

root@bsdpc[~/work/src] # cd /usr/ports/net-mgmt/mrtg/
root@bsdpc[/usr/ports/net-mgmt/mrtg] # make install clean

Copiati codul de mai jos in /usr/local/share/snmp/snmpd.conf

Code:

syslocation YourCountry
syscontact YourName – you@yourdomain.tld
rwcommunity public 127.0.0.1
rwcommunity public 10.0.0.0/24

In loc de 10.0.0.0/24 treceti IP-ul sau range-ul de ip-uri din reteaua dumneavoastra pentru care doriti sa generati graficele de trafic

Copiati codul de mai jos in /usr/local/etc/mrtg/mrtg.cfg iar in loc de msk0 la MRTG_INT_DESCR=”msk0” treceti identificatorul de la placa de retea a systemului dumneavoastra.

Code:

LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
WorkDir: /usr/local/apache2/htdocs/stats
Options[_]: growright, bits, nopercent, nobanner, noinfo, pngdate
PNGTitle[_]: host.domain.tld
Background[_]: #FFFFFF
Timezone[_]: Europe/Europe
Colours[_]: GREEN#00FF00,BLUE#0066FF,DARK GREEN#33FF33,PINK#FF66FF
XSize[_]: 600
YSize[_]: 180
YTics[_]: 12
Target[speedused]: 1:public@127.0.0.1:
SetEnv[speedused]: MRTG_INT_IP=”” MRTG_INT_DESCR=”msk0″
MaxBytes[speedused]: 125000000
AbsMax[speedused]: 230000000
Title[speedused]: Traffic Analysis
PageTop[speedused]: Traffic Analysis
Options[speedused]: growright, bits, nopercent, nobanner, noinfo, pngdate

Editati /etc/rc.conf si adaugati snmpd_enable= “YES”, apoi pornim serviciul SNMPd

root@bsdpc[~/work/src] # /usr/local/etc/rc.d/snmpd start

Creem directorul unde se vor salva graficele MRTG

root@bsdpc[~/work/src] # mkdir /usr/local/apache2/htdocs/stats

Rulam de 2-3 ori scriptul MRTG pana cand acesta nu va ma da erori sau avertizari, la inceput acestea apar doarece nu gaseste fisierele de loguri si imaginile mai vechi

root@bsdpc[~/work/src] # /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg

Editam /etc/crontab si adaugam scriptul MRTG la crontab pentru ca acesta sa ruleze la fiecare 5 minute si sa actualizeze graficele

*/5 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg

Job Done! Enjoy!

Leave a Reply