#ifndef _hdmon_ctl_ #define _hdmon_ctl_ #include #include #include #include #include #include #include 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 &keys, vector &vals); void HostStatusPROC(vector &keys, vector &vals); void HostInfoSYSCTL(vector &keys, vector &vals); void HostInfoPROC(vector &keys, vector &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 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_