====== Smokeping + Nginx en CentOS 6.4 ======
Smokeping, programado en perl, es un monitor de latencias basado en RRDTool (del mismísimo autor), mide el retardo de ICMP y varios servicios (DNS, SSH, HTTP, SMTP, LDAP, etc). En esta entrada, mostraremos como instalar desde el código fuente Smokeping, como integrarlo en el servidor web Nginx y configurarlo básicamente en CentOS 6.4
===== Software y versiones =====
* Smokeping Webpage: [[http://oss.oetiker.ch/smokeping/]]
* Webserver: Nginx 1.5.11
* Smokeping: 2.6.9
* Centos: 6.4
==== Desactivar Selinux / firewall (iptables) ====
**Deshabilitar SELinux**.
setenforce 0
**Deshabilitar Firewall**.
Bearbeiten Datei: /etc/selinux/config
SELINUX=disable
service iptables stop
chkconfig iptables off
==== Instalar repositorios EPEL y RepoForge en CentOS 6.X ====
curl -O -L http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
curl -O http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
curl -O http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
==== Instalar dependencias para Smokeping ====
yum install gcc gcc-c++ kernel-devel
yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-RRD-Simple perl-CGI-SpeedyCGI perl-ExtUtils-MakeMaker perl5lib perl-CPAN wget
yum --enablerepo=epel -y install spawn-fcgi fcgi-devel
yum -y groupinstall "Development Tools"
==== Compilar / Instalar Smokeping en CentOS 6.X ====
export PERL5LIB=/usr/lib64/perl5/
mkdir -p /opt/smokeping
tar -zxvf smokeping-2.6.9.tar.gz
cd smokeping-2.6.9
./setup/build-perl-modules.sh /opt/smokeping/thirdparty
./configure --prefix=/opt/smokeping
gmake install
cd /opt/smokeping/
mkdir data var htdocs/cache
cd /opt/smokeping/etc
for foo in *.dist; do cp $foo `basename $foo .dist`; done
cd /opt/smokeping/htdocs
cp smokeping.fcgi.dist smokeping.fcgi
chmod 600 /opt/smokeping/etc/smokeping_secrets.dist
==== Init script para Smokeping ====
#!/bin/sh
#
# smokeping This starts and stops the smokeping daemon
# chkconfig: 345 98 11
# description: Start/Stop the smokeping daemon
# processname: smokeping
# Source function library.
. /etc/rc.d/init.d/functions
SMOKEPING=/opt/smokeping/bin/smokeping
LOCKF=/var/lock/subsys/smokeping
CONFIG=/opt/smokeping/etc/config
[ -f $SMOKEPING ] || exit 0
[ -f $CONFIG ] || exit 0
RETVAL=0
case "$1" in
start)
echo -n $"Starting SMOKEPING: "
daemon $SMOKEPING
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKF
;;
stop)
echo -n $"Stopping SMOKEPING: "
killproc $SMOKEPING
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCKF
;;
status)
status smokeping
RETVAL=$?
;;
reload)
echo -n $"Reloading SMOKEPING: "
killproc $SMOKEPING -HUP
RETVAL=$?
echo
;;
restart)
$0 stop
sleep 3
$0 start
RETVAL=$?
;;
condrestart)
if [ -f $LOCKF ]; then
$0 stop
sleep 3
$0 start
RETVAL=$?
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
chmod 755 /etc/init.d/smokeping
==== Configurar y activar los logs de Smokeping (rsyslog) ====
Fichero de Log de Smokeping: ///var/log/smokeping.log//
Datei /etc/rsyslog.conf bearbeiten
local0.* /var/log/smokeping.log
Diese linien müssen in /opt/smokeping/etc/config sein.
# specify this to get syslog logging
syslogfacility = local0
syslogpriority = debug
touch /var/log/smokeping.log
==== Instalar Soporte para FasCGI en Nginx (CentOS 6.X) ====
wget https://codeload.github.com/gnosek/fcgiwrap/legacy.tar.gz/master -O fcgiwrap.tar.gz
tar zxvf fcgiwrap.tar.gz
cd gnosek-fcgiwrap-66e7b7d
autoreconf -i
./configure
make
make install
Datei /etc/sysconfig/spawn-fcgi bearbeiten.
OPTIONS="-u nginx -g nginx -a 127.0.0.1 -p 9001 -P /var/run/spawn-fcgi.pid -- /usr/local/sbin/fcgiwrap"
chkconfig spawn-fcgi on
service spawn-fcgi start
==== Instalar Nginx en Centos 6.X ====
Agregamos el repositorio creando el fichero ///etc/yum.repos.d/nginx.repo//
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/6/$basearch/
gpgcheck=0
enabled=1
yum install nginx
==== Configuración básica de Nginx para Smokeping ====
Hacemos un backup de la configuración predeterminada actual.
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf_backup
Creamos el fichero ///etc/nginx/conf.d/default.conf//
server {
listen 80;
server_name pollux.dominio localhost;
root /opt/smokeping/htdocs;
# access_log /var/www/logs/example.com.access.log;
location / {
index smokeping.fcgi;
}
location ~ \.pl|cgi|fcgi$ {
try_files $uri =404;
gzip off;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index smokeping.fcgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
service nginx start
chkconfig nginx on
==== Configuración básica de Smokeping ====
**Hosts a configurar**:
* pollux.dominio (Donde tenemos alojado Smokeping)
* chimera.dominio
* jirastag.dominio
Fichero de configuración: ///opt/smokeping/etc/config//
*** General ***
owner = Popoch Company
contact = admin@dominio
mailhost = my.mail.host
sendmail = /usr/sbin/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
imgcache = /opt/smokeping/htdocs/cache
imgurl = cache
datadir = /opt/smokeping/data
piddir = /opt/smokeping/var
cgiurl = http://pollux.dominio/smokeping.fcgi
smokemail = /opt/smokeping/etc/smokemail.dist
tmail = /opt/smokeping/etc/tmail.dist
# Specify this to get syslog logging
syslogfacility = local0
syslogpriority = debug
*** Alerts ***
to = admin@dominio
from = smokealert@dominio
+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times in a row
*** Database ***
step = 300
pings = 20
# consfn mrhb steps total
AVERAGE 0.5 1 1008
AVERAGE 0.5 12 4320
MIN 0.5 12 4320
MAX 0.5 12 4320
AVERAGE 0.5 144 720
MAX 0.5 144 720
MIN 0.5 144 720
*** Presentation ***
template = /opt/smokeping/etc/basepage.html.dist
+ charts
menu = Charts
title = The most interesting destinations
++ stddev
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation
format = Standard Deviation %f
++ max
sorter = Max(entries=>5)
title = Top Max Roundtrip Time
menu = by Max
format = Max Roundtrip Time %f seconds
++ loss
sorter = Loss(entries=>5)
title = Top Packet Loss
menu = Loss
format = Packets Lost %f
++ median
sorter = Median(entries=>5)
title = Top Median Roundtrip Time
menu = by Median
format = Median RTT %f seconds
+ overview
width = 600
height = 50
range = 10h
+ detail
width = 600
height = 200
unison_tolerance = 2
"Last 3 Hours" 3h
"Last 30 Hours" 30h
"Last 10 Days" 10d
"Last 400 Days" 400d
*** Probes ***
+ FPing
binary = /usr/sbin/fping
*** Slaves ***
secrets=/opt/smokeping/etc/smokeping_secrets.dist
+boomer
display_name=boomer
color=0000ff
+slave2
display_name=another
color=00ff00
*** Targets ***
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of Popoch Company. \
Here you will learn all about the latency of our network.
+ Empresa de moda
menu= Targets
++ Pollux
menu = Pollux
title =Server pollux.dominio
host = pollux.dominio
++ Cacti
menu = Cacti
title =Server chimera.dominio
host = chimera.dominio
++ JiraStag
menu = Jira_stag
title =Server jirastag.dominio
host = jirastag.dominio
==== Asignando permisos y configurando smokeping para que arranque al inicio del sistema ====
chown -R nginx:nginx /opt/smokeping/htdocs/cache/
chkconfig smokeping on
service smokeping start