Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
utilisateurs:draco31.fr:brouillon [Le 14/11/2010, 02:35]
draco31.fr
utilisateurs:draco31.fr:brouillon [Le 19/08/2012, 23:16] (Version actuelle)
draco31.fr
Ligne 1: Ligne 1:
-====== Ceci est ma page BROUILLON !! ======+====== ​∴☆★ ​Ceci est ma page BROUILLON !! ★☆∴ ​======
  
-===== Test box =====+===== NUT & upsmon & upssched ​=====
  
-==== Page imprimantes ​====+==== Monitorer les événements de l'UPS avec upsmon ​====
  
-  * v0 -- Version Frombenny, page imprimante :+=== Configuration par défaut ===
  
-<​note>​Aucun problème si fenêtre redimensionnée !\\ Problème si page zoomée : texte tronqué ​!</​note>​+Par défaut, toutes les types d’événements sont associés aux directives **SYSLOG** (écriture dans ''/​var/​log/​syslog''​) et **WALL** (notification aux utilisateurs par les terminaux). 
 +<​note ​warning>FIXME Sous Ubuntu, la notification par la commande **''​wall''​** ne semble pas fonctionner ​!</​note>​
  
 +Le fichier **''/​etc/​nut/​upsmon''​** contient donc les lignes suivantes :
 +<​file>​
 +NOTIFYFLAG ONLINE ​   SYSLOG+WALL
 +NOTIFYFLAG ONBATT ​   SYSLOG+WALL
 +NOTIFYFLAG LOWBATT ​  ​SYSLOG+WALL
 +NOTIFYFLAG FSD       ​SYSLOG+WALL
 +NOTIFYFLAG COMMOK ​   SYSLOG+WALL
 +NOTIFYFLAG COMMBAD ​  ​SYSLOG+WALL
 +NOTIFYFLAG SHUTDOWN ​ SYSLOG+WALL
 +NOTIFYFLAG REPLBATT ​ SYSLOG+WALL
 +NOTIFYFLAG NOCOMM ​   SYSLOG+WALL
 +NOTIFYFLAG NOPARENT ​ SYSLOG+WALL
 +</​file>​
  
-<box 100% center #​FFFFFF><​box 100px round left #dcf0ea>**[[:​imprimantes_brother|Brother]]**<​/box> +Dans **''​/var/log/syslog''​**, on obtient un message préformaté. Exemple ​: 
-<box 100px round left #​dcf0ea>​**[[:​tutoriel/installer_imprimante_canon|Canon]]**<​/box> +<file
-<box 100px round left #dcf0ea>**[[:tutoriel/​installer_imprimante_compaq|Compaq]]**</box+Aug 19 21:49:34 localhost upsmon[7784]Startup successful 
-<box 100px round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_dell| Dell]]**</​box>​ +Aug 19 21:50:24 localhost upsmon[7786]UPS localups@localhost on battery 
-<box 100px round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_epson|Epson]]**</​box>​ +Aug 19 21:50:34 localhost upsmon[7786]: Poll UPS [localups@localhostfailed - Data stale 
-<box 100px round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_hp|HP]]**</​box>​ +Aug 19 21:50:34 localhost upsmon[7786]Communications with UPS localups@localhost lost 
-<box 150px round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_konica|Konica/​Minolta]]**</​box>​ +Aug 19 21:50:39 localhost upsmon[7786]Communications with UPS localups@localhost established 
-<box 100px round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_lexmark|Lexmark]]**</​box>​ +Aug 19 21:50:39 localhost upsmon[7786]: UPS localups@localhost on line power 
-<box 100px round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_ricoh|Ricoh]]**</​box>​ +</file>
-<box 100px round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_samsung|Samsung]]**</​box>​ +
-<box 100px round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_xerox|Xerox]]**</​box>​</box>+
  
-Texte ...+<​note>//​Dans l'​exemple ci-dessus ''​localups''​ est le libellé associé à l'​onduleur dans le fichier **''/​etc/​nut/​ups.conf''​**//</​note>​
  
-----+=== Utilisation d'un script via l'​option NOTIFYCMD et la directive EXEC===
  
