Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| utilisateurs:draco31.fr:brouillon [Le 14/11/2010, 02:23] – 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 !! ====== | + | ====== |
| - | ===== 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 === |
| - | <box 100% center # | + | Par défaut, toutes les types d’événements sont associés aux directives |
| - | <box 100px round left # | + | <note warning>FIXME Sous Ubuntu, la notification par la commande |
| - | <box 100px round left #dcf0ea>**[[: | + | |
| - | <box 100px round left #dcf0ea>**[[: | + | |
| - | <box 100px round left # | + | |
| - | <box 100px round left # | + | |
| - | <box 150px round left # | + | |
| - | <box 100px round left # | + | |
| - | <box 100px round left # | + | |
| - | <box 100px round left # | + | |
| - | <box 100px round left # | + | |
| - | Texte ... | + | Le fichier **''/ |
| + | < | ||
| + | NOTIFYFLAG ONLINE | ||
| + | NOTIFYFLAG ONBATT | ||
| + | NOTIFYFLAG LOWBATT | ||
| + | NOTIFYFLAG FSD | ||
| + | NOTIFYFLAG COMMOK | ||
| + | NOTIFYFLAG COMMBAD | ||
| + | NOTIFYFLAG SHUTDOWN | ||
| + | NOTIFYFLAG REPLBATT | ||
| + | NOTIFYFLAG NOCOMM | ||
| + | NOTIFYFLAG NOPARENT | ||
| + | </ | ||
| - | | + | Dans **''/ |
| + | < | ||
| + | Aug 19 21:49:34 localhost upsmon[7784]: | ||
| + | Aug 19 21:50:24 localhost upsmon[7786]: | ||
| + | Aug 19 21:50:34 localhost upsmon[7786]: | ||
| + | Aug 19 21:50:34 localhost upsmon[7786]: | ||
| + | Aug 19 21:50:39 localhost upsmon[7786]: | ||
| + | Aug 19 21:50:39 localhost upsmon[7786]: | ||
| + | </ | ||
| - | < | + | < |
| - | <box 100% center # | + | === Utilisation d'un script via l' |
| - | <box 7% round left # | + | |
| - | <box 7% round left # | + | |
| - | <box 7% round left # | + | |
| - | <box 7% round left # | + | |
| - | <box 7% round left # | + | |
| - | <box 7% round left # | + | |
| - | <box 14% round left # | + | |
| - | <box 7% round left # | + | |
| - | <box 7% round left # | + | |
| - | <box 7% round left # | + | |
| - | <box 7% round left # | + | |
| - | </ | + | |
| - | Texte ... | + | Il est possible en plus ou la place des directives WALL et SYSLOG, d' |
| - | ==== Attributs ==== | + | Le fichier de configuration **''/ |
| + | < | ||
| + | NOTIFYCMD / | ||
| + | </ | ||
| + | <note tip>Le chemin ''/ | ||
| - | * v2.0 -- unité largeur | + | Les options NOTIFYFAG concernée par ce traitement personnalisée doivent avoir la directive EXEC. Exemple pour '' |
| + | < | ||
| + | NOTIFYFLAG ONLINE | ||
| + | NOTIFYFLAG ONBATT | ||
| + | NOTIFYFLAG LOWBATT | ||
| + | NOTIFYFLAG FSD | ||
| + | NOTIFYFLAG COMMOK | ||
| + | NOTIFYFLAG COMMBAD | ||
| + | NOTIFYFLAG SHUTDOWN | ||
| + | NOTIFYFLAG REPLBATT | ||
| + | NOTIFYFLAG NOCOMM | ||
| + | NOTIFYFLAG NOPARENT | ||
| + | </ | ||
| - | <box 100% center|par défaut> | + | FIXME Le script reçoit en argument le même libellé que ce qui est tracé dans '' |
| - | <box round left>n/a</box> | + | |
| - | <box round left> | + | |
| - | </ | + | |
| - | <box 100% center|**%** fixe - pourcentage> | + | == Notification par mail == |
| - | <box 10% round left> | + | |
| - | <box 10% round left> | + | |
| - | </ | + | |
| - | <box 100% center|**px** fixe - pixel> | + | <note warning>Votre modem ainsi que vos équipements réseaux reliant ce dernier au PC hébergeant upsmon serveur (relié à l' |
| - | <box 100px round left> | + | |
| - | <box 100px round left> | + | |
| - | </box> | + | |
| - | <box 100% center|**em** augmente avec le zoom de la page - emphase ?> | + | ** Choix d'un MTA accessible en console |
| - | <box 10em round left> | + | |
| - | <box 10em round left> | + | |
| - | </ | + | |
| - | <box 100% center|**em** augmente avec le zoom de la page - emphase ?> | + | Plusieurs MTA (mail transfert agent) accessible en console sont disponibles dans les dépôts. Parmi ceux-ci on notera : |
| - | <box 26em round left> | + | |
| - | <box 26em round left> | + | |
| - | </ | + | |
| - | <box 100% center|**ex** augmente avec le zoom de la page - ??> | + | ** Installation et configuration avec SSMTP ** |
| - | <box 10ex round left> | + | |
| - | <box 10ex round left> | + | |
| - | </ | + | |
| - | <box 100% center|**ex** augmente avec le zoom de la page - ??> | + | Exemple avec '' |
| - | <box 26ex round left> | + | * [[: |
| - | <box 26ex round left> | + | * [[: |
| - | </box> | + | root=mon-adresse-email@mon-fai.fr 25 |
| - | <box 100% center|**pt** fixe - point ?> | + | mailhub=smtp.fai.fr |
| - | <box 100pt round left>10pt</box> | + | hostname=ubuntu-desktop |
| - | <box 100pt round left> | + | FromLineOverride=YES |
| - | </box> | + | </file> |
| + | * Depuis un [[: | ||
| + | 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. | ||
| - | <box 100% center|**cm** fixe - centimètre> | + | ** Création du script de notification mail ** |
| - | <box 10cm round left> | + | |
| - | <box 10cm round left> | + | |
| - | </ | + | |
| - | <box 100% center|**mm** fixe | + | <note> A METTRE EN FORME --- Brouillon</ |
| - | <box 100mm round left>100mm</box> | + | Créer un fichier pour l' |
| - | <box 100mm round left>abcdefghijklmnopqrstuvwxyz</box> | + | Créer le script contenant les lignes : |
| - | </box> | + | <code>#!/bin/bash |
| + | echo " | ||
| + | </code> | ||
| - | <box 100% center|**pi** fixe - pitch ?> | + | FIXME : Non testé : à vérifier si ça marche bien :p |
| - | <box 10pi round left> | + | |
| - | <box 10pi round left> | + | |
| - | </ | + | |
| - | <box 100% center|**in** fixe - inch> | + | <note tips>Vous pouvez modifier le libellé par défaut associé à chaque événement dans le fichier upsmon.conf : |
| - | <box 10in round left> | + | <file> |
| - | <box 10in round left> | + | NOTIFYMSG ONLINE " |
| - | </box> | + | NOTIFYMSG ONBATT " |
| + | NOTIFYMSG LOWBATT " | ||
| + | NOTIFYMSG FSD " | ||
| + | NOTIFYMSG COMMOK " | ||
| + | NOTIFYMSG COMMBAD " | ||
| + | NOTIFYMSG SHUTDOWN " | ||
| + | NOTIFYMSG REPLBATT " | ||
| + | NOTIFYMSG NOCOMM " | ||
| + | NOTIFYMSG NOPARENT " | ||
| + | </file></note> | ||
| - | <box 100% center|**auto** paramètre inconnu - idem 50%> | + | === Utilisation de upssched === |
| - | <box auto round left> | + | |
| - | <box auto round left> | + | |
| - | </ | + | |
| - | * v2.0 -- Taille suivant texte : | + | Si vous souhaitez effectuer des actions différentes selon le type d' |
| - | <box 100% center|100% -- Titre> | + | fichier upsmon.conf (exemple) : |
| - | <box 10% round left|10%></ | + | |
| - | <box 10% round left|abcdefghijklmnopqrstuvwxyz></ | + | |
| - | </ | + | |
| - | <box 100% center|100% -- Texte> | + | <file> |
| - | <box 10% round left> | + | NOTIFYCMD |
| - | <box 10% round left> | + | |
| - | </ | + | |
| - | <box 100% center|100% -- Légende> | + | NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC |
| - | <box 10% round left></ | + | NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC |
| - | <box 10% round left></ | + | 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> | ||
| - | * v2.1 -- Mini Box 50% seules | + | Créer le fichier de config / |
| + | < | ||
| + | # the script to be executed | ||
| + | CMDSCRIPT / | ||
| - | <box 50% round left> | + | # mandatory fields that must be set before AT commands |
| - | <box 50% round left> | + | PIPEFN |
| + | LOCKFN / | ||
| - | \\ \\ \\ \\ \\ \\ | + | # the timers, here 30 sec after the ONBATT (ups on battery) event |
| + | AT ONBATT * START-TIMER onbatt-timer 120 | ||
| - | | + | # cancel the countdown is power is back |
| + | AT ONLINE | ||
| - | <box 100% center|100%> | + | AT COMMBAD * EXECUTE commbad |
| - | <box 50% round left> | + | AT COMMOK * EXECUTE commok |
| - | <box 50% round left> | + | 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|100%> | + | Créer le script / |
| - | <box 40% round left> | + | <file> |
| - | <box 40% round left> | + | #!/bin/bash |
| - | <box 40% round left>40%</ | + | logfile=/ |
| - | </ | + | date=$(date +"%F %T") |
| - | <box 100% center|100%> | + | case $1 in |
| - | <box 30% round left>30%</box> | + | commbad) |
| - | <box 30% round left>30%</box> | + | echo "$date : UPS communications failure." |
| - | <box 30% round left>30%</box> | + | ;; |
| - | <box 30% round left>30%</box> | + | commok) |
| - | </box> | + | echo "$date : UPS communications restored." |
| + | echo "$date : | ||
| + | sudo /bin/upscmd -u login -p pwd localups beeper.enable 2>> $logfile | ||
| + | ;; | ||
| + | nocomm) | ||
| + | echo "$date : UPS communications cannot be established." | ||
| + | ;; | ||
| + | onbatt) | ||
| + | echo "$date : UPS is on battery. Trying to suspend." | ||
| + | echo "$date : | ||
| + | sudo /bin/upscmd -u login -p pwd localups beeper.mute 120 2>> $logfile | ||
| + | sudo / | ||
| + | ;; | ||
| + | onbatt-timer) | ||
| + | echo "$date : UPS is on battery for more than 2 min. Trying to hibernate." | ||
| + | $echo "$date : | ||
| + | sudo /bin/upscmd -u login -p pwd localups beeper.mute 300 2>> $logfile | ||
| + | sudo / | ||
| + | ;; | ||
| + | lowbatt) | ||
| + | echo "$date : UPS has a low battery. Current load=$(/ | ||
| + | echo "$date : | ||
| + | sleep 1 | ||
| + | sudo /bin/upscmd -u login -p pwd localups beeper.enable 2>> $logfile | ||
| + | sudo / | ||
| + | ;; | ||
| + | online) | ||
| + | echo "$date : UPS on line. Shutdown aborted." | ||
| + | echo "$date : | ||
| + | sudo /bin/upscmd -u login -p pwd localups shutdown.stop | ||
| + | sleep 1 | ||
| + | sudo / | ||
| + | sudo /bin/upscmd -u login -p pwd localups beeper.enable 2> | ||
| + | ;; | ||
| + | fsd) | ||
| + | echo "$date : UPS is being forced-shutdown by the master." | ||
| + | echo "$date : | ||
| + | sleep 1 | ||
| + | sudo /bin/upscmd -u login -p pwd localups beeper.mute 300 2>> $logfile | ||
| + | ;; | ||
| + | shutdown) | ||
| + | echo "$date : The system is being shutdown." | ||
| + | echo "$date : | ||
| + | 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 : | ||
| + | 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)." | ||
| + | sudo / | ||
| + | ;; | ||
| + | *) | ||
| + | echo "$date : $0 > Unrecognized command: $1" | tee -a $logfile 1>& | ||
| + | echo "$date : | ||
| + | ;; | ||
| + | esac | ||
| + | exit 0 | ||
| + | </file> | ||
| - | <box 100% center|100%> | + | ====== Réduire le nombre d' |
| - | <box 25% round left> | + | |
| - | <box 25% round left> | + | |
| - | <box 25% round left> | + | |
| - | <box 25% round left> | + | |
| - | </ | + | |
| - | ==== Modulation sur box 25% ==== | + | - Créer un dossier pour les log permanentes : sudo mkdir -p / |
| + | - Modifier le fichier de config de / | ||
| + | < | ||
| + | # see "man logrotate" | ||
| + | # rotate log files weekly | ||
| + | weekly | ||
| - | ----- | + | # keep 4 weeks worth of backlogs |
| + | rotate 4 | ||
| - | <box 100% right|100% right> | + | # create new (empty) log files after rotating old ones |
| - | <box 25% round left>25% round left</ | + | create |
| - | <box 25% round left>25% round left</ | + | |
| - | <box 25% round left>25% round left</ | + | |
| - | <box 25% round left>25% round left</ | + | |
| - | </ | + | |
| - | <box 100% center|100% center> | + | # uncomment this if you want your log files compressed |
| - | <box 25% round left>25% round left</ | + | #compress |
| - | <box 25% round left>25% round left</ | + | |
| - | <box 25% round left>25% round left</ | + | |
| - | <box 25% round left>25% round left</ | + | |
| - | </ | + | |
| - | <box 100% left|100% left> | + | olddir |
| - | <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 100% round left|100% round left> | + | # packages drop log rotation information into this directory |
| - | <box 25% round left>25% round left</box> | + | include |
| - | <box 25% round left>25% round left</ | + | |
| - | <box 25% round left>25% round left</ | + | |
| - | <box 25% round left>25% round left</ | + | |
| - | </box> | + | |
| - | <box 100% left|100% left> | + | # no packages own wtmp, or btmp -- we'll rotate them here |
| - | <box 25% left>25% left</box> | + | /var/log/wtmp { |
| - | <box 25% left>25% left</box> | + | |
| - | <box 25% left>25% left</box> | + | |
| - | <box 25% left>25% left</ | + | create 0664 root utmp |
| - | </ | + | rotate 1 |
| + | } | ||
| - | <box 100% left> | + | / |
| - | ------- | + | |
| - | </ | + | |
| + | create 0660 root utmp | ||
| + | rotate 1 | ||
| + | } | ||
| - | %% | + | # system-specific logs may be configured here |
| - | <box 75% left|75% left> | + | </file> |
| - | <box 25% left>25% left</box> | + | - Modifier |
| - | <box 25% left>25% left</box> | + | <file> |
| - | <box 25% left>25% left</box> | + | # dossier en RAM (volatile) |
| - | <box 25% left>25% left</box> | + | tmpfs /tmp tmpfs |
| - | </box> | + | tmpfs /var/ |
| - | %% | + | tmpfs /var/ |
| + | tmpfs / | ||
| + | </file> | ||
| - | <box 100% left> | + | <note important>Il est possible de s' |
| - | ------- | + | |
| - | </box> | + | |
| + | === Mod easy === | ||
| + | <note tip> | ||
| - | <box 100% left|100% left> | + | - FIXME Créer un script dans / |
| - | <box 25% round left>25% round left</box> | + | <code>#!/bin/sh |
| - | <box 25% round left>25% round left</box> | + | case " |
| - | <box 25% round left>25% round left</box> | + | stop) |
| - | <box 25% round left>25% round left</box> | + | logrotate -f /etc/logrotate.conf |
| - | </box> | + | ;; |
| + | *) | ||
| + | #no-op | ||
| + | ;; | ||
| + | esac | ||
| + | exit 0 | ||
| + | </code> | ||
| + | - Lier le script dans /etc/ | ||
| - | ==== Taille N box horizontales ==== | + | > Le mieux serait de faire un service qui écoute le bon événement et ferait la manip juste avant le démontage (S40umountfs). |
| - | < | + | < |
| - | | + | === Mod avancé === |
| + | - FIXME Créer un script dans /etc/init.d qui fait : | ||
| + | | ||
| + | * 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 / | ||
| - | <box 100% center|100% center> | + | <note warning>FIXME besoin de créer |
| - | <box 100% round left> | + | |
| - | </ | + | |
| - | + | ||
| - | * 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> | + | |
| - | <box 48% round center> | + | |
| - | </ | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 48% round right> | + | |
| - | <box 48% round right> | + | |
| - | </ | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 48% round left>48% left</ | + | |
| - | <box 48% round right> | + | |
| - | </ | + | |
| - | + | ||
| - | * 3 box horizontales | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 32% round left>32% left</ | + | |
| - | <box 32% round left>32% left</ | + | |
| - | <box 32% round left>32% left</ | + | |
| - | </ | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 32% round center> | + | |
| - | <box 32% round center> | + | |
| - | <box 32% round center> | + | |
| - | </ | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 32% round right> | + | |
| - | <box 32% round right> | + | |
| - | <box 32% round right> | + | |
| - | </ | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 32% round left>32% left **1**</ | + | |
| - | <box 32% round right> | + | |
| - | <box 32% round center> | + | |
| - | </ | + | |
| - | + | ||
| - | * 4 box horizontales | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 23% round left>23% left 1</ | + | |
| - | <box 23% round left>23% left 2</ | + | |
| - | <box 23% round left>23% left 3</ | + | |
| - | <box 23% round left>23% left 4</ | + | |
| - | </ | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 23% round left>23% left 1</ | + | |
| - | <box 23% round left>23% left 2</ | + | |
| - | <box 23% round right> | + | |
| - | <box 23% round right> | + | |
| - | </ | + | |
| - | + | ||
| - | <box 100% center|100% center> | + | |
| - | <box 23% round left>23% left 1</ | + | |
| - | <box 23% round right> | + | |
| - | <box 23% round center> | + | |
| - | <box 23% round center> | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | Texte ... | + | |
