FreeBSD 6.0 ir MRTG HOWTO

Niekaip internete neradau trumpo ir aiškaus HOWTO, kaip instaliuoti ir susikonfigūruoti MRTG paprastam tinklo stebėjimui. Vienur informacija pasenusi, kitur kažkas neveikia ar ne taip paaiškinta. Visgi MRTG pasileidau ir dabar papasakosiu viską nuosekliai.

Tiems, kas nežino, kas yra MRTG (iš oficialaus MRTG puslapio):

Multi Router Traffic Grapher (MRTG) yra įrankis, kurio pagalba galima stebėti tinklo apkrovimą tinklo sujungimuose. MRTG sugeneruoja HTML puslapius, kuriuose yra matomi paveikslėliai, kurie vaizduoja tinklo apkrovimą realiu laiku. MRTG yra parašytas Perl ir C pagrindu bei veikia UNIX ir Windows NT šeimų operacinėse sistemose.


Instaliavimo instrukcija

1. Reikia instaliuoti SNMP (Simple Network Management Protocol). Šis protokolas yra plačiai naudojamas tam, kad būtų galima stebėti įvairius tinklo įrenginius (šiuo atveju stebėsime savo kompiuterį). Tam instaliuosime net-snmp FreeBSD port’ą. Net-SNMP yra programų rinkinys, kurios yra naudojamos implementuoti SNMP v1, SNMP v2c ir SNMP v3 protokolus naudojant IPv4 ir IPv6. Kad instaliuotume, darome taip:

main# cd /usr/ports/net-mgmt/net-snmp/
main# make install clean

2. Instaliuojame MRTG:

main# cd /usr/ports/net-mgmt/mrtg/
main# make install clean

3. Dabar reikia sukonfigūruoti SNMP.

3.1. Paleidžiame snmpconf (parametras -i naudojamas tam, kad nurodytume, jog konfigūracijos failas bus kūriamas /usr/local/share/snmp/ kataloge):

main# snmpconf -i
I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

1: snmpd.conf
2: snmptrapd.conf
3: snmp.conf

Other options: quit

Select File:

3.2. Įvedame 1 ir spaudžiame enter.

The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:

1: System Information Setup
2: Access Control Setup
3: Trap Destinations
4: Monitor Various Aspects of the Running Host
5: Extending the Agent
6: Agent Operating Mode

Other options: finished

Select section:

3.3. Pasirenkame 1.

Section: System Information Setup
Description:
This section defines some of the information reported in
the “system” mib group in the mibII tree.

Select from:

1: The [typically physical] location of the system.
2: The contact information for the administrator
3: The proper value for the sysServices object.

Other options: finished, list

Select section:

3.4. Pasirenkame 1.

Configuring: syslocation
Description:
The [typically physical] location of the system.
Note that setting this value here means that when trying to
perform an snmp SET operation to the sysLocation.0 variable will make
the agent return the “notWritable” error code. IE, including
this token in the snmpd.conf file will disable write access to
the variable.
arguments: location_string

The location of the system:

3.5. Dabar nurodome sistemos vietą, pavyzdžiui: Vilnius, Lithuania. Spaudžiame enter.

Finished Output: syslocation “Vilnius, Lithuania”
Section: System Information Setup
Description:
This section defines some of the information reported in
the “system” mib group in the mibII tree.

Select from:

1: The [typically physical] location of the system.
2: The contact information for the administrator
3: The proper value for the sysServices object.

Other options: finished, list

Select section:

3.6. Pasirenkame 2.

Configuring: syscontact
Description:
The contact information for the administrator
Note that setting this value here means that when trying to
perform an snmp SET operation to the sysContact.0 variable will make
the agent return the “notWritable” error code. IE, including
this token in the snmpd.conf file will disable write access to
the variable.
arguments: contact_string

The contact information:

3.7. Dabar reikia nurodyti sistemos administratoriaus kontaktus, pavyzdžiui: Vaidas Zlotkus (vaidas@zlotkus.com). Spaudžiame enter.

Finished Output: syscontact “Vaidas Zlotkus (vaidas@zlotkus.com)”

Section: System Information Setup
Description:
This section defines some of the information reported in
the “system” mib group in the mibII tree.

Select from:

1: The [typically physical] location of the system.
2: The contact information for the administrator
3: The proper value for the sysServices object.

Other options: finished, list

Select section:

3.8. Pasirenkame 3.

Configuring: sysservices
Description:
The proper value for the sysServices object.
arguments: sysservices_number

does this host offer physical services (eg, like a repeater) [answer 0 or 1]:

3.9. Įvedame 0 (manau, kad daugeliu atveju čia reikia vesti 0, nebent Jųsų konfigūracija yra kitokia ir žinote, ką darote).

does this host offer datalink/subnetwork services (eg, like a bridge):

3.10. Įvedame 0, jei Jūsų kompiuteris neatlieka BRIDGE funkcijos. Aš naudojau 1, nes mano sistemoje yra naudojamas BRIDGE (tiltas).

does this host offer internet services (eg, supports IP):

3.11. Įvedame 1.

does this host offer end-to-end services (eg, supports TCP):

3.12. Įvedame 1.