-  ​v1 -- Mini box 10 x 7% + 1 x 14%+Il est possible en plus ou la place des directives WALL et SYSLOG, d'​utiliser la directive ​**''​EXEC''​** pour lancer un script définit par l'​option **''​NOTIFYCMD''​** pour réaliser un traitement personnalisé.
  
-<​note>​Problème si fenêtre redimensionnée : texte tronqué !\\ Problème si page zoomée : texte tronqué ​!</​note>​+Le fichier de configuration **''/​etc/​nut/​upsmon.conf''​** contiendra donc la ligne : 
 +<​file>​ 
 +NOTIFYCMD /​usr/​local/​bin/​upsalert.sh 
 +</​file>​ 
 +<​note ​tip>Le chemin ''/​usr/​local/​bin/​upsalert.sh''​ est à remplacer par celui votre script ​!</​note>​
  
-<box 100% center #​FFFFFF>​ +Les options NOTIFYFAG concernée par ce traitement personnalisée doivent avoir la directive EXEC. Exemple pour ''​ONLINE''​ et ''​ONBATT''​ et ''​LOWBATT'' ​
-<box 7% round left #​dcf0ea>​**[[:imprimantes_brother|Brother]]**</​box>​ +<file
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_canon|Canon]]**</​box+NOTIFYFLAG ONLINE ​   SYSLOG+WALL+EXEC 
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_compaq|Compaq]]**</​box>​ +NOTIFYFLAG ONBATT ​   SYSLOG+WALL+EXEC 
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_dell| Dell]]**</​box>​ +NOTIFYFLAG LOWBATT ​  ​SYSLOG+WALL+EXEC 
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_epson|Epson]]**</​box>​ +NOTIFYFLAG FSD       ​SYSLOG+WALL 
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_hp|HP]]**</​box>​ +NOTIFYFLAG COMMOK ​   SYSLOG+WALL 
-<box 14% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_konica|Konica/​Minolta]]**</​box>​ +NOTIFYFLAG COMMBAD ​  ​SYSLOG+WALL 
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_lexmark|Lexmark]]**</​box>​ +NOTIFYFLAG SHUTDOWN ​ SYSLOG+WALL 
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_ricoh|Ricoh]]**</​box>​ +NOTIFYFLAG REPLBATT ​ SYSLOG+WALL 
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_samsung|Samsung]]**</​box>​ +NOTIFYFLAG NOCOMM ​   SYSLOG+WALL 
-<box 7% round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_xerox|Xerox]]**</​box>​ +NOTIFYFLAG NOPARENT ​ SYSLOG+WALL 
-</box>+</file>
  
-Texte ...+FIXME Le script reçoit en argument le même libellé que ce qui est tracé dans ''/​var/​log/​syslog''​.
  
-----+== Notification par mail ==
  
-  * v2 -- Mini box ~ 1em lettre+<note warning>​Votre modem ainsi que vos équipements réseaux reliant ce dernier au PC hébergeant upsmon serveur (relié à l'​onduleur) et upsmon client (celui exécutant le script) doivent aussi être alimentés pour pouvoir envoyer le mail au moment opportun. Dans le cas contraire, vous risquez de ne recevoir le mail que lorsque le courant revient, voir de ne pas recevoir le mail du tout !!</note>
  
-<​note>​Aucun problème si fenêtre redimensionnée !\\ Aucun problème si page zoomée !</​note>​+** Choix d'un MTA accessible en console **
  
-<box 100% center #​FFFFFF>​ +Plusieurs MTA (mail transfert agent) accessible en console sont disponibles dans les dépôts. Parmi ceux-ci on notera ​
-<box 6em round left #​dcf0ea>​**[[:imprimantes_brother|Brother]]**</​box>​ +  * [[:ssmtp]] : Très simple d'​utilisation 
-<box 5em round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_canon|Canon]]**</​box>​ +  * [[:mutt]] : plus évolué que ''​ssmtp''​ et ligne de commande plus complexe 
-<box 6em round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_compaq|Compaq]]**</​box>​ +  * [[:postfix]] : le plus puissant, mais aussi plus compliqué à configurer !
-<box 4em round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_dell|Dell]]**</​box>​ +
-<box 5em round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_epson|Epson]]**</​box>​ +
-<box 3em round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_hp|HP]]**</​box>​ +
-<box 10em round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_konica|Konica/​Minolta]]**</​box>​ +
-<box 7em round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_lexmark|Lexmark]]**</​box>​ +
-<box 5em round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_ricoh|Ricoh]]**</​box>​ +
-<box 7em round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_samsung|Samsung]]**</​box>​ +
-<box 5em round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_xerox|Xerox]]**</​box>​ +
-</​box>​+
  
