Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
MRTG requiere de un servidor Web instalado en la máquina, así como también librerías para generar
gráficos (gd) y herramientas de compilación que serán usadas también por NAGIOS:
Como paso previo, verifiquemos si tenemos los pre requisitos instalados:
En CentOS 6:
chkconfig httpd on
service httpd restart
1
1. Instalación de los paquetes
La siguiente instrucción instalará los siguientes paquetes:
SNMP
MRTG
yum install mrtg net-snmp net-snmp-utils
Se instalarán también todas las dependencias requeridas.
Configuramos el fichero principal de SNMP, luego de generar una copia del mismo:
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.original
vi /etc/snmp/snmpd.conf
En CentOS 6:
chkconfig snmpd on
service snmpd restart
Podemos probar con el comando “snmpwalk” si se puede obtener información del sistema:
snmpwalk -v 1 -c snmpsecret localhost IP-MIB::ipAdEntIfIndex
En caso de que este comando de error, o timeout, se puede deber a solo 2 motivos:
El demonio snmpd no fue reiniciado correctamente
El fichero de configuración snmpd.conf tiene algún error
2
3. Configurar MRTG
Una guía completa de como configurar MRTG se encuentra en esta página web:
http://oss.oetiker.ch/mrtg/doc/index.en.html
Acortaremos los pasos.
Finalmente, ejecutamos indexmaker para crear las páginas web iniciales para desplegar los estados
que genere MRTG:
indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
Debería darnos:
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
--lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
5. Ejecutamos el comando de MRTG unas 3 veces para que generen los ficheros de datos
LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
--lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
3
6. Habilitamos el acceso a la página MRTG
MRTG ya está instalado y corriendo cada 5 minutos.
MRTG ya tiene una página web, pero por defecto está configurada para que solo se pueda ver desde
el servidor local.
Si desea, puede acceder desde el navegador de su servidor local asi:
http://localhost/mrtg
http://127.0.0.1/mrtg
Si desea entrar desde afuera, hay que configurar el fichero de acceso del MRTG
cp /etc/httpd/conf.d/mrtg.conf /etc/httpd/conf.d/mrtg.original
vi /etc/httpd/conf.d/mrtg.conf
<Location /mrtg>
Order deny,allow
Allow from all
# Allow from 127.0.0.1
# Allow from ::1
# Allow from .example.com
</Location>
En CentOS 6:
service httpd restart
Primero creamos el fichero que nos ayudará a desplegar la carga promedio del sistema.
/var/lib/mrtg/mrtg-loadavg.sh
4
El fichero debe tener este contenido:
#!/bin/sh
# Created by Jehiah Czebotar
# http://www.jehiah.com/
#
# This script is licensed under the GPL
# http://www.gnu.org/copyleft/gpl.html
#
# Date : January 5, 2003
# File : mrtg-loadavg.sh
# Version: 1.0
#########################
# Target[spock-cpu]: `scripts/mrtg-loadavg.sh`
# MaxBytes[spock-cpu]: 500
# Title[spock-cpu]: Server CPU Load (5 minute average)
# YLegend[spock-cpu]: Load*100
# ShortLegend[spock-cpu]: load
# Legend1[spock-cpu]: CPU Load (x 100)
# Legend2[spock-cpu]:
# LegendI[spock-cpu]: 1min load
# LegendO[spock-cpu]: 5min load
# PageTop[spock-cpu]: <h1>Server 5-minute average CPU Load</h1>
# Options[spock-cpu]: gauge,nopercent,integer,growright
5
#
# Memory Monitoring (Percentage usage)
#
Title[spock_mempercent]: Percentage Free Memory
PageTop[spock_mempercent]: <h1>Percentage Free Memory</h1>
Target[spock_mempercent]: (
memAvailReal.0&memAvailReal.0:snmpsecret@localhost ) * 100 / (
memTotalReal.0&memTotalReal.0:snmpsecret@localhost )
options[spock_mempercent]: growright,gauge,transparent,nopercent
Unscaled[spock_mempercent]: ymwd
MaxBytes[spock_mempercent]: 100
YLegend[spock_mempercent]: Memory %
ShortLegend[spock_mempercent]: Percent
LegendI[spock_mempercent]: Free
LegendO[spock_mempercent]: Free
Legend1[spock_mempercent]: Percentage Free Memory
Legend2[spock_mempercent]: Percentage Free Memory
#
# New TCP Connection Monitoring (per minute)
#
Target[spock_newconns]:
tcpPassiveOpens.0&tcpActiveOpens.0:snmpsecret@localhost
Title[spock_newconns]: Newly Created TCP Connections
PageTop[spock_newconns]: <h1>New TCP Connections</h1>
MaxBytes[spock_newconns]: 10000000000
ShortLegend[spock_newconns]: c/s
YLegend[spock_newconns]: Conns / Min
LegendI[spock_newconns]: In
LegendO[spock_newconns]: Out
Legend1[spock_newconns]: New inbound connections
Legend2[spock_newconns]: New outbound connections
Options[spock_newconns]: growright,nopercent,perminute
#
# Established TCP Connections
#
Target[spock_estabcons]: tcpCurrEstab.0&tcpCurrEstab.0:snmpsecret@localhost
Title[spock_estabcons]: Currently Established TCP Connections
PageTop[spock_estabcons]: <h1>Established TCP Connections</h1>
MaxBytes[spock_estabcons]: 10000000000
ShortLegend[spock_estabcons]:
YLegend[spock_estabcons]: Connections
LegendI[spock_estabcons]: In
LegendO[spock_estabcons]:
Legend1[spock_estabcons]: Established connections
Legend2[spock_estabcons]:
Options[spock_estabcons]: growright,nopercent,gauge
6
#
# Disk Usage Monitoring
#
Target[spock_disk]: dskPercent.1&dskPercent.1:snmpsecret@localhost
Title[spock_disk]: Disk Partition Usage
PageTop[spock_disk]: <h1>Disk Partition Usage /</h1>
MaxBytes[spock_disk]: 100
ShortLegend[spock_disk]: %
YLegend[spock_disk]: Utilization
LegendI[spock_disk]: /
LegendO[spock_disk]:
Options[spock_disk]: gauge,growright,nopercent
Unscaled[spock_disk]: ymwd
#
# CPU Server Load Monitoring
#
Target[spock-cpu]: `/var/lib/mrtg/mrtg-loadavg.sh`
MaxBytes[spock-cpu]: 500
Title[spock-cpu]: Average Server Load
YLegend[spock-cpu]: Load
ShortLegend[spock-cpu]: load
Legend1[spock-cpu]: 1min Avg Server Load
Legend2[spock-cpu]: 5min Avg Sever Load
LegendI[spock-cpu]: 1min load
LegendO[spock-cpu]: 5min load
PageTop[spock-cpu]: <h1>Average Server Load</h1>
Options[spock-cpu]: gauge,nopercent,growright
YTicsFactor[spock-cpu]: 0.01
Factor[spock-cpu]: 0.01