#ifndef _hdmon_ctl_ #define _hdmon_ctl_ #include <vector> #include <string> #include <thread> #include <atomic> #include <zmq.hpp> #include <JANA/JApplication.h> #include <JANA/JLogger.h> using namespace jana; using namespace std; class hdmon_ctl { public: // Construct the plugin with a pointer to the JApplication hdmon_ctl(JApplication *japp); virtual ~hdmon_ctl(); protected: // Process an incoming message (assumed to be multipart: subject, sender, text) void processMessage(const string &subject, const string &sender, const string &cmd); // These routines fill key/value vectors with host info/status void HostStatusSYSCTL(vector<string> &keys, vector<string> &vals); void HostStatusPROC(vector<string> &keys, vector<string> &vals); void HostInfoSYSCTL(vector<string> &keys, vector<string> &vals); void HostInfoPROC(vector<string> &keys, vector<string> &vals); // Helper to send a response as a multipart message (subject, sender, text) void sendMessage(const string &subject, const string &sender, const string &text); private: // Disallow default constructor hdmon_ctl(); // Unique name for this instance (based on hostname and PID) string myname; JApplication *japp; // JStreamLog jctlout; int VERBOSE = 0; std::string hdmon_level = "---"; // ZeroMQ context and sockets zmq::context_t context; zmq::socket_t subscriber; zmq::socket_t publisher; // Thread that continuously receives incoming messages std::thread recv_thread; std::thread update_thread; std::atomic<bool> running; // Endpoints for zmq sockets (can be set via configuration parameters) string sub_endpoint; // Endpoint to connect for incoming commands string pub_endpoint; // Endpoint to bind for sending responses }; #endif // _hdmon_ctl_