-Texte ...+** Installation et configuration avec SSMTP **
  
-----+Exemple avec ''​ssmtp''​ : 
 +  * [[:​tutoriel:​comment_installer_un_paquet|Installer le paquet]] **[[apt>​ssmtp]]** 
 +  * [[:​tutoriel:​comment_modifier_un_fichier|Modifier le fichier]] **''/​etc/​ssmtp/​ssmtp.conf''​** suivant l'​exemple ci-dessous :<​file>​ 
 +root=mon-adresse-email@mon-fai.fr 25 
 +mailhub=smtp.fai.fr 
 +hostname=ubuntu-desktop 
 +FromLineOverride=YES 
 +</​file>​ 
 +  * Depuis un [[:​terminal]],​ faites un essai avec la commande ci-dessous :<​code>​ssmtp <​mon-adresse-email@mon-fai.fr></​code>​entrez le texte suivant :<​code>​From:​ mon-adresse-email@mon-fai.fr 
 +Subject: Test envoi mail avec ssmtp 
 +Test réussi ! Bravo ! 
 +</​code>​et enfin, appuyez sur la combinaison CTRL+D pour terminer la saisie et envoyer le mail.
  
-  ​v2bis -- Mini box ~ 2ex / lettre+** Création du script de notification mail **
  
-<​note>​Aucun problème si fenêtre redimensionnée !\\ Aucun problème si page zoomée !</​note>​+<​note> ​A METTRE EN FORME --- Brouillon</note
 +Créer un fichier pour l'​entête avec une ligne From: ; To: ; Subject: : Ces données sont invariantes dans le message. 
 +Créer le script contenant les lignes : 
 +<​code>#​!/​bin/​bash 
 +echo "​$@"​ | cat </​chemin/​fichier/​entête>​ - | ssmtp <​mon-adresse-mail@mon-fai.fr>​ 
 +</code>
  
-<box 100% center #​FFFFFF>​ +FIXME Non testé ​à vérifier si ça marche bien :p
-<box 12ex round left #​dcf0ea>​**[[:imprimantes_brother|Brother]]**</​box>​ +
-<box 10ex round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_canon|Canon]]**</​box>​ +
-<box 12ex round left #​dcf0ea>​**[[:tutoriel/​installer_imprimante_compaq|Compaq]]**</​box>​ +
-<box 8ex round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_dell|Dell]]**</​box>​ +
-<box 10ex round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_epson|Epson]]**</​box>​ +
-<box 6ex round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_hp|HP]]**</​box>​ +
-<box 20ex round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_konica|Konica/​Minolta]]**</​box>​ +
-<box 14ex round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_lexmark|Lexmark]]**</​box>​ +
-<box 10ex round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_ricoh|Ricoh]]**</​box>​ +
-<box 14ex round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_samsung|Samsung]]**</​box>​ +
-<box 10ex round left #​dcf0ea>​**[[:​tutoriel/​installer_imprimante_xerox|Xerox]]**</​box>​ +
-</​box>​+
  
