Skip to content

Commit

Permalink
Add the banner configuration command
Browse files Browse the repository at this point in the history
The `banner` configuration command is a replacement of the `-B`
command-line option.

Example:
banner mode=<0|1|2>
  • Loading branch information
nichamon authored and tom95858 committed Mar 5, 2024
1 parent e2b0b25 commit 2f1aa48
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ldms/src/ldmsd/ldmsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,11 @@ int main(int argc, char *argv[])
"The option `-C` is obsolete. "
"Please specify `default_credits credits=<INTEGER> in a configuration file.\n");
cleanup(EINVAL, "Received an obsolete command-line option");
case 'B':
ovis_log(NULL, OVIS_LCRIT,
"The option `-B` is obsolete. "
"Please specify `banner mode=<0|1|2>` in a configuration file.");
cleanup(EINVAL, "Received an obsolete command-line option");
default:
ret = ldmsd_process_cmd_line_arg(op, optarg);
if (ret) {
Expand Down
28 changes: 28 additions & 0 deletions ldms/src/ldmsd/ldmsd_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ static int daemon_name_set_handler(ldmsd_req_ctxt_t reqc);
static int worker_threads_set_handler(ldmsd_req_ctxt_t reqc);
static int default_credits_set_handler(ldmsd_req_ctxt_t reqc);
static int pid_file_handler(ldmsd_req_ctxt_t reqc);
static int banner_mode_handler(ldmsd_req_ctxt_t reqc);

/* executable for all */
#define XALL 0111
Expand Down Expand Up @@ -683,6 +684,9 @@ static struct request_handler_entry request_handler[] = {
[LDMSD_PID_FILE_REQ] = {
LDMSD_PID_FILE_REQ, pid_file_handler, XUG
},
[LDMSD_BANNER_MODE_REQ] = {
LDMSD_BANNER_MODE_REQ, banner_mode_handler, XUG
},
};

int is_req_id_priority(enum ldmsd_request req_id)
Expand All @@ -702,6 +706,7 @@ int is_req_id_priority(enum ldmsd_request req_id)
case LDMSD_WORKER_THR_SET_REQ:
case LDMSD_DEFAULT_CREDITS_REQ:
case LDMSD_PID_FILE_REQ:
case LDMSD_BANNER_MODE_REQ:
return 1;
default:
return 0;
Expand Down Expand Up @@ -9298,3 +9303,26 @@ static int pid_file_handler(ldmsd_req_ctxt_t reqc)
free(path);
return rc;
}

static int banner_mode_handler(ldmsd_req_ctxt_t reqc)
{
int rc = 0;
char *mode_s = NULL;
mode_s = ldmsd_req_attr_str_value_get_by_id(reqc, LDMSD_ATTR_LEVEL);
if (!mode_s) {
reqc->errcode = EINVAL;
reqc->line_off = snprintf(reqc->line_buf, reqc->line_len,
"The attribute 'mode' is missing.");
goto send_reply;
}
reqc->errcode = ldmsd_process_cmd_line_arg('B', mode_s);
if (reqc->errcode) {
reqc->line_off = snprintf(reqc->line_buf, reqc->line_len,
"The given banner mode '%s' is invalid.", mode_s);
goto send_reply;
}
send_reply:
ldmsd_send_req_response(reqc, reqc->line_buf);
free(mode_s);
return rc;
}
1 change: 1 addition & 0 deletions ldms/src/ldmsd/ldmsd_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ enum ldmsd_request {
LDMSD_WORKER_THR_SET_REQ,
LDMSD_DEFAULT_CREDITS_REQ,
LDMSD_PID_FILE_REQ,
LDMSD_BANNER_MODE_REQ,

/* failover requests by user */
LDMSD_FAILOVER_CONFIG_REQ = 0x700, /* "failover_config" user command */
Expand Down
2 changes: 2 additions & 0 deletions ldms/src/ldmsd/ldmsd_request_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const struct req_str_id req_str_id_table[] = {
/* This table need to be sorted by keyword for bsearch() */
{ "auth_add", LDMSD_AUTH_ADD_REQ },
{ "auth_del", LDMSD_AUTH_DEL_REQ },
{ "banner", LDMSD_BANNER_MODE_REQ },
{ "bridge_add", LDMSD_BRIDGE_ADD_REQ },
{ "bridge_del", LDMSD_PRDCR_DEL_REQ },
{ "bridge_start", LDMSD_PRDCR_START_REQ },
Expand Down Expand Up @@ -178,6 +179,7 @@ const struct req_str_id attr_str_id_table[] = {
{ "level", LDMSD_ATTR_LEVEL },
{ "match", LDMSD_ATTR_MATCH },
{ "metric", LDMSD_ATTR_METRIC },
{ "mode", LDMSD_ATTR_LEVEL },
{ "name", LDMSD_ATTR_NAME },
{ "num", LDMSD_ATTR_SIZE },
{ "offset", LDMSD_ATTR_OFFSET },
Expand Down

0 comments on commit 2f1aa48

Please sign in to comment.