Item 1: Bacula support for a MailOnSuccess feature.
Origin: Jaime Ventura <jaimeventura at ipp dot pt>
Date: 15 November 2006
Status: for 1.38.11: coded(patch on attachment), compiled, tested
for 1.39.28: coded(patch on attachment), complied, NOT tested
What: be able to send a email message for a specified email address if (and
only if) a job finishes successfully.
Its similar to the MailOnError feature.
Why: The importance is about the same as MailOnError feature.
Since its not possible to do it using bacula's message types(info,
error,...)filter, this could be done using some kind of filter, right after the
mail was sent.
But since there is a MailOnError feature, why not have a
MailOnSuccess feature?
Notes:
Why its not possible to do it using bacula's message types(info, error,...)?
Imagine I want bacula to send ONLY successful job reports/messages to
[EMAIL PROTECTED]
When a job starts, bacula send the message : 10-Nov 17:37 bserver-dir: Start Backup JobId 1605, Job=Job.GSI04.2006-11-10_17.37.30
Since this is a info message (msgtype = M_INFO) the "bacula's messaging system" put it on the job messages (jcr->jcr_msgs) to be sent
to all dest that have the info type enabled (including [EMAIL PROTECTED]).
But when/if the job fails, that message (10-Nov 17:37 bserver-dir: Start Backup JobId 1605, Job=Job.GSI04.2006-11-10_17.37.30) has already
been queued to be sent to [EMAIL PROTECTED], even though it refers to a unsuccessful backup.
So when its time to send all messages to emails, the "bacula's messaging system" send that message (10-Nov 17:37 bserver-dir: Start
Backup JobId 1605, Job=Job.GSI04.2006-11-10_17.37.30) to [EMAIL PROTECTED], but using the subject "bacula ERROR", because the job terminated unsuccessful.
This "problem" could also happen if I wanted bacula to send emails regarding unsuccessful backups, if i didnt use the MailOnError feature.
This feature is implemented so that if messages that where queued to be sent if the backup was unsuccessful, to be discarded if the backup is
successful.
--
Jaime Ventura
[Infra-estruturas e Comunicações]
Rua Dr. António Bernardino de Almeida, 431
4200 - 072 Porto
Telef: +351 22 834 05 00 (04) - ext. 1641
Fax: +351 22 832 11 59
e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
url: www.isep.ipp.pt <http://www.isep.ipp.pt>
diff -ur bacula-1.38.11/src/lib/message.c bacula-1.38.11-MailOnSuccess/src/lib/message.c
--- bacula-1.38.11/src/lib/message.c 2005-12-16 16:39:02.000000000 +0000
+++ bacula-1.38.11-MailOnSuccess/src/lib/message.c 2006-11-15 12:19:49.000000000 +0000
@@ -418,12 +418,19 @@
break;
case MD_MAIL:
case MD_MAIL_ON_ERROR:
- Dmsg0(850, "Got MD_MAIL or MD_MAIL_ON_ERROR\n");
+ case MD_MAIL_ON_SUCCESS:
+ Dmsg0(850, "Got MD_MAIL, MD_MAIL_ON_ERROR or MD_MAIL_ON_SUCCESS\n");
if (!d->fd) {
break;
}
- if (d->dest_code == MD_MAIL_ON_ERROR && jcr &&
- jcr->JobStatus == JS_Terminated) {
+ if (
+ (d->dest_code == MD_MAIL_ON_ERROR && jcr &&
+ jcr->JobStatus == JS_Terminated)
+ ||
+ (d->dest_code == MD_MAIL_ON_SUCCESS && jcr &&
+ jcr->JobStatus == JS_ErrorTerminated)
+ ){
+
goto rem_temp_file;
}
@@ -656,6 +663,7 @@
break;
case MD_MAIL:
case MD_MAIL_ON_ERROR:
+ case MD_MAIL_ON_SUCCESS:
Dmsg1(850, "MAIL for following msg: %s", msg);
if (!d->fd) {
POOLMEM *name = get_pool_memory(PM_MESSAGE);
diff -ur bacula-1.38.11/src/lib/message.h bacula-1.38.11-MailOnSuccess/src/lib/message.h
--- bacula-1.38.11/src/lib/message.h 2005-12-10 13:18:05.000000000 +0000
+++ bacula-1.38.11-MailOnSuccess/src/lib/message.h 2006-11-15 12:18:55.000000000 +0000
@@ -115,6 +115,7 @@
#define MD_OPERATOR 8 /* email a single message to the operator */
#define MD_CONSOLE 9 /* send msg to UserAgent or console */
#define MD_MAIL_ON_ERROR 10 /* email messages if job errors */
+#define MD_MAIL_ON_SUCCESS 11 /* email messages if job succeeds */
/* Queued message item */
struct MQUEUE_ITEM {
diff -ur bacula-1.38.11/src/lib/parse_conf.c bacula-1.38.11-MailOnSuccess/src/lib/parse_conf.c
--- bacula-1.38.11/src/lib/parse_conf.c 2006-06-04 13:24:40.000000000 +0100
+++ bacula-1.38.11-MailOnSuccess/src/lib/parse_conf.c 2006-11-15 12:18:55.000000000 +0000
@@ -91,6 +91,7 @@
{"syslog", store_msgs, ITEM(res_msgs), MD_SYSLOG, 0, 0},
{"mail", store_msgs, ITEM(res_msgs), MD_MAIL, 0, 0},
{"mailonerror", store_msgs, ITEM(res_msgs), MD_MAIL_ON_ERROR, 0, 0},
+ {"mailonsuccess", store_msgs, ITEM(res_msgs), MD_MAIL_ON_SUCCESS, 0, 0},
{"file", store_msgs, ITEM(res_msgs), MD_FILE, 0, 0},
{"append", store_msgs, ITEM(res_msgs), MD_APPEND, 0, 0},
{"stdout", store_msgs, ITEM(res_msgs), MD_STDOUT, 0, 0},
@@ -237,6 +238,7 @@
case MD_DIRECTOR: /* send to Director */
case MD_MAIL: /* mail */
case MD_MAIL_ON_ERROR: /* mail if Job errors */
+ case MD_MAIL_ON_SUCCESS: /* mail if Job succeeds */
if (item->code == MD_OPERATOR) {
cmd = res_all.res_msgs.operator_cmd;
} else {
diff -ur bacula-1.39.28/src/lib/message.c bacula-1.39.28-MailOnSuccess/src/lib/message.c
--- bacula-1.39.28/src/lib/message.c 2006-10-11 23:40:36.000000000 +0100
+++ bacula-1.39.28-MailOnSuccess/src/lib/message.c 2006-11-15 13:11:30.000000000 +0000
@@ -417,12 +417,19 @@
break;
case MD_MAIL:
case MD_MAIL_ON_ERROR:
- Dmsg0(850, "Got MD_MAIL or MD_MAIL_ON_ERROR\n");
+ case MD_MAIL_ON_SUCCESS:
+ Dmsg0(850, "Got MD_MAIL, MD_MAIL_ON_ERROR or MD_MAIL_ON_SUCCESS\n");
if (!d->fd) {
break;
}
- if (d->dest_code == MD_MAIL_ON_ERROR && jcr &&
- jcr->JobStatus == JS_Terminated) {
+ if (
+ (d->dest_code == MD_MAIL_ON_ERROR && jcr &&
+ jcr->JobStatus == JS_Terminated)
+ ||
+ (d->dest_code == MD_MAIL_ON_SUCCESS && jcr &&
+ jcr->JobStatus == JS_ErrorTerminated)
+ ){
+
goto rem_temp_file;
}
@@ -679,6 +686,7 @@
break;
case MD_MAIL:
case MD_MAIL_ON_ERROR:
+ case MD_MAIL_ON_SUCCESS:
Dmsg1(850, "MAIL for following msg: %s", msg);
if (!d->fd) {
POOLMEM *name = get_pool_memory(PM_MESSAGE);
Only in bacula-1.39.28-MailOnSuccess/src/lib: message.c.orig
diff -ur bacula-1.39.28/src/lib/message.h bacula-1.39.28-MailOnSuccess/src/lib/message.h
--- bacula-1.39.28/src/lib/message.h 2006-09-01 01:49:15.000000000 +0100
+++ bacula-1.39.28-MailOnSuccess/src/lib/message.h 2006-11-15 13:15:14.000000000 +0000
@@ -114,6 +114,7 @@
MD_OPERATOR, /* email a single message to the operator */
MD_CONSOLE, /* send msg to UserAgent or console */
MD_MAIL_ON_ERROR, /* email messages if job errors */
+ MD_MAIL_ON_SUCCESS, /* email messages if job succeeds */
MD_CATALOG /* sent to catalog Log table */
};
Only in bacula-1.39.28-MailOnSuccess/src/lib: message.h.orig
Only in bacula-1.39.28-MailOnSuccess/src/lib: message.h.rej
diff -ur bacula-1.39.28/src/lib/parse_conf.c bacula-1.39.28-MailOnSuccess/src/lib/parse_conf.c
--- bacula-1.39.28/src/lib/parse_conf.c 2006-11-07 04:24:53.000000000 +0000
+++ bacula-1.39.28-MailOnSuccess/src/lib/parse_conf.c 2006-11-15 13:11:30.000000000 +0000
@@ -95,6 +95,7 @@
{"syslog", store_msgs, ITEM(res_msgs), MD_SYSLOG, 0, 0},
{"mail", store_msgs, ITEM(res_msgs), MD_MAIL, 0, 0},
{"mailonerror", store_msgs, ITEM(res_msgs), MD_MAIL_ON_ERROR, 0, 0},
+ {"mailonsuccess", store_msgs, ITEM(res_msgs), MD_MAIL_ON_SUCCESS, 0, 0},
{"file", store_msgs, ITEM(res_msgs), MD_FILE, 0, 0},
{"append", store_msgs, ITEM(res_msgs), MD_APPEND, 0, 0},
{"stdout", store_msgs, ITEM(res_msgs), MD_STDOUT, 0, 0},
@@ -244,6 +245,7 @@
case MD_DIRECTOR: /* send to Director */
case MD_MAIL: /* mail */
case MD_MAIL_ON_ERROR: /* mail if Job errors */
+ case MD_MAIL_ON_SUCCESS: /* mail if Job succeeds */
if (item->code == MD_OPERATOR) {
cmd = res_all.res_msgs.operator_cmd;
} else {
Only in bacula-1.39.28-MailOnSuccess/src/lib: parse_conf.c.orig
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users