-Texte ...+<note tips>​Vous pouvez modifier le libellé par défaut associé à chaque événement dans le fichier upsmon.conf : 
 +<​file>​ 
 +NOTIFYMSG ONLINE "​UPS %s sur secteur.
 +NOTIFYMSG ONBATT "​UPS %s sur batterie.
 +NOTIFYMSG LOWBATT "​UPS %s batterie faible."​ 
 +NOTIFYMSG FSD "​UPS %s: arrêt forcé en cours."​ 
 +NOTIFYMSG COMMOK "​Communications avec l'UPS %s établie."​ 
 +NOTIFYMSG COMMBAD "​Communications avec l'UPS %s perdue."​ 
 +NOTIFYMSG SHUTDOWN "​Déconnexion et arrêt automatiques engagés."​ 
 +NOTIFYMSG REPLBATT "​UPS %s La batterie doit être remplacée."​ 
 +NOTIFYMSG NOCOMM "​UPS %s indisponible."​ 
 +NOTIFYMSG NOPARENT "​mort du processus upsmon parent - arrêt impossible"​ 
 +</​file></​note>​
  
-==== Attributs ====+=== Utilisation de upssched ​===
  
-  * v2.0 -- unité largeur+Si vous souhaitez effectuer des actions différentes selon le type d'​événement,​ il est préférable d'​utiliser upssched.
  
-<box 100% center|par défaut>​ +fichier upsmon.conf (exemple) :
-<box round left>​n/​a</​box>​ +
-<box round left>​abcdefghijklmnopqrstuvwxyz</​box>​ +
-</​box>​+
  
-<box 100% center|**%** fixe - pourcentage+<file
-<box 10% round left>​10%<​/box> +NOTIFYCMD ​/sbin/upssched
-<box 10% round left>​abcdefghijklmnopqrstuvwxyz<​/box> +
-</​box>​+
  
-<box 100% center|**px** fixe - pixel> +NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC 
-<box 100px round left>​100px</​box>​ +NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC 
-<box 100px round left>​abcdefghijklmnopqrstuvwxyz</​box>​ +NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC 
-</box>+NOTIFYFLAG FSD SYSLOG+WALL+EXEC 
 +NOTIFYFLAG COMMOK SYSLOG+EXEC 
 +NOTIFYFLAG COMMBAD SYSLOG+EXEC 
 +NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC 
 +NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC 
 +NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC 
 +NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC 
 +</file>
  
-<box 100% center|**em** augmente avec le zoom de la page - emphase ?> +Créer ​le fichier ​de config /etc/nut/​upssched.conf 
-<box 10em round left>​10em<​/box> +<file
-<box 10em round left>​abcdefghijklmnopqrstuvwxyz</​box+# the script to be executed 
-</box>+CMDSCRIPT ​/usr/​local/​bin/​upsalert.sh
  
-<box 100% center|**em** augmente avec le zoom de la page - emphase ?> +# mandatory fields that must be set before AT commands 
-<box 26em round left>​26em<​/box> +PIPEFN ​/var/run/​nut/​upssched.pipe 
-<box 26em round left>​abcdefghijklmnopqrstuvwxyz<​/box> +LOCKFN /​var/​run/​nut/upssched.lock
-</box>+
  
-<box 100% center|**ex** augmente avec le zoom de la page ??> +# the timers, here 30 sec after the ONBATT (ups on battery) event 
-<box 10ex round left>​10ex</​box>​ +AT ONBATT ​START-TIMER onbatt-timer 120
-<box 10ex round left>​abcdefghijklmnopqrstuvwxyz</​box>​ +
-</​box>​+
  
-<box 100% center|**ex** augmente avec le zoom de la page - ??> +# cancel the countdown is power is back 
-<box 26ex round left>​26ex</​box>​ +AT ONLINE ​CANCEL-TIMER onbatt-timer
-<box 26ex round left>​abcdefghijklmnopqrstuvwxyz</​box>​ +
-</​box>​ +
-<box 100% center|**pt** fixe point ?> +
-<box 100pt round left>​10pt</​box>​ +
-<box 100pt round left>​abcdefghijklmnopqrstuvwxyz</​box>​ +
-</​box>​+
  
-<box 100% center|**cm** fixe - centimètre>​ +AT COMMBAD ​EXECUTE commbad 
-<box 10cm round left>​10cm</​box>​ +AT COMMOK ​EXECUTE commok 
-<box 10cm round left>​abcdefghijklmnopqrstuvwxyz</​box>​ +AT NOCOMM ​EXECUTE nocomm 
-</box>+AT ONBATT ​EXECUTE onbatt 
 +AT LOWBATT * EXECUTE lowbatt 
 +AT ONLINE * EXECUTE online 
 +AT FSD * EXECUTE fsd 
 +AT SHUTDOWN * EXECUTE shutdown 
 +AT REPLBATT * EXECUTE replbatt 
 +AT NOPARENT * EXECUTE noparent 
 +</file>
  
-<box 100% center|**mm** fixe  - millimètres+Créer le script /​usr/​local/​bin/​upsalert.sh (FIXME exemple à revoir) 
-<box 100mm round left>​100mm<​/box> +<file
-<box 100mm round left>​abcdefghijklmnopqrstuvwxyz<​/box> +#!/bin/bash 
-</​box>​+logfile=/​var/log/ups.log 
 +date=$(date +"%F %T")
  
-<box 100center|**pi** fixe pitch ?+case $1 in 
-<box 10pi round left>10pi</box+    commbad) 
-<box 10pi round left>abcdefghijklmnopqrstuvwxyz<​/box+        echo "$date : UPS communications failure."​ >> $logfile 
-</box>+        ;; 
 +    commok) 
 +        echo "$date : UPS communications restored."​ >> $logfile 
 +        echo "$date :     ​Current status=[$(/​bin/​upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%, Load=$(/​bin/​upsc localups ups.load)%."​ >> $logfile 
 +        sudo /​bin/​upscmd ​-u login -p pwd localups beeper.enable 2>> $logfile 
 +        ;; 
 +    nocomm) 
 +        echo "$date : UPS communications cannot be established." ​>> $logfile 
 +        ;; 
 +    onbatt) 
 +        echo "$date : UPS is on battery. Trying to suspend."​ >> $logfile 
 +        echo "$date :     ​Current status=[$(/bin/upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%,​ Load=$(/​bin/​upsc localups ups.load)%."​ >$logfile 
 +        sudo /bin/upscmd -u login -p pwd localups beeper.mute 120 2>> $logfile 
 +        sudo /usr/​sbin/​pm-suspend-hybrid --quirk-none 2>&1 >> $logfile 
 +        ;; 
 +    onbatt-timer) 
 +        echo "$date : UPS is on battery for more than 2 min. Trying to hibernate."​ >> $logfile 
 +       $echo "$date :     ​Current status=[$(/​bin/​upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%,​ Load=$(/​bin/​upsc localups ups.load)%."​ >> $logfile 
 +        sudo /bin/upscmd -u login -p pwd localups beeper.mute 300 2>> $logfile 
 +        sudo /​usr/​sbin/​pm-hibernate --quirk-none 2&>1 >>​$logfile 
 +        ;; 
 +    lowbatt) 
 +        echo "$date : UPS has a low battery. Current load=$(/​bin/​upsc localups ups.status)%. Trying forced-shutdown."​ >> $logfile 
 +        echo "$date :     ​Current status=[$(/​bin/​upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%,​ Load=$(/​bin/​upsc localups ups.load)%."​ >> $logfile 
 +        sleep 1 
 + sudo /bin/upscmd -u login -p pwd localups beeper.enable 2>> $logfile 
 +        sudo /​sbin/​upsmon -c fsd 2>&1 >> $logfile 
 +        ;; 
 +    online) 
 +        echo "$date : UPS on line. Shutdown aborted."​ >> $logfile 
 +        echo "$date :     ​Current status=[$(/​bin/​upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%,​ Load=$(/​bin/​upsc localups ups.load)%."​ >> $logfile 
 +        sudo /bin/upscmd -u login -p pwd localups shutdown.stop 
 +        sleep 1 
 +        sudo /​sbin/​upsmon -K && echo "$date : WARN : fsd flag is still on !" >> $logfile 
 +        sudo /bin/upscmd -u login -p pwd localups beeper.enable 2>​$logfile 
 +        ;; 
 +    fsd) 
 +        echo "$date : UPS is being forced-shutdown by the master."​ >> $logfile 
 +        echo "$date :     ​Current status=[$(/​bin/​upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%,​ Load=$(/​bin/​upsc localups ups.load)%."​ >> $logfile 
 +        sleep 1 
 +        sudo /bin/upscmd -u login -p pwd localups beeper.mute 300 2>> $logfile 
 +        ;; 
 +    shutdown) 
 +        echo "$date : The system is being shutdown."​ >> $logfile 
 +        echo "$date :     ​Current status=[$(/​bin/​upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%,​ Load=$(/​bin/​upsc localups ups.load)%."​ >> $logfile 
 +        sudo /bin/upscmd -u login -p pwd localups beeper.mute 300 2>> $logfile 
 +        ;; 
 +    replbatt) 
 +        echo "$date : UPS battery is bad and needs to be replaced !!!" >> $logfile 
 +        echo "$date :     ​Current status=[$(/​bin/​upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%,​ Load=$(/​bin/​upsc localups ups.load)%."​ >> $logfile 
 +        sudo /bin/upscmd -u login -p pwd localups beeper.enable 2>> $logfile 
 +        ;; 
 +    noparent) 
 +        echo "$date : The process that shuts down the system has died (shutdown impossible)."​ >> $logfile 
 +        sudo /​sbin/​shutdown -h now 2>&1 >> $logfile 
 +        ;; 
 +    *) 
 +        echo "$date : $0 > Unrecognized command: $1" | tee -a $logfile 1>&​2 
 +        echo "$date :     ​Current status=[$(/​bin/​upsc localups ups.status)],​ Charge=$(/​bin/​upsc localups battery.charge)%,​ Load=$(/​bin/​upsc localups ups.load)%."​ >> $logfile 
 +        ;; 
 +esac 
 +exit 0 
 +</file>
  
-<box 100% center|**in** fixe - inch> +====== Réduire le nombre d'​écriture sur disque pour les log et sauver la vie du SSD Ryan ======
-<box 10in round left>​10in</​box>​ +
-<box 10in round left>​abcdefghijklmnopqrstuvwxyz</​box>​ +
-</​box>​+
  
-<box 100% center|**auto** paramètre inconnu ​idem 50%> +  ​Créer un dossier pour les log permanentes : sudo mkdir -p /​var/​log.hdd/​ 
-<box auto round left>​auto<​/box> +  - Modifier le fichier de config de /etc/logrotate.conf et ajouter la ligne ''​olddir /​var/​log.hdd/''​ : 
-<box auto round left>​abcdefghijklmnopqrstuvwxyz</​box+<file
-</​box>​+# see "man logrotate"​ for details 
 +# rotate log files weekly 
 +weekly
  
-  * v2.0 -- Taille suivant texte :+# keep 4 weeks worth of backlogs 
 +rotate 4
  
-<box 100% center|100% -- Titre> +# create new (empty) log files after rotating old ones 
-<box 10% round left|10%></​box>​ +create
-<box 10% round left|abcdefghijklmnopqrstuvwxyz></​box>​ +
-</​box>​+
  
-<box 100% center|100% -- Texte> +# uncomment this if you want your log files compressed 
-<box 10% round left>​10%</​box>​ +#compress
-<box 10% round left>​abcdefghijklmnopqrstuvwxyz</​box>​ +
-</​box>​+
  
-<box 100% center|100% -- Légende>​ +olddir ​/var/log.hdd/
-<box 10% round left><​/box|10%>​ +
-<box 10% round left><​/box|abcdefghijklmnopqrstuvwxyz>​ +
-</box>+
  
-  * v2.1 -- Mini Box 50% seules+# packages drop log rotation information into this directory 
 +include /​etc/​logrotate.d
  
-<box 50% round left>​50%</​box>​ +# no packages own wtmp, or btmp -- we'll rotate them here 
-<box 50% round left>​50%<​/box>+/var/​log/​wtmp { 
 +    missingok 
 +    monthly 
 +    create 0664 root utmp 
 +    rotate 1 
 +}
  
-\\ \\ \\ \\ \\ \\ +/​var/​log/​btmp { 
 +    missingok 
 +    monthly 
 +    create 0660 root utmp 
 +    rotate 1 
 +}
  
