4 \section*{La ressource Messages}
5 \label{_ChapterStart15}
6 \index[general]{Ressource!Messages}
7 \index[general]{Messages Ressource}
8 \addcontentsline{toc}{section}{Ressource Messages}
10 \subsection*{La ressource Messages}
11 \label{MessageResource}
12 \index[general]{Ressource!Messages}
13 \index[general]{Messages Ressource}
14 \addcontentsline{toc}{subsection}{La ressource Messages}
16 La ressource Messages définit la façon dont les messages doivent être construits
17 et vers quelles destinations ils doivent être transmis.
19 Bien que chaque {\it daemon} intègre un gestionnaire de messages pleinement
20 fonctionnel, vous choisirez certainement de centraliser les messages appropriés
21 des File Daemons et du Storage Daemon vers le Director. Ainsi, tous les messages
22 associés à un job donné peuvent être combinés et envoyés en un simple courrier
23 électronique vers l'utilisateur, ou enregistré dans quelque fichier de logs.
25 Chaque message généré par un {\it daemon} Bacula possède un type associé tel
26 que INFO, WARNING, ERROR, FATAL, etc. La ressource Messages vous permet de
27 stipuler les types de messages que vous voulez voir, et où les envoyer. De plus,
28 un message peut être expédié vers plusieurs destinations. Par exemple, vous
29 pouvez faire en sorte quque tous les messages d'erreur soient consignés dans un
30 fichier de logs tout en vous étant envoyés par courrier élecronique. En
31 définissant plusieurs ressources Messages, vous pouvez profiter de différents
32 modes de prise en charge pour chaque type de job (par exemple, selon qu'il
33 s'agit d'une full ou d'un incrémentale).
35 En général, les messages sont attachés à un job et sont inclus dans le rapport de job.
36 Il existe de rares situations où ce n'est pas possible, par exemple lorsqu'aucun
37 job n'est en cours d'exécution, ou si une erreur de communication se produit
38 entre un daemon et le Director. Dans ce genre de situations, le message demeure
39 dans le système et devrait être purgé à la fin job suivant. Cependant, comme de tels
40 messages ne sont pas attachés à un job, tous ceux qui sont envoyés par courrier
41 électronique sont envoyés à {\bf /usr/lib/sendmail}. Si sur votre système, comme c'est
42 le cas de FreeBSD, sendmail réside en un autre emplacement, veillez à le lier
43 depuis l'emplacement ci-dessus.
45 Les enregistrements contenus dans une ressource Messages consistent en une
46 spécification de {\bf destination} suivie d'une liste de types de messages
47 {\bf message-types} au format :
51 \item [destination = message-type1, message-type2, message-type3, ... ]
52 \index[dir]{destination}
55 ou, pour ces destinations qui nécessitent de spécifier une adresse (e-mail, par exemple) :
59 \item [destination = address = message-type1, message-type2,
61 \index[dir]{destination}
63 où {\bf destination} est l'un des mots-clef prédéfinis qui précise où le message
64 doit être expédié ({\bf stdout}, {\bf file}, ...), {\bf message-type} est l'un des
65 mots-clef prédéfinis qui précise le type de messages généré par Bacula ({\bf ERROR},
66 {\bf WARNING}, {\bf FATAL}, ...) et {\bf address} varie selon le mot clef {\bf destination}
67 mais peut typiquement être une adresse de courrier électronique ou un nom de fichier.
71 Voici la liste des directives disponibles pour définir des ressources Messages :
78 Début des enregistrements de Messages
80 \item [Name = \lt{}name\gt{}]
82 Le nom de la ressource Message. Ce nom sera utilisé pour lier cette ressource
83 Message à un job et/ou au un daemon.
87 \item [MailCommand = \lt{}command\gt{}]
88 \index[dir]{MailCommand}
89 En l'absence de cette directive, Bacula enverra tous ses messages avec la
92 {\bf mail -s "Bacula Message" \lt{}recipients\gt{}}
93 Dans de nombreusx cas, selon votre machine, cette commande peut ne pas fonctionner.
94 La directive {\bf MailCommand} vous permet de stipuler précisément la façon
95 d'envoyer vos courrier électroniques. Lors de l'exécution de la commande
96 {\bf command}, spécifiée entre guillemets, les substitutions suivantes sont
101 \item \%c = Le nom du client
102 \item \%d = Le nom du Director
103 \item \%e = Le code de sortie du job (OK, Error, ...)
104 \item \%i = L'Id du Job
105 \item \%j = Le nom unique du job
106 \item \%l = Le niveau (Full, differential, ...) du job
107 \item \%n = Le om du job
108 \item \%r = Les destinataires
109 \item \%t = Le type du job (Backup, verify, ...)
112 Voici la commande que j'utilise (Kern) :
114 {\bf mailcommand = "/home/kern/bacula/bin/bsmtp -h mail.example.com -f
115 \textbackslash{}"\textbackslash{}(Bacula\textbackslash{})
116 \%r\textbackslash{}" -s \textbackslash{}"Bacula: \%t \%e of \%c
117 \%l\textbackslash{}" \%r"}
119 Notez que la commande entière devrait apparaître sur une seulle ligne plutôt
120 que découpée comme ici pour des raisons de présentation.
122 Le programme {\bf bsmtp} est fourni en tant que partie de Bacula. Pour plus
123 de détails, consultez la section \ilink{ bsmtp -- Personnaliser l'envoi
124 de vos message par courrier électronique}{bsmtp}. Testez soigneusement
125 toute commande {\bf mailcommand} pour vous assurer que votre passerelle
126 bsmtp accepte le format d'adressage que vous utilisez. Certains programmes
127 tels Exim peut se montrer très sélectif en ce qui concerne les format
128 autorisés, particulièrement en ce qui concerne le champ "from".
130 \item [OperatorCommand = \lt{}command\gt{}]
131 \index[fd]{OperatorCommand}
132 This resource specification is similar to the {\bf MailCommand} except that
133 it is used for Operator messages. The substitutions performed for the {\bf
134 MailCommand} are also done for this command. Normally, you will set this
135 command to the same value as specified for the {\bf MailCommand}.
137 \item [Debug = \lt{}debug-level\gt{}]
139 This sets the debug message level to the debug level, which is an integer.
140 Higher debug levels cause more debug information to be produced. You are
141 requested not to use this record since it will be deprecated.
143 \item [\lt{}destination\gt{} = \lt{}message-type1\gt{},
144 \lt{}message-type2\gt{}, ...]
145 \index[fd]{\lt{}destination\gt{}}
147 Where {\bf destination} may be one of the following:
153 Send the message to standard output.
157 Send the message to standard error.
160 \index[console]{console}
161 Send the message to the console (Bacula Console). These messages are held
162 until the console program connects to the Director.
165 \item {\bf \lt{}destination\gt{} = \lt{}address\gt{} =
166 \lt{}message-type1\gt{}, \lt{}message-type2\gt{}, ...}
167 \index[console]{\lt{}destination\gt{}}
169 Where {\bf address} depends on the {\bf destination}, which may be one of the
175 \index[dir]{director}
176 Send the message to the Director whose name is given in the {\bf address}
177 field. Note, in the current implementation, the Director Name is ignored, and
178 the message is sent to the Director that started the Job.
182 Send the message to the filename given in the {\bf address} field. If the
183 file already exists, it will be overwritten.
187 Append the message to the filename given in the {\bf address} field. If the
188 file already exists, it will be appended to. If the file does not exist, it
193 Send the message to the system log (syslog) using the facility specified in
194 the {\bf address} field. Note, for the moment, the {\bf address} field is
195 ignored and the message is always sent to the LOG_DAEMON facility with
196 level LOG_ERR. See {\bf man 3 syslog} for more details. Example:
198 syslog = all, !skipped, !saved
203 Send the message to the email addresses that are given as a comma
204 separated list in the {\bf address} field. Mail messages are grouped
205 together during a job and then sent as a single email message when the
206 job terminates. The advantage of this destination is that you are
207 notified about every Job that runs. However, if you backup 5 or 10
208 machines every night, the volume of email messages can be important.
209 Some users use filter programs such as {\bf procmail} to automatically
210 file this email based on the Job termination code (see {\bf
213 \item [mail on error]
214 \index[fd]{mail on error}
215 Send the message to the email addresses that are given as a comma
216 separated list in the {\bf address} field if the Job terminates with an
217 error condition. MailOnError messages are grouped together during a job
218 and then sent as a single email message when the job terminates. This
219 destination differs from the {\bf mail} destination in that if the Job
220 terminates normally, the message is totally discarded (for this
221 destination). If the Job terminates in error, it is emailed. By using
222 other destinations such as {\bf append} you can ensure that even if the
223 Job terminates normally, the output information is saved.
227 Send the message to the email addresses that are specified as a comma
228 separated list in the {\bf address} field. This is similar to {\bf
229 mail} above, except that each message is sent as received. Thus there
230 is one email per message. This is most useful for {\bf mount} messages
231 (see below). \end{description}
233 For any destination, the {\bf message-type} field is a comma separated
234 list of the following types or classes of messages:
240 General information messages.
244 Warning messages. Generally this is some unusual condition but not expected
249 Non-fatal error messages. The job continues running. Any error message should
250 be investigated as it means that something went wrong.
254 Fatal error messages. Fatal errors cause the job to terminate.
257 \index[fd]{terminate}
258 Message generated when the daemon shuts down.
262 Files saved normally.
266 Files not saved because of some error. Usually because the file cannot be
267 accessed (i.e. it does not exist or is not mounted).
271 Files that were skipped because of a user supplied option such as an
272 incremental backup or a file that matches an exclusion pattern. This is
273 not considered an error condition such as the files listed for the {\bf
274 notsaved} type because the configuration file explicitly requests these
275 types of files to be skipped. For example, any unchanged file during an
276 incremental backup, or any subdirectory if the no recursion option is
281 Volume mount or intervention requests from the Storage daemon. These
282 requests require a specific operator intervention for the job to
286 \index[dir]{restored}
287 The {\bf ls} style listing generated for each file restored is sent to
295 \index[fd]{*security}
296 Security info/warning messages principally from unauthorized
302 The following is an example of a valid Messages resource definition, where
303 all messages except files explicitly skipped or daemon termination messages
304 are sent by email to enforcement@sec.com. In addition all mount messages
305 are sent to the operator (i.e. emailed to enforcement@sec.com). Finally
306 all messages other than explicitly skipped files and files saved are sent
313 mail = enforcement@sec.com = all, !skipped, !terminate
314 operator = enforcement@sec.com = mount
315 console = all, !skipped, !saved
320 With the exception of the email address (changed to avoid junk mail from
321 robot's), Kern's Director's Messages resource is as follows. Note, the {\bf
322 mailcommand} and {\bf operatorcommand} are on a single line -- they had to be
323 split for this manual:
329 mailcommand = "bacula/bin/bsmtp -h mail.example.com \
330 -f \"\(Bacula\) %r\" -s \"Bacula: %t %e of %c %l\" %r"
331 operatorcommand = "bacula/bin/bsmtp -h mail.example.com \
332 -f \"\(Bacula\) %r\" -s \"Bacula: Intervention needed \
334 MailOnError = security@example.com = all, !skipped, \
336 append = "bacula/bin/log" = all, !skipped, !terminate
337 operator = security@example.com = mount
338 console = all, !skipped, !saved