does this host offer application services (eg, supports SMTP):

3.13. Įveskite 1, jei Jūsų kompiuteryje yra pašto, web, irc ir t.t. servisas(-ai).

Finished Output: sysservices 78

Section: System Information Setup
Description:
This section defines some of the information reported in
the “system” mib group in the mibII tree.

Select from:

1: The [typically physical] location of the system.
2: The contact information for the administrator
3: The proper value for the sysServices object.

Other options: finished, list

Select section:

3.14. Įvedame finished.

The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:

1: System Information Setup
2: Access Control Setup
3: Trap Destinations
4: Monitor Various Aspects of the Running Host
5: Extending the Agent
6: Agent Operating Mode

Other options: finished

Select section:

3.15. Pasirenkame 2.

Section: Access Control Setup
Description:
This section defines who is allowed to talk to your running
snmp agent.

Select from:

1: a SNMPv3 read-write user
2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name

Other options: finished, list

Select section:

3.16. Pasirenkame 3.

Configuring: rocommunity
Description:
a SNMPv1/SNMPv2c read-only access community name
arguments: community [default|hostname|network/bits] [oid]

The community name to add read-only access for:

3.17. Pavyzdžiui, įvedame server.

The hostname or network address to accept this community name from [RETURN for all]:

3.18. Įrašykime localhost.

The OID that this community should be restricted to [RETURN for no-restriction]:

3.19. Spaudžiame tiesiog enter.

Finished Output: rocommunity server localhost

Section: Access Control Setup
Description:
This section defines who is allowed to talk to your running
snmp agent.

Select from:

1: a SNMPv3 read-write user
2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name

Other options: finished, list

Select section:

3.20. Įrašome finished.

The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:

1: System Information Setup
2: Access Control Setup
3: Trap Destinations
4: Monitor Various Aspects of the Running Host
5: Extending the Agent
6: Agent Operating Mode

Other options: finished

Select section:

3.21. Įrašome finished.

I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

1: snmpd.conf
2: snmptrapd.conf
3: snmp.conf

Other options: quit

Select File:

3.22. Įrašome quit.

The following files were created:

snmpd.conf installed in /usr/local/share/snmp

4. snmpd paleidimas.

4.1. Į /etc/rc.conf failą įrašome:

snmpd_enable=”YES”

4.2. Paleidžiame snmpd:

main# /usr/local/etc/rc.d/snmpd.sh start
Starting snmpd.

5. MRTG konfigūracija.

5.1. Įvedame šią eilutę, kad sukurtume mrtg.conf failą. Nepamirškite čia pakeisti /home/mrtg/ į savo direktoriją, kur bus laikomi MRTG sugeneruoti failai. Taip pat nepamirškite server@localhost, jei konfigūruodami vedėt kitokią informaciją.

main# cfgmaker –global “WorkDir: /home/mrtg/” server@localhost > /usr/local/etc/mrtg/mrtg.cfg

5.2. Įvedus šią komandą matysite visokius cfgmaker pranešimus, nebijokite jų :)

5.3. Išbandome mrtg:

mrtg /usr/local/etc/mrtg/mrtg.cfg

5.4. Neišsigąskite Rateup WARNING pranešimų. Pakartokite šią komandą dar du kartus, kol nebematysite šių perspėjimų.

5.5. Dabar sugeneruojam pagrindinį (index) MRTG puslapį:

indexmaker /usr/local/etc/mrtg/mrtg.cfg > /home/mrtg/index.html

5.6. Įdedame mrtg į crontab’ą:

crontab -e

5.7. Įrašome:

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

6. Apache konfigūravimas.

6.1. Įrašome į httpd.conf

[Directory "/home/mrtg"]
AllowOverride None
Options None
Order Deny,Allow
Allow from all
[/Directory]

[VirtualHost * ]
DocumentRoot /home/mrtg
ServerName mrtg.domenas.com
ServerAdmin admin@domenas.com
[/VirtualHost]

P.S.: Pakeiskite [ ir ] į normalius daugiau ir mažiau ženklus. Rašant šį straipsnį wordpress’as kažkodėl niekaip nepriėmė šių ženklų :)

6.2. Restartuojame apache:

apachectl restart

Resursai internete

  • http://people.ee.ethz.ch/~oetiker/webtools/mrtg/ – oficialus MRTG puslapis.
  • http://kerneltrap.org/node/3276 – trumpas howto.

Outro

Malonu būtų išgirsti Jūsų atsiliepimus čia po straipsniu arba į el. paštą vaidas at zlotkus dot com.

Tags: ,

2 Responses to “FreeBSD 6.0 ir MRTG HOWTO”

  1. Neoman says:

    parasyk vaideli apie freebsd idiegima gera straipsniuka kad net man butu aisq :) plz :D

  2. Šiaip viskas handbook’e labai aiškiai aprašyta, tad nematau prasmės apie tai rašyt. Nebent konkrečiai apie kuriuos nors specifinius dalykus, pavyzdžiui, disk labels ar pan… Bet irgi nematau prasmės – ten ir taip viskas aišku, jei turi supratimą apie techninius kompiuterio dalykus.

Leave a Reply