jeudi 25 octobre 2012

Candy, chat are no dead yet

Candy est un chat en javascript qui semble très flexible et dispose de plus en plus de plugin.
http://candy-chat.github.com/candy/


Il s'intègre bien avec Openfire même si c'est un peu compliqué la première fois.
Je l'ai par exemple couplé avec Openfire, lui même couplé avec le LDAP de Zimbra pour créer un chat room pour les utilisateurs.

Config Openfire


Dans la paramètres du serveur activé HTTP Binding.
Activlé les ports 7070 et 7443.
Activé le script syntax : Allows BOSH.
Laisser ar défaut la Cross-domain policy.

Installation Candy


Télécharger Candy dans votre répertoire www.
Définir votre vhost.
La difficulté est dans Rewrite rule

RewriteRule http-bind/ http://monserver.com:7070/http-bind/ [P]


Config vhost


<VirtualHost *:8081>
ServerName mon.server.com
DocumentRoot /var/www/candy/
<Directory />
                Options FollowSymLinks
                AllowOverride All
</Directory>
<Directory /var/www/candy>
               Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Order allow,deny
              allow from all
</Directory>
             AddDefaultCharset UTF-8
            Options +MultiViews
            RewriteEngine On
            RewriteRule http-bind/ http://monserver.com:7070/http-bind/ [P]
</VirtualHost>

Config cany/index.html 


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Candy - Chats are not dead yet</title>
<link rel="shortcut icon" href="res/img/favicon.png" type="image/gif" />
<link rel="stylesheet" type="text/css" href="res/default.css" />
<link rel="stylesheet" type="text/css" href="candy-chat-candy-plugins-e9310e4/colors/candy.css" />
        <link rel="stylesheet" type="text/css" href="candy-chat-candy-plugins-e9310e4/roomPanel/default.css" />
        <link rel="stylesheet" type="text/css" href="candy-chat-candy-plugins-e9310e4/inline-images/candy.css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="libs/libs.min.js"></script>
<script type="text/javascript" src="candy.min.js"></script>
<script type="text/javascript" src="candy-chat-candy-plugins-e9310e4/colors/candy.js"></script>
        <script type="text/javascript" src="candy-chat-candy-plugins-e9310e4/inline-images/candy.js"></script>
        <script type="text/javascript" src="candy-chat-candy-plugins-e9310e4/roomPanel/roomPanel.js"></script>

<script type="text/javascript">
$(document).ready(function() {
Candy.init( 'http://monserveur.com/http-bind/', {
core: { debug: false, autojoin: ['info@conference.monserver.com' ]},
view: { resources: 'res/', language: 'fr'}
});

// enable Colors plugin (default: 8 colors)
                        CandyShop.Colors.init();
CandyShop.InlineImages.init();
// enable RoomPanel plugin
                        CandyShop.RoomPanel.init({
                                // domain that hosts the muc rooms, only required if autoDetectRooms is enabled
                                mucDomain: 'info.monserver.com',

                                // allow you to force a list of rooms, only required if autoDetectRoom is disabled
                                roomList: [
                                       {
                                                name: 'info',
                                                jid:  'info@monserver.com'
                                        },
                                                                       ],
                                // show room list if all rooms are closed, default value is true. [optional]
                                showIfAllTabClosed: true,
                                // detect rooms before showing list, default value is true. [optional]
                                autoDetectRooms: true,
                                // how long in seconds before refreshing room list, default value is 600. [optional]
                                roomCacheTime: 600
                        });
Candy.Core.connect();
});
</script>
</head>
<body>
<div id="candy"></div>
</body>
</html>

Merci à Candy


Le support est assuré au travers de google group, la communauté Candy est très active.
Merci à eux.
https://groups.google.com/forum/#!forum/candy-chat


vendredi 5 octobre 2012

Zabbix superviser Postfix

Superviser Postfix pour éviter par exemple que des emails restent bloquer sans s'en appercevoir.
Recette: un zabbix, un template, un petit script et l'erreur est corrigée.

Zabbix Postfix Template

Template Zabbix-Postfix
Les items, 2 triggers et un graph détaillant les items. Ce template est ccompatible Zabbix 2.0

Installer les outils

Installer sur les serveurs les outils suivants : pflogsumm et logcheck

Config Zabbix agent

Pour récupérer l'était de la queue, on déclare un Userparmeter qui exécutera la commande suivante ;

UserParameter=postfix.mailq,mailq | grep -v "Mail queue is empty" | grep -c '^[0-9A-Z]'

Script Zabbix-Postfix

Créer le script suivant qui une fois les logs analyser, envoi les données au moyen de zabbix_sender au serveur qui actualisera les items correspodants.
#!/bin/bash +x
PFLOGSUMM=/usr/sbin/pflogsumm.pl
MAILLOG=/var/log/mail.log
LOGTAIL=/usr/sbin/logtail
DAT1=/tmp/zabbix-postfix-offset.dat
DAT2=$(mktemp)
ZABBIX_SENDER=/usr/bin/zabbix_sender
ZABBIX_HOST=monserver #même nom que dans Zabbix
ZABBIX_SERVER=monserverzabbix.com
ZABBIX_CONF=/etc/zabbix/zabbix_agentd.conf
DEBUG=0

function zsend {
 key="postfix.`echo "$1" | tr ' -' '_' | tr '[A-Z]' '[a-z]' | tr -cd [a-z_]`"
 value=`grep -m 1 "$1" $DAT2 | awk '{print $1}'`

 [ ${DEBUG} -ne 0 ] && echo "Send key \"${key}\" with value \"${value}\"" >&2
 $ZABBIX_SENDER -s $ZABBIX_HOST -z $ZABBIX_SERVER -c $ZABBIX_CONF -k "${key}" -o "${value}" 2>&1 >/dev/null
}

$LOGTAIL -f $MAILLOG -o $DAT1 | $PFLOGSUMM -h 0 -u 0 --bounce_detail=0 --deferral_detail=0 --reject_detail=0 --no_no_msg_size --smtpd_warning_detail=0 > $DAT2

zsend received
zsend delivered
zsend forwarded
zsend deferred
zsend bounced
zsend rejected
zsend held
zsend discarded
zsend "reject warnings"
zsend "bytes received"
zsend "bytes delivered"
zsend senders
zsend recipients

rm $DAT2

Automatiser le script

Toutes les minutes

* * * * * /etc/zabbix/zabbix-postfix.sh

Astuce supprimer les emails bloqués en queue

# perl -e 'foreach (`postqueue -p`) {`postsuper -d $1` if /^([0-9A-Z]+)/}'


Remerciements

http://blog.hbis.fr/2012/03/30/zabbix-postfix_monitoring/
http://www.zabbix.com/wiki/howto/monitor/mail/postfix/monitoringpostfix