lunes, 24 de octubre de 2011

RTG debian squeeze

Instalación:

# apt-get install php5-snmp rrdtool php-pear libmysqlclient16 snmp gcc g++ make php5-snmp libsnmp15 libsnmp-dev libapache2-mod-php5 libsnmp-base php5-mysql php5-snmp php5-gd php5-cli php5-cgi libmysqlclient-dev mysql-server php5-mysql

# cd /usr/local/src

# wget http://puzzle.dl.sourceforge.net/sourceforge/rtg/rtg-0.7.4.tar.gz

# tar xzvf rtg-0.7.4.tar.gz

# cd rtg-0.7.4

# ./configure

# make

# make install

### Esto instala todos los archives de configuracion bajo: /usr/local/rtg

### Ahora copiar el archivo rtgplolt con el siguiente comando:


# cp /usr/local/src/rtg-0.7.4/src/rtgplot /usr/local/bin/rtgplot



Configurando la DB:

Para configurala debemos tener el password del mysql y reemplazarlo en el siguiente comando por (pass_mysql_root):

# /usr/local/rtg/etc/createdb (pass_mysql_root)


/usr/local/rtg/etc/createdb setting up MySQL database for RTG.
Using MySQL binaries in /usr/bin.

Adding user "snmp" to MySQL database...
Creating RTG database "rtg"...
Reloading MySQL privileges...
Creating RTG tables...
Done.



Configurando RTG: debemos editar 2 archivos

# vim /usr/local/rtg/etc/routers

#Comentar todo lo que tenga y solo dejarla ips de los routes que deseamos poolear, uno por cada linea
192.168.1.1

# vim /usr/local/rtg/etc/rtgtargmkr.pl
$community = "poner_my_comunidad"; # Default SNMP community

# /usr/local/rtg/etc/rtgtargmkr.pl

Poking 192.168.1.1 (mi_comunidad) (32 bit)...
SNMP Error:
no response received
SNMPv1_Session (remote host: "192.168.1.1 " [192.168.1.1].161)
community: "mi_comunidad"
request ID: 614928433
PDU bufsize: 8000 bytes
timeout: 2s
retries: 5
backoff: 1)
at /usr/local/rtg/etc/SNMP_util.pm line 458
SNMPGET Problem for sysDescr on mi_comunidad@192.168.1.1
at /usr/local/rtg/etc/rtgtargmkr.pl line 303


POSIBLEMENTE EL ERROR, PORQUE NO TIENE LA IP HABILITADA PARA CONSULTAS SNMP
Probamos haciendo un snmpwalk:


# snmpwalk -v 2c –c mi_comunidad 192.168.1.1

Timeout: No Response from 192.168.1.1 #Esto nos indica que no llegamos x snmp

En cambio si tenemos varias líneas con algo como esto, si esta funcionando:
iso.3.6.1.2.1.2.2.1.1.52 = INTEGER: 52
iso.3.6.1.2.1.2.2.1.1.53 = INTEGER: 53
iso.3.6.1.2.1.2.2.1.1.54 = INTEGER: 54


Volvemos a ejecutar el script en perl si tuvimos error de snmp:
# /usr/local/rtg/etc/rtgtargmkr.pl

# mv /root/targets.cfg /usr/local/rtg/targets.cfg

# mysql rtg –u root –p
mysql> UPDATE interface SET description='global_network 100Mbps' WHERE id=7;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> quit



Iniciar el pooleo:

# /usr/local/rtg/bin/rtgpoll -v -t /usr/local/rtg/targets.cfg

RTG version 0.7.4 starting.
Checking another instance with pid 6560.
PID 6560 is no longer running. Starting anyway.
Using RTG config file [/usr/local/rtg/etc/rtg.conf].
Reading RTG target list [/usr/local/src/rtg-0.7.4/targets.cfg].
Successfully hashed [268] new targets, (94336 bytes).
Initializing threads (5).
Initializing SNMP (v1, port 161).
Connecting to MySQL database 'rtg' on 'localhost'...connected.
RTG Ready.
[10/23 23:00:31 Queue ready, broadcasting thread go condition.]
[10/23 23:00:31 Poll round 1 complete.]

[Polls = 268] [DBInserts = 0] [Wraps = 0] [OutOfRange = 0]
[No Resp = 0] [SNMP Errs = 0] [Slow = 0] [PollTime = 0.785s]



Agregamos el siguiente comando en el inicio al rc.local:

# vim /etc/rc.local
/usr/local/rtg/bin/rtgpoll -v -t /usr/local/rtg/targets.cfg -c /usr/local/rtg/etc/rtg.conf



Interface web:

# cp -Rpf /usr/local/rtg/web/ /var/www/rtgweb

# cp –pf /usr/local/rtg/bin/rtgplot /var/www/rtgweb/rtgplot.cgi

# vim /etc/apache2/sites-enabled/rtg




AllowOverride AuthConfig
AddType application/x-httpd-php .php
AddHandler cgi-script .cgi
Options +ExecCGI




# vim /usr/local/rtg/etc/rtg.conf

#
# RTG Master Config
#
Interval 300
HighSkewSlop 3
LowSkewSlop .5
OutOfRange 93750000000
SNMP_Ver 2
SNMP_Port 161
DB_Host localhost
DB_Database rtg
DB_User snmp
DB_Pass rtgdefault
Threads 5



Restartear apache server:

# /etc/init.d/apache2 restart


Se puede acceder al servicio en http://yourserverip/rtgweb/

http://192.168.1.1/rtgweb/rtg.php

http://yourserverip/rtgweb/rtg.php (Interactive Reports)
http://yourserverip/rtgweb/95.php (95th Percentile Queries)
http://yourserverip/rtgweb/view.php (MRTG-style overview + day/wk/mo plots)


FUENTE: http://www.debianhelp.co.uk/rtg.htm

No hay comentarios: