4646#include < cstdlib>
4747#include < dlfcn.h>
4848#include < signal.h>
49+ #include < sys/time.h>
4950
5051#include " configurator.hpp"
5152#include " extensions.hpp"
5253
5354extern " C" {
5455#include " ../message_terminate.h"
56+ #include " ../message_periodic.h"
5557#include " ../plugin_parser.h"
5658#include " ../plugin_output_mgr.h"
5759#include " ../verbose.h"
@@ -88,7 +90,7 @@ termination_handler(int sig)
8890 cnt++;
8991
9092 // Send a termination request to the configurator
91- int rc = ipx_cpipe_send_term (NULL , request_type);
93+ int rc = ipx_cpipe_send (NULL , request_type);
9294 if (rc != IPX_OK) {
9395 static const char *msg = " ERROR: Signal handler: failed to send a termination request" ;
9496 write (STDOUT_FILENO, msg, strlen (msg));
@@ -568,6 +570,22 @@ ipx_configurator::termination_send_msg()
568570 m_term_sent = m_running_inputs.size ();
569571}
570572
573+ void
574+ ipx_configurator::periodic_send_msg (uint32_t *periodic_message_sequence)
575+ {
576+ for (auto &input : m_running_inputs) {
577+ ipx_msg_periodic_t *msg = ipx_msg_periodic_create (*periodic_message_sequence);
578+ if (!msg) {
579+ IPX_ERROR (comp_str, " Can't create periodic message!" , ' \0 ' );
580+ termination_send_msg ();
581+ return ;
582+ }
583+
584+ ipx_fpipe_write (input->get_feedback (), ipx_msg_periodic2base (msg));
585+ }
586+ (*periodic_message_sequence)++;
587+ }
588+
571589int
572590ipx_configurator::run (ipx_controller *ctrl)
573591{
@@ -595,6 +613,9 @@ ipx_configurator::run(ipx_controller *ctrl)
595613 // Collector is running -> process termination/reconfiguration requests
596614 m_state = STATUS::RUNNING;
597615 bool terminate = false ;
616+
617+ uint32_t periodic_message_sequence = 0 ;
618+
598619 while (!terminate) {
599620 struct ipx_cpipe_req req;
600621 if (ipx_cpipe_receive (&req) != IPX_OK) {
@@ -609,6 +630,9 @@ ipx_configurator::run(ipx_controller *ctrl)
609630 case IPX_CPIPE_TYPE_TERM_DONE:
610631 terminate = termination_handle (req, ctrl);
611632 break ;
633+ case IPX_CPIPE_TYPE_PERIODIC:
634+ periodic_send_msg (&periodic_message_sequence);
635+ break ;
612636 default :
613637 IPX_ERROR (comp_str, " Ignoring unknown configuration request!" , ' \0 ' );
614638 continue ;
0 commit comments