From 2100d21be76e19ff4c057c0c4bb3fc141d1077a4 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 3 Feb 2008 16:23:37 +0000 Subject: [PATCH] Update plugins git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6363 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/fd-plugins.c | 2 +- bacula/src/filed/job.c | 3 ++- bacula/src/lib/plugins.c | 2 +- bacula/src/plugins/fd/example-plugin-fd.c | 33 ++++++++++++++++------- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/bacula/src/filed/fd-plugins.c b/bacula/src/filed/fd-plugins.c index 5fd41338db..c503da898d 100644 --- a/bacula/src/filed/fd-plugins.c +++ b/bacula/src/filed/fd-plugins.c @@ -35,7 +35,7 @@ #include "jcr.h" #include "fd-plugins.h" -const int dbglvl = 0; +const int dbglvl = 50; const char *plugin_type = "-fd.so"; diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 6617d6a58b..6965a863a7 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -465,7 +465,8 @@ static int job_cmd(JCR *jcr) jcr->sd_auth_key = bstrdup(sd_auth_key); free_pool_memory(sd_auth_key); Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key); - generate_plugin_event(jcr, bEventJobStart, (void *)dir->msg); + Mmsg(jcr->errmsg, "JobId=%d Job=%s", jcr->JobId, jcr->Job); + generate_plugin_event(jcr, bEventJobStart, (void *)jcr->errmsg); return dir->fsend(OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER); } diff --git a/bacula/src/lib/plugins.c b/bacula/src/lib/plugins.c index c67228e6fd..81b7cfcb2a 100644 --- a/bacula/src/lib/plugins.c +++ b/bacula/src/lib/plugins.c @@ -105,7 +105,7 @@ bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir, const char if (len < type_len+1 || strcmp(&result->d_name[len-type_len], type) != 0) { continue; } - printf("Got: name=%s len=%d\n", result->d_name, len); + Dmsg2(000, "Loaded plugin: name=%s len=%d\n", result->d_name, len); pm_strcpy(fname, plugin_dir); if (need_slash) { diff --git a/bacula/src/plugins/fd/example-plugin-fd.c b/bacula/src/plugins/fd/example-plugin-fd.c index 044b7594db..7599c4d9c7 100644 --- a/bacula/src/plugins/fd/example-plugin-fd.c +++ b/bacula/src/plugins/fd/example-plugin-fd.c @@ -101,7 +101,7 @@ static bpError newPlugin(bpContext *ctx) { int JobId = 0; bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId); - printf("plugin: newPlugin JobId=%d\n", JobId); +// printf("plugin: newPlugin JobId=%d\n", JobId); bfuncs->registerBaculaEvents(ctx, 1, 2, 0); return 0; } @@ -110,19 +110,19 @@ static bpError freePlugin(bpContext *ctx) { int JobId = 0; bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId); - printf("plugin: freePlugin JobId=%d\n", JobId); +// printf("plugin: freePlugin JobId=%d\n", JobId); return 0; } static bpError getPluginValue(bpContext *ctx, pVariable var, void *value) { - printf("plugin: getPluginValue var=%d\n", var); +// printf("plugin: getPluginValue var=%d\n", var); return 0; } static bpError setPluginValue(bpContext *ctx, pVariable var, void *value) { - printf("plugin: setPluginValue var=%d\n", var); +// printf("plugin: setPluginValue var=%d\n", var); return 0; } @@ -131,16 +131,31 @@ static bpError handlePluginEvent(bpContext *ctx, bEvent *event, void *value) char *name; switch (event->eventType) { case bEventJobStart: - printf("plugin: HandleEvent JobStart\n"); + printf("plugin: JobStart=%s\n", (char *)value); break; case bEventJobEnd: - printf("plugin: HandleEvent JobEnd\n"); + printf("plugin: JobEnd\n"); + break; + case bEventBackupStart: + printf("plugin: BackupStart\n"); + break; + case bEventBackupEnd: + printf("plugin: BackupEnd\n"); + break; + case bEventPluginCommand: + printf("plugin: command=%s\n", (char *)value); + break; + case bEventLevel: + printf("plugin: JobLevel=%c %d\n", (int)value, (int)value); + break; + case bEventSince: + printf("plugin: since=%d\n", (int)value); break; } bfuncs->getBaculaValue(ctx, bVarFDName, (void *)&name); - printf("FD Name=%s\n", name); - bfuncs->JobMessage(ctx, __FILE__, __LINE__, 1, 0, "JobMesssage message"); - bfuncs->DebugMessage(ctx, __FILE__, __LINE__, 1, "DebugMesssage message"); +// printf("FD Name=%s\n", name); +// bfuncs->JobMessage(ctx, __FILE__, __LINE__, 1, 0, "JobMesssage message"); +// bfuncs->DebugMessage(ctx, __FILE__, __LINE__, 1, "DebugMesssage message"); return 0; } -- 2.39.5