Skip to content

Commit

Permalink
[FIXUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
nichamon committed May 15, 2024
1 parent 5f75652 commit 109578f
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 62 deletions.
40 changes: 20 additions & 20 deletions ldms/man/ldmsd_sampler_discovery.man
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ ldmsd_sampler_disconvery - Manual for LDMSD Sampler Discovery

**Sampler side Commands**

.IP \fBadvertise_add
.IP \fBadvertiser_add
.RI "name=" NAME " xprt=" XPRT " host=" HOST " port=" PORT
.RI "[auth=" AUTH_DOMAIN "]"

.IP \fBadvertise_start
.IP \fBadvertiser_start
.RI "name=" NAME

.IP \fBadvertise_stop
.IP \fBadvertiser_stop
.RI "name=" NAME

.IP \fBadvertise_del
.IP \fBadvertiser_del
.RI "name=" NAME

.IP \fBadvertise_status
.IP \fBadvertiser_status
.RI "[name=" NAME "]"

.PP
Expand Down Expand Up @@ -52,16 +52,16 @@ eliminates the need for manual configuration of sampler hostname in the
aggregator configuration file.

Admins specify the aggregator hostname and the listening port in sampler
configuration via the \fBadvertise_add\fR command and start the advertisement
with the \fBadvertise_start\fR command. The samplers now advertise their
configuration via the \fBadvertiser_add\fR command and start the advertisement
with the \fBadvertiser_start\fR command. The samplers now advertise their
hostname to the aggregator. On the aggregator, admins specify a regular
expression to be matched with sampler hostname via the \fBprdcr_listen_add\fR
command. The \fBprdcr_listen_start\fR command is used to tell the aggregator to
automatically add producers corresponding to a sampler of which the hostname
matches the regular expression.

The auto-generated producers is of the ‘generated’ type. The producer name is
the same as the name given at the \fBadvertise_add\fR line in the sampler
The auto-generated producers is of the ‘advertised’ type. The producer name is
the same as the name given at the \fBadvertiser_add\fR line in the sampler
configuration file. LDMSD automatically starts them; however, admins need to
stop them manually by using the command \fBprdcr_stop\fR or
\fBprdcr_stop_regex\fR. They can be restarted by using the command
Expand All @@ -71,7 +71,7 @@ The description for each command and its parameters are as follows.

**Sampler Side Commands**

\fBadvertise_add\fR adds a new advertisement. The parameters are:
\fBadvertiser_add\fR adds a new advertisement. The parameters are:
.RS
.IP \fBname\fR=\fINAME
String of the advertisement name. The aggregator uses the string as the producer name as well.
Expand All @@ -87,26 +87,26 @@ Reconnect interval
The authentication domain to be used to connect to the aggregator
.RE

\fBadvertise_start\fR starts an advertisement. The parameters are:
\fBadvertiser_start\fR starts an advertisement. The parameters are:
.RS
.IP \fBname\fR=\fINAME
The advertisement name to be started
.RE


\fBadvertise_stop\fR stops an advertisement. The parameters are:
\fBadvertiser_stop\fR stops an advertisement. The parameters are:
.RS
.IP \fBname\fR=\fINAME
The advertisement name to be stopped
.RE

\fBadvertise_del\fR deletes an advertisement. The parameters are:
\fBadvertiser_del\fR deletes an advertisement. The parameters are:
.RS
.IP \fBname\fR=\fINAME
The advertisement name to be deleted
.RE

\fBadvertise_status reports the status of each advertisement. An optional parameter is:
\fBadvertiser_status reports the status of each advertisement. An optional parameter is:
.RS
.IP \fB[name\fR=\fINAME\fB]
Advertisement name
Expand Down Expand Up @@ -168,8 +168,8 @@ advertise themselves and connect to the aggregator using sock on host
> cat samplerd-1.conf
.RS 4
# Add and start an advertisement
advertise_add name=samplerd-1 xprt=sock host=node-3 port=411 reconnect=10s
advertise_start name=samplerd-1
advertiser_add name=samplerd-1 xprt=sock host=node-3 port=411 reconnect=10s
advertiser_start name=samplerd-1
# Load, configure, and start the meminfo plugin
load name=meminfo
config name=meminfo producer=samplerd-1 instance=samplerd-1/meminfo
Expand All @@ -180,8 +180,8 @@ start name=meminfo interval=1s
> cat samplerd-2.conf
.RS 4
# Add and start an advertisement
advertise_add name=samplerd-2 host=node-3 port=411 reconnect=10s
advertise_start name=samplerd-2
advertiser_add name=samplerd-2 host=node-3 port=411 reconnect=10s
advertiser_start name=samplerd-2
# Load, configure, and start the meminfo plugin
load name=meminfo
config name=meminfo producer=samplerd-2 instance=samplerd-2/meminfo
Expand Down Expand Up @@ -210,14 +210,14 @@ updtr_start name=all
.RE
.EE

LDMSD provides the command \fBadvertise_status\fR to report the status of
LDMSD provides the command \fBadvertiser_status\fR to report the status of
advertisement of a sampler daemon.

.EX
.B
> ldmsd_controller -x sock -p 10001 -h node-1
Welcome to the LDMSD control processor
sock:node-1:10001> advertise_status
sock:node-1:10001> advertiser_status
Name Aggregator Host Aggregator Port Transport Reconnect (us) State
---------------- ---------------- --------------- ------------ --------------- ------------
samplerd-1 node-3 10001 sock 10000000 CONNECTED
Expand Down
1 change: 1 addition & 0 deletions ldms/python/ldmsd/ldmsd_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ class LDMSD_Request(object):
PRDCR_LISTEN_START = 0x100 + 19
PRDCR_LISTEN_STOP = 0x100 + 20
PRDCR_LISTEN_STATUS = 0x100 + 21
ADVERTISE = 0x100 + 22

STRGP_ADD = 0x200
STRGP_DEL = 0x200 + 1
Expand Down
6 changes: 3 additions & 3 deletions ldms/python/ldmsd/ldmsd_controller
Original file line number Diff line number Diff line change
Expand Up @@ -3033,10 +3033,10 @@ class LdmsdCmdParser(cmd.Cmd):
rc, msg = self.comm.prdcr_listen_status(**arg)
if rc == 0 and msg is not None:
l = fmt_status(msg)
print(f"{'Name':20} {'Regex':15} {'State':10}")
print(f"{'-'*20} {'-'*15} {'-'*10}")
print(f"{'Name':20} {'State':10} {'Regex':15} {'IP Range':30}")
print(f"{'-'*20} {'-'*10} {'-'*15} {'-'*30}")
for pl in l:
print(f"{pl['name']:20} {pl['regex']:15} {pl['state']:10}")
print(f"{pl['name']:20} {pl['state']:10} {pl['regex']:15} {pl['IP range']:30}")
if len(pl['producers']):
print(f"Producers: {', '.join(p for p in pl['producers'])}")
else:
Expand Down
5 changes: 3 additions & 2 deletions ldms/src/ldmsd/ldmsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ typedef struct ldmsd_prdcr {
* an advertise_notification request. The peer will initiate the dir request
* after the peer verifies its hostname.
*/
LDMSD_PRDCR_TYPE_ADVERTISE,
LDMSD_PRDCR_TYPE_ADVERTISER,
/**
* The producer is generated by LDMSD upon receiving a
* advertise_notification request that the hostname matches
Expand All @@ -257,7 +257,7 @@ typedef struct ldmsd_prdcr {
* Similarly to passive producers, the connection is initiated
* by an advertise producer on the peer. This side initiates the dir request.
*/
LDMSD_PRDCR_TYPE_GENERATED,
LDMSD_PRDCR_TYPE_ADVERTISED,
} type;

struct ldmsd_task task;
Expand Down Expand Up @@ -379,6 +379,7 @@ typedef struct ldmsd_prdcr_listen {
int rate_limits; /* bytes/sec */

/* Network Address & prefix_len from a given CIDR IP address string */
const char *cidr_str; /* IP Range */
struct ldms_addr net_addr;
int prefix_len;

Expand Down
6 changes: 3 additions & 3 deletions ldms/src/ldmsd/ldmsd_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ int __req_deferred_start(ldmsd_req_ctxt_t reqc, ldmsd_cfgobj_type_t type)
/* The implementation is in ldmsd_request.c. */
extern ldmsd_prdcr_t
__prdcr_add_handler(ldmsd_req_ctxt_t reqc, char *verb, char *obj_name);
int __req_deferred_advertise_start(ldmsd_req_ctxt_t reqc)
int __req_deferred_advertiser_start(ldmsd_req_ctxt_t reqc)
{
int rc = 0;
ldmsd_prdcr_t prdcr;
Expand All @@ -837,7 +837,7 @@ int __req_deferred_advertise_start(ldmsd_req_ctxt_t reqc)

prdcr = ldmsd_prdcr_find(name);
if (!prdcr) {
prdcr = __prdcr_add_handler(reqc, "advertise_start", "advertise");
prdcr = __prdcr_add_handler(reqc, "advertiser_start", "advertiser");
if (!prdcr) {
ovis_log(config_log, OVIS_LERROR, "%s", reqc->line_buf);
rc = reqc->errcode;
Expand Down Expand Up @@ -872,7 +872,7 @@ int __req_filter_failover(ldmsd_req_ctxt_t reqc, void *ctxt)
rc = __req_deferred_start_regex(reqc, LDMSD_CFGOBJ_PRDCR);
break;
case LDMSD_ADVERTISER_START_REQ:
rc = __req_deferred_advertise_start(reqc);
rc = __req_deferred_advertiser_start(reqc);
break;
case LDMSD_PRDCR_START_REQ:
rc = __req_deferred_start(reqc, LDMSD_CFGOBJ_PRDCR);
Expand Down
36 changes: 18 additions & 18 deletions ldms/src/ldmsd/ldmsd_prdcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static void __ldmsd_xprt_ctxt_free(void *_ctxt)
}

static ovis_log_t config_log;
static int __advertise_notification_resp_cb(ldmsd_req_cmd_t rcmd)
static int __advertise_resp_cb(ldmsd_req_cmd_t rcmd)
{
ldmsd_req_hdr_t resp = (ldmsd_req_hdr_t)(rcmd->reqc->req_buf);
ldmsd_prdcr_t prdcr = (ldmsd_prdcr_t)(rcmd->ctxt);
Expand Down Expand Up @@ -605,15 +605,15 @@ static int __advertise_notification_resp_cb(ldmsd_req_cmd_t rcmd)
return 0;
}

static int __send_advertise_notification(ldmsd_prdcr_t prdcr)
static int __send_advertisement(ldmsd_prdcr_t prdcr)
{
int rc;
ldmsd_req_cmd_t rcmd;
char my_hostname[HOST_NAME_MAX+1];

rcmd = ldmsd_req_cmd_new(prdcr->xprt,
LDMSD_ADVERTISE_NOTIFY_REQ, NULL,
__advertise_notification_resp_cb, prdcr);
LDMSD_ADVERTISE_REQ, NULL,
__advertise_resp_cb, prdcr);
if (!rcmd) {
ovis_log(NULL, OVIS_LCRIT, "Memory allocation failure.\n");
return ENOMEM;
Expand All @@ -640,8 +640,8 @@ static int __sampler_routine(ldms_t x, ldms_xprt_event_t e, ldmsd_prdcr_t prdcr)
case LDMS_XPRT_EVENT_CONNECTED:
/* Do nothing */
prdcr->conn_state = LDMSD_PRDCR_STATE_CONNECTED;
if (prdcr->type == LDMSD_PRDCR_TYPE_ADVERTISE) {
__send_advertise_notification(prdcr);
if (prdcr->type == LDMSD_PRDCR_TYPE_ADVERTISER) {
__send_advertisement(prdcr);
/* TODO: handle the error */
}
break;
Expand Down Expand Up @@ -766,11 +766,11 @@ static void prdcr_connect_cb(ldms_t x, ldms_xprt_event_t e, void *cb_arg)
switch (prdcr->type) {
case LDMSD_PRDCR_TYPE_ACTIVE:
case LDMSD_PRDCR_TYPE_PASSIVE:
case LDMSD_PRDCR_TYPE_GENERATED:
case LDMSD_PRDCR_TYPE_ADVERTISED:
is_reset_prdcr = __agg_routine(x, e, prdcr);
break;
case LDMSD_PRDCR_TYPE_BRIDGE:
case LDMSD_PRDCR_TYPE_ADVERTISE:
case LDMSD_PRDCR_TYPE_ADVERTISER:
is_reset_prdcr = __sampler_routine(x, e, prdcr);
break;
default:
Expand Down Expand Up @@ -831,7 +831,7 @@ static void prdcr_connect(ldmsd_prdcr_t prdcr)
switch (prdcr->type) {
case LDMSD_PRDCR_TYPE_ACTIVE:
case LDMSD_PRDCR_TYPE_BRIDGE:
case LDMSD_PRDCR_TYPE_ADVERTISE:
case LDMSD_PRDCR_TYPE_ADVERTISER:
assert(prdcr->xprt == NULL);
prdcr->conn_state = LDMSD_PRDCR_STATE_CONNECTING;
prdcr->xprt = ldms_xprt_rail_new(prdcr->xprt_name,
Expand All @@ -857,7 +857,7 @@ static void prdcr_connect(ldmsd_prdcr_t prdcr)
}
break;
case LDMSD_PRDCR_TYPE_PASSIVE:
case LDMSD_PRDCR_TYPE_GENERATED:
case LDMSD_PRDCR_TYPE_ADVERTISED:
assert(prdcr->xprt == NULL);
prdcr->xprt = ldms_xprt_by_remote_sin((struct sockaddr *)&prdcr->ss);
/*
Expand Down Expand Up @@ -917,10 +917,10 @@ int ldmsd_prdcr_str2type(const char *type)
prdcr_type = LDMSD_PRDCR_TYPE_LOCAL;
else if (0 == strcasecmp(type, "bridge"))
prdcr_type = LDMSD_PRDCR_TYPE_BRIDGE;
else if (0 == strcasecmp(type, "advertise"))
prdcr_type = LDMSD_PRDCR_TYPE_ADVERTISE;
else if (0 == strcasecmp(type, "generated"))
prdcr_type = LDMSD_PRDCR_TYPE_GENERATED;
else if (0 == strcasecmp(type, "advertiser"))
prdcr_type = LDMSD_PRDCR_TYPE_ADVERTISER;
else if (0 == strcasecmp(type, "advertised"))
prdcr_type = LDMSD_PRDCR_TYPE_ADVERTISED;
else
return -EINVAL;
return prdcr_type;
Expand All @@ -936,10 +936,10 @@ const char *ldmsd_prdcr_type2str(enum ldmsd_prdcr_type type)
return "local";
else if (LDMSD_PRDCR_TYPE_BRIDGE == type)
return "bridge";
else if (LDMSD_PRDCR_TYPE_ADVERTISE == type)
return "advertise";
else if (LDMSD_PRDCR_TYPE_GENERATED == type)
return "generated";
else if (LDMSD_PRDCR_TYPE_ADVERTISER == type)
return "advertiser";
else if (LDMSD_PRDCR_TYPE_ADVERTISED == type)
return "advertised";
else
return NULL;
}
Expand Down
Loading

0 comments on commit 109578f

Please sign in to comment.