May 02

Send email notifications from supervisord

Reading time: 1 – 2 minutes

There is a package called superlance which listens supervisord events. If you install it with:

pip install superlance

Then it’s very easy to setup supervisord to send emails when a daemon changes the state because of a crash or something else.

Lines to add to supervisord configuration file:

command=/usr/local/bin/crashmail -a -m

if you want to send notifications only for some applications:

command=/usr/local/bin/crashmail -p program1 -p group1:program2 -m

Of course, superlance can listen many different event signals from supervisor and can take different actions like call to HTTP URL or send SMS. I want to recommend you to take look to the package documentation it could be useful to understand all the superlance power.

May 01

Relay mail from your server without MTA

Reading time: < 1 minute Sometime you need to send notifications or simply you need to use sendmail command from your server, but you don't want to use a local mail server. Maybe use simple SMTP (ssmtp) could be a good idea to solve this kind of situations. I use to configure SSMTP with a GMail account to send notifications from server different daemons, for example, crontab, supervisord, etc. This is a cookbook configuration for SSMTP and GMail: /etc/ssmtp/ssmtp.conf


Installation in ubuntu server is as easy as: apt-get install ssmtp

Feb 25

Setup a VPN with PPP and SSH

Reading time: < 1 minute Fast trick for linux users, do you know how to setup a VPN using PPP and SSH? of course you can setup a secure tunnel using '-w- or '-W' ssh parameters in last versions of SSH. But in this case I want to share with you this idea:

pppd updetach pty “ssh root@REMOTE_PUB_IP pppd notty”

I hope it’s useful for you.

Dec 21

timegrep: Very useful grep tool

Reading time: < 1 minute Specially when you have to look up inside Postfix logs or Syslog in general it could be the swiss knife tool you need: timegrep.

You have to know that the tool is developed using Python. And is very easy to upgrade or fork the code.

Mar 11


Reading time: < 1 minute Really useful command of ssh package to add public key of your user account to a remote SSH server and then access there with passwordless authentication method. ssh-copy-id [-i [identity_file]] [user@]machine

In the past I wrote a simple cookbook to explain this process but now this is as simple as possible. Don’t forget ssh-copy-id is the most easy way to add your ssh public key in remote servers.

Mar 08

Getting help to configure spamassassin.conf

Reading time: < 1 minute Configure spamassassin is never easy to do. But when you look for information in Google usually you will be mad . The most common help method in linux is use 'man command' but it doesn't work or information is not enough usually. After a lucky search I found this command to get an extended information about how to configure spamassassin.conf file.

perldoc Mail::SpamAssassin::Conf

Nov 18

CLI de Xen

Reading time: 2 – 2 minutes

Aquesta setmana he tingut un expedient X’s amb el servidor d’ que tinc virtualitzat en un servidor de Xen. La qüestió és que segons Xen la màquina estava corrent normal però encanvi no podia accedir ni a la consola ni enlloc. Ja que la màquina no estava a la llista de processesos del sistema. Així doncs, després de més d’1any he hagut d’aprendre alguna comanda de Xen CLI per poder solucionar el problema.

Per obtenir la llista de màquines virtuals que té el sistema:

xe vm-list

amb aquesta comanda podem obtenir el uuid, aquest identificador ens serà útil per poder forçar la màquina perquè es pari. Això ho podem fer així:

xe vm-reset-powerstate uuid=XXXXXXXXXXXXXXX force=true

En cas de que la comandi falli, per exemple, amb un error de:

The operation could not be performed because a domain still exists for the specified VM.                                                               
vm: XXXXXXXXXXXXXXX (nom_servidor)
domid: 1

Llavors podem eliminar el domini que ens causa problemes així:

/opt/xensource/debug/destroy_domain -domid 1

Si la comanda no retorna error vol dir que hem pogut eliminar el domini i ja podem tornar a executar la comanda xe vm-reset-powerstate.

Gràcies a això he pogut fer-li entendre al Xen server que la màquina estava parada i des de la GUI he tornat a iniciar la màquina sense problemes. En el meu cas aquesta anomalia s’havia donat degut a que el sistema s’havia quedat sense memòria, o sigui, que entenc que hi hauria alguna part del hypervisor que tindria leaks de memòria.