Archive for the ‘syslog’ tag
Command to check a Syslog server status from Nagios
I’ve been using Nagios for a long time and now I have to check a Syslog server. I was looking for a command to check directly a remote Syslog server.
I didn’t find anything that fit my needs so I did one by myself.
To use this command, the Syslog server has to bee listening on the UDP 514 port. It’s only made to check Syslog servers that are available on a network.
The process is simple:
- The script sends a message to the syslog server
- The script start a small UDP server on localhost
- The remote syslog server receives the message and sends it back to the server where the script was executed from
- The script UDP server receives the message and check if it is correct
The Syslog server needs to know how to match the specific message from the check script and send it back to the source script, so it needs a small previous configuration.
The code is hosted in github. There you cand find detailed information about how to run this script and how to configure a Syslog server in the README file.
http://github.com/lbosque/check_syslog
You can also clone directly the repository and see the README with your favourite editor:
git://github.com/lbosque/check_syslog.git
Soporte de Syslog para Nginx
Estos días tenía la necesidad de hacer que nginx mandase sus logs al syslog local.
Nginx no tiene soporte nativo para usar syslog. Puede escribir los logs o en fichero o mandarlos a un pipe.
Estuve bsucando y encontré un parche de la versión 0.6.31 que resuelve el problema. Aquí habla también un poco del parche.
A pesar de que en ese último link explica por encima como hacerlo, lo voy a contar yo también.
- Bajamos la versión 0.6.31 de nginx en http://sysoev.ru/nginx/nginx-0.6.31.tar.gz. Según el comentario de Marlon (el creador del parche) debería funcionar también con las versiones 0.6.30 y 0.6.29, y mirando los changelogs pienso que tambíen debería funcionar en la última que es la 0.6.32. Si alguien lo prueba que me lo diga.
- Descomprimimos:
# cd /usr/src/ # tar xvzf nginx-0.6.31.tar.gz
- Bajamos el parche:
# wget http://bugs.gentoo.org/attachment.cgi?id=153345 -O nginx_syslog.patch
- Parcheamos:
# patch -p0 < nginx_syslog.patch
- Compilamos e instalamos nginx:
# cd nginx-0.6.31 # ./configure --with-syslog # make # make install
CFLAGS="$CFLAGS -Werror"
por:
CFLAGS="$CFLAGS"
Esto únicamente hace que no se rompa la compilación al encontrar algun warning. En mi caso los warning que lanza la compilación se pueden ignorar tranquilamente, por lo que resulta seguro continuar con ellos.
Si todo ha ido bien deberíamos de tener funcionando nginx. Faltaría unicamente configurarlo y ponerlo en marcha. En el fichero de configuración no hace falta indicar nada para que mande correctamente los logs al syslog. Por defecto los manda a la facility daemon.
Yo lo he probado ya en servidores en producción y por el momento funciona estupendamente.
Desde aquí agradezco el esfuerzo a Marlon de Boer, que no he conseguido encontrar un blog suyo donde hacerlo.