-  * v2.2 -- Mini Box xx% dans box 100%+# system-specific logs may be configured here 
 +</​file>​ 
 +  ​Modifier /etc/fstab pour charge /var/log sur un tmpfs : 
 +<​file>​ 
 +# dossier en RAM (volatile) 
 +tmpfs /​tmp ​           tmpfs ​  ​defaults ​          ​ 0 ​   0 
 +tmpfs     ​ /​var/​tmp ​     tmpfs ​  ​defaults ​   0 ​     0 
 +tmpfs     ​ /​var/​lock ​     tmpfs ​  ​defaults ​   0 ​     0 
 +tmpfs /​var/​log tmpfs defaults 0 0 
 +</​file>​
  
-<box 100% center|100%> +<note important>Il est possible de s'​arrêter là, si le système est rarement rebooté, et que l'on accepte de perdre les logs depuis la dernière rotation</note>
-<box 50% round left>​50%</​box>​ +
-<box 50% round left>​50%</​box>​ +
-</box>+
  
-<box 100% center|100%>​ +=== Mod easy ===
-<box 40% round left>​40%</​box>​ +
-<box 40% round left>​40%</​box>​ +
-<box 40% round left>​40%</​box>​ +
-</​box>​+
  
-<box 100% center|100%> +<note tip>FIXME devrait bien marcher pour systèmes avec peu de reboot, et permet de ne perdre aucun log !!</note>
-<box 30% round left>​30%</​box>​ +
-<box 30% round left>​30%</​box>​ +
-<box 30% round left>​30%</​box>​ +
-<box 30% round left>​30%</​box>​ +
-</box>+
  
-<box 100% center|100%>​ +  - FIXME Créer un script dans /​etc/​init.d/​ qui appele logrotate en mode forcé pour recopier les log dans /var/log.hdd si appelé avec ''​stop''​ 
-<box 25% round left>​25%<​/box> +<code>#!/bin/sh 
-<box 25% round left>25%</box> +case "​$1"​ in 
-<box 25% round left>​25%<​/box> +stop) 
-<box 25% round left>25%</box+logrotate -f /etc/logrotate.conf 
-</box>+;; 
 +*) 
 +#no-op 
 +;; 
 +esac 
 +exit 0 
 +</code
 +  - Lier le script dans /etc/​rc0.d/​S39savelogs
  
-==== Modulation sur box 25% ====+> Le mieux serait de faire un service qui écoute le bon événement et ferait la manip juste avant le démontage (S40umountfs).
  
------+<note warning>​Cela ne respecte pas les règles logrotate (daily, weekly ...) donc risque de perdre rapidement des données si peu de génération sont conservées pour un fichier donné !</​note>​
  
-<box 100% right|100% right> +=== Mod avancé === 
-<box 25% round left>25% round left</box> +  - FIXME Créer un script dans /etc/init.d qui fait : 
-<box 25% round left>25% round left</box> +    * en stop : copie des fichiers de /var/log vers /​var/​log.hdd && umount de /var/log && création des liens symboliques avec le même nom que les fichiers copiés de /var/log vers /​var/​log.hdd (ou lien symbolique des dossiers directement) FIXME utiliser le contenu de /​var/​lib/​logrotate/​status ? (cf. /​etc/​cron.daily/​logrotate ) 
-<box 25% round left>25% round left</box> +    * en start (juste après mount), copier les log de /var/log/ à la suite des fichiers existant puis écrasement des fichiers de /var/log/ par ceux de /var/log.hdd
-<box 25% round left>25% round left</box> +
-</box>+
  
