Hi,
our bacula setup includes large numbers of clone jobs which result in a large
number of messages/mails. For better handling, we now only send mails for non-
clone jobs by using a custom "mail" command for messages that aggregates
messages of its clones.
This requires the availability of the job codes (especially the "%C" code
introduced in patch 1/3, see earlier mail) that are known inside the director
to the messaging system. That is implemented in the attached patch. During
initialization of the message system (init_msg), the director's job code
callback is passed to the messaging system, where it is stored in a global
variable.
I have tested the patch in our scenario and have not seen any negative
impacts. The calls to the functions that eventually use the job code callback
-- i.e. ones that execute the mail and operator commands -- are only performed
from the director side. The callback is initialized with NULL when the message
system is initialized from the other daemons. I expect the patch to be quite
safe.
Please feel free to use this patch in upstream or any other bacula editions.
If you consider the patch for upstream inclusion, I'll be happy to provide a
documentation patch as well if required. You have my signed FLA.
Thx
Bastian
--
Collax GmbH . Basler Str. 115a . 79115 Freiburg . Germany
p: +49 (0) 89-990 157-28 www.collax.com
Geschäftsführer: Bernd Bönte, Boris Nalbach
AG München HRB 173695. Ust.-IdNr: DE270819312
--- bacula-5.2.6.ori/src/lib/message.c 2012-02-21 16:59:33.000000000 +0100
+++ bacula-5.2.6/src/lib/message.c 2012-02-23 16:01:00.000000000 +0100
@@ -66,6 +66,7 @@
char con_fname[500]; /* Console filename */
FILE *con_fd = NULL; /* Console file descriptor */
brwlock_t con_lock; /* Console lock structure */
+job_code_callback_t message_job_code_callback = NULL; /* Job code callback. Only used by director. */
/* Forward referenced functions */
@@ -242,7 +243,7 @@
* non-NULL -> initialize jcr using Message resource
*/
void
-init_msg(JCR *jcr, MSGS *msg)
+init_msg(JCR *jcr, MSGS *msg, job_code_callback_t job_code_callback)
{
DEST *d, *dnew, *temp_chain = NULL;
int i;
@@ -255,6 +256,8 @@
set_jcr_in_tsd(INVALID_JCR);
}
+ message_job_code_callback = job_code_callback;
+
#if !defined(HAVE_WIN32)
/*
* Make sure we have fd's 0, 1, 2 open
@@ -448,7 +451,7 @@
BPIPE *bpipe;
if (d->mail_cmd) {
- cmd = edit_job_codes(jcr, cmd, d->mail_cmd, d->where);
+ cmd = edit_job_codes(jcr, cmd, d->mail_cmd, d->where, message_job_code_callback);
} else {
Mmsg(cmd, "/usr/lib/sendmail -F Bacula %s", d->where);
}
--- bacula-5.2.6.ori/src/lib/protos.h 2012-02-21 16:59:33.000000000 +0100
+++ bacula-5.2.6/src/lib/protos.h 2012-02-23 16:00:09.000000000 +0100
@@ -226,9 +226,14 @@
void lex_set_default_error_handler (LEX *lf);
int lex_set_error_handler_error_type (LEX *lf, int err_type);
+/* Required typedef, not in a C file */
+extern "C" {
+typedef char *(*job_code_callback_t)(JCR *, const char *);
+}
+
/* message.c */
void my_name_is (int argc, char *argv[], const char *name);
-void init_msg (JCR *jcr, MSGS *msg);
+void init_msg (JCR *jcr, MSGS *msg, job_code_callback_t job_code_callback = NULL);
void term_msg (void);
void close_msg (JCR *jcr);
void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code);
@@ -310,11 +315,6 @@
/* util.c */
-
-extern "C" {
-typedef char *(*job_code_callback_t)(JCR *, const char *);
-}
-
bool is_buf_zero (char *buf, int len);
void lcase (char *str);
void bash_spaces (char *str);
--- bacula-5.2.6.ori/src/dird/job.c 2012-02-23 16:03:30.000000000 +0100
+++ bacula-5.2.6/src/dird/job.c 2012-02-23 16:03:08.000000000 +0100
@@ -105,7 +105,7 @@
jcr->lock();
Dsm_check(100);
- init_msg(jcr, jcr->messages);
+ init_msg(jcr, jcr->messages, job_code_callback_director);
/* Initialize termination condition variable */
if ((errstat = pthread_cond_init(&jcr->term_wait, NULL)) != 0) {
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel