| 1 | Programme Opérations de registre avancées |
|---|
| 2 | |
|---|
| 3 | Utilisation de Swatch |
|---|
| 4 | --------------------- |
|---|
| 5 | |
|---|
| 6 | 1. Nous allons faire en sorte que tout puisse être consigné dans un fichier journal unique : |
|---|
| 7 | |
|---|
| 8 | - Editez /etc/syslog-ng/syslog-ng.conf et ajoutez ceci à la fin : |
|---|
| 9 | |
|---|
| 10 | destination everything { |
|---|
| 11 | file("/var/log/everything" |
|---|
| 12 | template("$DATE <$FACILITY.$PRIORITY> $HOST $MSG\n") template_escape(no) |
|---|
| 13 | ); |
|---|
| 14 | }; |
|---|
| 15 | log { source(s_all); destination(everything); }; |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | ... ceci permettra d'enregistrer TOUS les messages dans un fichier unique et d'exécuter un script de supervision sur les messages. |
|---|
| 19 | |
|---|
| 20 | 2. Activez un script automatisé quotidien afin de tronquer le fichier journal afin d'éviter qu'il ne devienne trop gros : |
|---|
| 21 | |
|---|
| 22 | Créez le fichier /etc/logrotate.d/everything |
|---|
| 23 | |
|---|
| 24 | /var/log/everything { |
|---|
| 25 | daily |
|---|
| 26 | copytruncate |
|---|
| 27 | rotate 1 |
|---|
| 28 | postrotate |
|---|
| 29 | /etc/init.d/swatch restart |
|---|
| 30 | endscript |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | 2. Installez swatch : |
|---|
| 35 | |
|---|
| 36 | # apt-get install swatch |
|---|
| 37 | |
|---|
| 38 | 3. Créez le fichier /etc/swatch.conf et copiez ceci dans ce fichier : |
|---|
| 39 | |
|---|
| 40 | watchfor /PRIV_AUTH_PASS/ |
|---|
| 41 | mail=tldadmin,subject=Enable mode entered |
|---|
| 42 | threshold type=limit,count=1,seconds=3600 |
|---|
| 43 | |
|---|
| 44 | watchfor /CONFIG_I/ |
|---|
| 45 | mail=tldadmin,subject=Router config |
|---|
| 46 | threshold type=limit,count=1,seconds=3600 |
|---|
| 47 | |
|---|
| 48 | watchfor /LINK-3-UPDOWN/ |
|---|
| 49 | mail=tldadmin,subject=Link state change |
|---|
| 50 | threshold type=limit,count=1,seconds=3600 |
|---|
| 51 | |
|---|
| 52 | 4. Lancez swatch : |
|---|
| 53 | |
|---|
| 54 | # swatch -c /etc/swatch.conf --daemon |
|---|
| 55 | |
|---|
| 56 | Vérifiez qu'il s'exécute : |
|---|
| 57 | |
|---|
| 58 | # ps ax | grep swatch |
|---|
| 59 | |
|---|
| 60 | 5. Ouvrez une session sur votre routeur et exécutez quelques commandes "config". |
|---|
| 61 | |
|---|
| 62 | 6. Vérifiez que les courriers électroniques arrivent : |
|---|
| 63 | |
|---|
| 64 | # mutt -f /var/mail/tldadmin |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|