-<box 100% center|100% center> +<note warning>FIXME besoin de créer 2 liens symbolique différents : nécessité de tester le nom d'​appel pour vérifier si Start ou Stop && avant/après mount/umount. start + après mount OK ; stop + avant umount ​OK ; sinon ne rien faire.</​note>​
-<box 25% round left>25% round left</box> +
-<box 25% round left>25% round left</box> +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-</​box>​ +
- +
-<box 100% left|100% left> +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-</​box>​ +
- +
-<box 100% round left|100% round left> +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-</​box>​ +
- +
-<box 100% left|100% left> +
-<box 25% left>25% left</​box>​ +
-<box 25% left>25% left</​box>​ +
-<box 25% left>25% left</​box>​ +
-<box 25% left>25% left</​box>​ +
-</​box>​ +
- +
-<box 100% left> +
-------- +
-</​box>​ +
- +
-%% +
-<box 75% left|75% left> +
-<box 25% left>25% left</​box>​ +
-<box 25% left>25% left</​box>​ +
-<box 25% left>25% left</​box>​ +
-<box 25% left>25% left</​box>​ +
-</​box>​ +
-%% +
- +
-<box 100% left> +
-------- +
-</​box>​ +
- +
- +
- +
-<box 100% left|100% left> +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-<box 25% round left>25% round left</​box>​ +
-</​box>​ +
- +
-==== Taille N box horizontales ==== +
- +
-<​note>​Valeurs pour résolution 1680x1050\\ Si fenêtre redimensionnée, ​ne fonctionne plus !</​note>​ +
- +
-  * 1 box horizontale +
- +
-<box 100% center|100% center>​ +
-<box 100% round left>​100% left</​box>​ +
-</​box>​ +
- +
-  * 2 box horizontales +
- +
-<box 100% center|100% center>​ +
-<box 48% round left>48% left</​box>​ +
-<box 48% round left>48% left</​box>​ +
-</​box>​ +
- +
-<box 100% center|100% center>​ +
-<box 48% round center>​48% center</​box>​ +
-<box 48% round center>​48% center</​box>​ +
-</​box>​ +
- +
-<box 100% center|100% center>​ +
-<box 48% round right>​48% right</​box>​ +
-<box 48% round right>​48% right</​box>​ +
-</​box>​ +
- +
-<box 100% center|100% center>​ +
-<box 48% round left>48% left</​box>​ +
-<box 48% round right>​48% right</​box>​ +
-</​box>​ +
- +
-  * 3 box horizontales +
- +
-<box 100% center|100% center>​ +
-<box 32% round left>32% left</​box>​ +
-<box 32% round left>32% left</​box>​ +
-<box 32% round left>32% left</​box>​ +
-</​box>​ +
- +
-<box 100% center|100% center>​ +
-<box 32% round center>​32% center</​box>​ +
-<box 32% round center>​32% center</​box>​ +
-<box 32% round center>​32% center</​box>​ +
-</​box>​ +
- +
-<box 100% center|100% center>​ +
-<box 32% round right>​32% right</​box>​ +
-<box 32% round right>​32% right</​box>​ +
-<box 32% round right>​32% right</​box>​ +
-</​box>​ +
- +
-<box 100% center|100% center>​ +
-<box 32% round left>32% left **1**</​box>​ +
-<box 32% round right>​32% right **2**</​box>​ +
-<box 32% round center>​32% center **3**</​box>​ +
-</​box>​ +
- +
-  * 4 box horizontales +
- +
-<box 100% center|100% center>​ +
-<box 23% round left>23% left 1</​box>​ +
-<box 23% round left>23% left 2</​box>​ +
-<box 23% round left>23% left 3</​box>​ +
-<box 23% round left>23% left 4</​box>​ +
-</​box>​ +
- +
-<box 100% center|100% center>​ +
-<box 23% round left>23% left 1</​box>​ +
-<box 23% round left>23% left 2</​box>​ +
-<box 23% round right>​23% right 3</​box>​ +
-<box 23% round right>​23% right 4</​box>​ +
-</​box>​ +
- +
-<box 100% center|100% center>​ +
-<box 23% round left>23% left 1</​box>​ +
-<box 23% round right>​23% right 2</​box>​ +
-<box 23% round center>​23% center 3</​box>​ +
-<box 23% round center>​23% center 4</​box>​ +
-</​box>​ +
- +
- +
- +
-Texte ...+
  • utilisateurs/draco31.fr/brouillon.1289698548.txt.gz
  • Dernière modification: Le 18/04/2011, 14:44
  • (modification externe)