From: Eric Bollengier Date: Wed, 4 Aug 2021 14:24:18 +0000 (+0200) Subject: Add debug/trace/tags information to .status header X-Git-Tag: Release-11.3.2~419 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8ed2103574b6e917664d341f3027d467dd681af;p=thirdparty%2Fbacula.git Add debug/trace/tags information to .status header --- diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index ac351f9bb..68cdb2067 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -436,6 +436,7 @@ static void do_all_status(UAContext *ua) static void api_list_dir_status_header(UAContext *ua) { + alist tlist(10, not_owned_by_alist); OutputWriter wt(ua->api_opts); wt.start_group("header"); wt.get_output( @@ -456,6 +457,9 @@ static void api_list_dir_status_header(UAContext *ua) OT_PLUGINS,"plugins", b_plugin_list, OT_INT32, "fips", crypto_get_fips(), OT_STRING, "crypto", crypto_get_version(), + OT_INT64, "debug", debug_level, + OT_INT, "trace", get_trace(), + OT_ALIST_STR, "tags", debug_get_tags_list(&tlist, debug_level_tags), OT_END); ua->send_msg("%s", wt.end_group()); diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index 8a761594e..9df408bab 100644 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -79,6 +79,7 @@ static void api_list_status_header(STATUS_PKT *sp) char *p; char buf[300]; const char *cipher=NULL, *digest=NULL; + alist tlist(10, not_owned_by_alist); OutputWriter wt(sp->api_opts); *buf = 0; @@ -115,6 +116,7 @@ static void api_list_status_header(STATUS_PKT *sp) OT_STRING, "winver", buf, OT_INT64, "debug", debug_level, OT_INT, "trace", get_trace(), + OT_ALIST_STR, "tags", debug_get_tags_list(&tlist, debug_level_tags), OT_INT64, "bwlimit", me->max_bandwidth_per_job, OT_PLUGINS, "plugins", b_plugin_list, OT_INT, "pkiencryption", (int)me->pki_encrypt, diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 309d26053..4de610590 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -2031,6 +2031,35 @@ bool debug_find_tag(const char *tagname, bool add, int64_t *current_level) return false; } +/* Convert back tag bits to a string */ +char *debug_get_tags(POOLMEM **options, int64_t current_level) +{ + bool first=true; + + pm_strcpy(options, ""); + for (int i = 0; debug_tags[i].tag; i++) { + if ((debug_tags[i].bit & current_level) == debug_tags[i].bit) { + if (!first) { + pm_strcat(options, ","); + } + pm_strcat(options, debug_tags[i].tag); + first=false; + } + } + return *options; +} + +/* Convert back tag bits to a list (not_owned_by_alist) */ +alist *debug_get_tags_list(alist *options, int64_t current_level) +{ + for (int i = 0; debug_tags[i].tag; i++) { + if ((debug_tags[i].bit & current_level) == debug_tags[i].bit) { + options->append((char *)debug_tags[i].tag); + } + } + return options; +} + bool debug_parse_tags(const char *options, int64_t *current_level) { bool operation; /* + => true, - false */ diff --git a/bacula/src/lib/message.h b/bacula/src/lib/message.h index bc647ac5c..38dbb990b 100644 --- a/bacula/src/lib/message.h +++ b/bacula/src/lib/message.h @@ -183,6 +183,8 @@ const char conn_info_wo_name[] = "Connected to %s at %s:%d %s\n"; const char *debug_get_tag(uint32_t pos, const char **desc); bool debug_find_tag(const char *tagname, bool add, int64_t *current_level); bool debug_parse_tags(const char *options, int64_t *current_level); +alist *debug_get_tags_list(alist *options, int64_t current_level); +char *debug_get_tags(POOLMEM **options, int64_t current_level); class MSGS; MSGS *get_current_MSGS(JCR *jcr); diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index a8cf658a3..a6615e402 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -539,6 +539,7 @@ static void api_list_sd_status_header(STATUS_PKT *sp) { char *p; alist drivers(10, not_owned_by_alist); + alist tlist(10, not_owned_by_alist); OutputWriter wt(sp->api_opts); sd_list_loaded_drivers(&drivers); @@ -557,6 +558,9 @@ static void api_list_sd_status_header(STATUS_PKT *sp) OT_ALIST_STR, "drivers", &drivers, OT_INT32, "fips", (int32_t)crypto_get_fips(), OT_STRING, "openssl", crypto_get_version(), + OT_INT64, "debug", debug_level, + OT_INT, "trace", get_trace(), + OT_ALIST_STR, "tags", debug_get_tags_list(&tlist, debug_level_tags), OT_END); p = wt.end_group(); sendit(p, strlen(p), sp);