Grafice Trafic cu MRTG pe FreeBSD

0
9

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

[alert status=”info”]root@bsdpc[~/work/src] # portsnap fetch && portsnap extract && portsnap fetch update[/alert]

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

[alert status=”info”]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[/alert]

Instalam MRTG din FreeBSD ports

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

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

Code:

[alert status=”info”]
syslocation YourCountry
syscontact YourName – you@yourdomain.tld
rwcommunity public 127.0.0.1
rwcommunity public 10.0.0.0/24
[/alert]

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:

[alert status=”info”]
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
[/alert]

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

[alert status=”info”]root@bsdpc[~/work/src] # /usr/local/etc/rc.d/snmpd start[/alert]

Creem directorul unde se vor salva graficele MRTG

[alert status=”info”]root@bsdpc[~/work/src] # mkdir /usr/local/apache2/htdocs/stats[/alert]

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

[alert status=”info”]root@bsdpc[~/work/src] # /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg[/alert]

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

[alert status=”info”]*/5 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg[/alert]

Job Done! Enjoy!

LEAVE A REPLY

Please enter your comment!
Please enter your name here