55 const std::map< const string, const string > plugin_libldms_msg_publish_config_defaults =
63 inline static const char *plugin_prefix =
"ADC_LIBLDMS_MSG_PUBLISH_PLUGIN_";
66 const std::vector<string> tags;
77 if (mode != pi_config)
90 const string get(
const std::map< string, string >& m,
91 string field,
const string& env_prefix) {
93 auto it = m.find(field);
97 string en = env_prefix + field;
98 char *ec = getenv(en.c_str());
100 return plugin_libldms_msg_publish_config_defaults.at(field);
108 int libldms_msg_publish_send(
string& f)
112 string qcmd =
"(" + prog +
120 "> /dev/null 2>&1 ; /bin/rm " + f +
") &";
121 int err2 = std::system(qcmd.c_str());
122 std::cout << f << std::endl;
123 std::cout << err2 << std::endl;
130 std::cout <<
"Constructing libldms_msg_publish_plugin" << std::endl;
138 if (mode != pi_pub_or_final)
144 int config(
const std::map< std::string, std::string >& m) {
145 return config(m, plugin_prefix);
148 int config(
const std::map< std::string, std::string >& m,
const std::string& env_prefix) {
149 string host = get(m,
"HOST", env_prefix);
150 string port = get(m,
"PORT", env_prefix);
151 string auth = get(m,
"AUTH", env_prefix);
152 string channel = get(m,
"CHANNEL", env_prefix);
153 return config(d, host, port, auth, channel);
157 return plugin_libldms_msg_publish_config_defaults;
161 std::map <string, string >m;
164 if (mode != pi_init) {
167 if ( state == err ) {
168 std::cout <<
"libldms_msg_publish plugin initialize found pre-existing error" << std::endl;
174 mode = pi_pub_or_final;
179 if (mode == pi_pub_or_final) {
184 std::cout <<
"libldms_msg_publish plugin finalize on non-running plugin" << std::endl;
197 return "libldms_msg_publish";
205 std::cout <<
"Destructing libldms_msg_publish_plugin" << std::endl;
libldms_msg_publish publisher_api implementation. This plugin calls the ldms libraries for sending me...
void pause()
Pause publishing until a call to resume. Duplicate calls are allowed.
libldms_msg_publish_plugin()
int publish(std::shared_ptr< builder_api > b)
Publish the content of the builder.
static const char * adc_libldms_msg_publish_plugin_channel_default
name of the channel ADC messages go into LDMS aggregators must be subscribed to this name....
static const char * adc_libldms_msg_publish_plugin_port_default
port for channel connections; ldmsd listeners must match. Overridden with env("ADC_LIBLDMS_MSG_PUBLIS...
string_view version() const
void resume()
Resume publishing Duplicate calls are allowed.
static const char * adc_libldms_msg_publish_plugin_auth_default
authentication method for channel connections; ldmsd listeners must match. Overridden with env("ADC_L...
const std::map< const std::string, const std::string > & get_option_defaults()
Look up the settable options and their defaults.
int config(const std::map< std::string, std::string > &m, const std::string &env_prefix)
void finalize()
Stop publishing and release any resources held for managing publication.
int config(const std::map< std::string, std::string > &m)
Configure the plugin with the options given.
~libldms_msg_publish_plugin()
int initialize()
Ready the plugin to publish following the configuration options set or defaulted.
static const char * adc_libldms_msg_publish_plugin_host_default
host for channel connections; ldmsd must be listening on the host. Overridden with env("ADC_LIBLDMS_M...
Publisher plugin interface.
std::string_view string_view