From: Kern Sibbald Date: Sun, 14 Dec 2008 20:25:24 +0000 (+0000) Subject: Implement a crude 'list joblog' mostly for debugging. X-Git-Tag: Release-3.0.0~483 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1303b1a85a57b71be814a715cdeac6caf184726a;p=bacula%2Fbacula Implement a crude 'list joblog' mostly for debugging. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8159 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index 1e3996dca6..cf9f8be7ff 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -121,6 +121,7 @@ void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void db_list_files_for_job(JCR *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx); void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type); void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type); +void db_list_joblog_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type); int db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type); void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type); diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index 9b70cb9646..8e7f1b2873 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -242,6 +242,33 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, } +void db_list_joblog_records(JCR *jcr, B_DB *mdb, uint32_t JobId, + DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) +{ + char ed1[50]; + db_lock(mdb); + if (JobId <= 0) { + return; + } + if (type == VERT_LIST) { + Mmsg(mdb->cmd, "SELECT Time,LogText FROM Log " + "WHERE Log.JobId=%s", edit_int64(JobId, ed1)); + } else { + Mmsg(mdb->cmd, "SELECT LogText FROM Log " + "WHERE Log.JobId=%s", edit_int64(JobId, ed1)); + } + if (!QUERY_DB(jcr, mdb, mdb->cmd)) { + goto bail_out; + } + + list_result(jcr, mdb, sendit, ctx, type); + + sql_free_result(mdb); + +bail_out: + db_unlock(mdb); +} + /* * List Job record(s) that match JOB_DBR diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 9679a7d82f..1afe0484f1 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -212,6 +212,8 @@ bail_out: * list jobname=name - same as above * list jobmedia jobid= * list jobmedia job=name + * list joblog jobid= + * list joblog job=name * list files jobid= - list files saved for job nn * list files job=name * list pools - list pool records @@ -337,6 +339,29 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) db_list_jobmedia_records(ua->jcr, ua->db, 0, prtit, ua, llist); } + /* List JOBLOG */ + } else if (strcasecmp(ua->argk[i], NT_("joblog")) == 0) { + int done = FALSE; + for (j=i+1; jargc; j++) { + if (strcasecmp(ua->argk[j], NT_("ujobid")) == 0 && ua->argv[j]) { + bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); + jr.JobId = 0; + db_get_job_record(ua->jcr, ua->db, &jr); + jobid = jr.JobId; + } else if (strcasecmp(ua->argk[j], NT_("jobid")) == 0 && ua->argv[j]) { + jobid = str_to_int64(ua->argv[j]); + } else { + continue; + } + db_list_joblog_records(ua->jcr, ua->db, jobid, prtit, ua, llist); + done = TRUE; + } + if (!done) { + /* List for all jobs (jobid=0) */ + db_list_joblog_records(ua->jcr, ua->db, 0, prtit, ua, llist); + } + + /* List POOLS */ } else if (strcasecmp(ua->argk[i], NT_("pool")) == 0 || strcasecmp(ua->argk[i], NT_("pools")) == 0) { diff --git a/bacula/src/version.h b/bacula/src/version.h index 1c5555b4e4..9126674bda 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.23" -#define BDATE "13 December 2008" -#define LSMDATE "13Dec08" +#define BDATE "14 December 2008" +#define LSMDATE "14Dec08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */