Logwatch

De Le Wiki du Forum-Debian.fr
Aller à la navigation Aller à la recherche

Logwatch est un utilitaire permettant de surveiller les journaux système et de créer des rapports. Ces rapports comprennent les tentatives de connexion infructueuses, les tentatives de connexion réussie, l'espace de stockage utilisé/disponible, les erreurs de kernel, etc.

Mettre son système à jour

Ce n'est pas mauvais de le rappeler encore une fois, un système à jour est plus sécurisé!

apt-get update
apt-get upgrade

Installez Logwatch

Passer la commande suivante pour installer logwatch:

apt-get install logwatch

Par défaut Logwatch installe Postfix si vous n'avez pas de service SMTP installé. Lorsque ce sera demandé, sélectionnez la configuration "Internet Site".

Si vous préférez Exim, (re)installez-le au préalable.

Configurez Logwatch

Une fois installé vous aurez à faire une configuration minimale de logwatch.

Les options sont nombreuses, je vous encourage à lire le man

nano /usr/share/logwatch/default.conf/logwatch.conf
Output = mail
Format = text
MailTo = root (ou tout autre adresse fonctionnelle)
MailFrom = logwatch@votredomaine.org (ou tout autre adresse fonctionnelle)

Le format html

A l'heure ou j'écrit, le paquet logwatch 7.3.6.cvs20090906-1squeeze1 contient un bug (pas trop gênant...): il manque les fichiers pour le format html.

Vous pouvez tout de même facilement utiliser le format html. Il suffit de créer les fichiers suivants:

nano /usr/share/logwatch/default.conf/html/footer.html


Logwatch ©Copyright 2002-2006 Kirk Bauer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

</body></html>

nano /usr/share/logwatch/default.conf/html/header.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>Logwatch $Version ( $VDate )</title> <meta name="generator" content="Logwatch $Version ( $VDate )"> <style type="text/css">

 h1 {color: gray; border-bottom: 3px double silver}
 h2,h3 {color: gray; border-bottom: 1px solid silver}
 .ref {padding-left: 1%}
 .service {padding-left: 1%; font-family: Monospace}
 .return_link {border-top: 1px; border-bottom: 1px;
 padding: 1%; margin-top: 1%; margin-bottom: 1%;}
 .copyright {color: black; border-top: 1px solid grey;
 border-bottom: 1px solid grey;
 padding: 1%; margin-top: 1%; margin-bottom: 1%;}

</style> </head> <body style="width:90%; margin-left: 5%; margin-right: 5%" bgcolor="#FFFFFF">


Et de remplacer

Format = text

par

Format = html

Vérifiez le fonctionnement

Tapez la commande suivante pour tester l'installation

logwatch

Allez vérifier ensuite vos mails pour vous assurer qu'il est bien arrivé. Vérifiez votre boite à spam si nécessaire...

Vous devriez recevoir un mail du système:

################### Logwatch 7.3.6 (05/19/07) #################### 
       Processing Initiated: Fri Aug  5 11:16:24 2011
       Date Range Processed: yesterday
                             ( 2011-Aug-04 )
                             Period is day.
       Detail Level of Output: 0
       Type of Output/Format: mail / text
       Logfiles for Host: vanille.zehome.org
 ################################################################## 

Ou un beau mail au format HTML.









Cron

Vérifiez que la tâche cron est bien activée Vous devriez avoir une tâche journalière automatiquement créée:

root@vanille:~# cat /etc/cron.daily/00logwatch

  1. !/bin/bash
  1. Check if removed-but-not-purged

test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0

  1. execute

/usr/sbin/logwatch --output mail

  1. Note: It's possible to force the recipient in above command
  2. Just pass --mailto address@a.com instead of --output mail

Lol 5 août 2011 à 03:57 (CDT)