diff --git a/fairmq/shmem/Manager.h b/fairmq/shmem/Manager.h index a1dd4322..08e63fec 100644 --- a/fairmq/shmem/Manager.h +++ b/fairmq/shmem/Manager.h @@ -227,8 +227,15 @@ class Manager boost::filesystem::path p = boost::process::search_path("fairmq-shmmonitor", ownPath); + bool verbose = false; + if (const char* verboseEnv = getenv("FAIRMQ_SHMMONITOR_VERBOSE")) { + if (std::string(verboseEnv) == "true") { + verbose = true; + } + } + if (!p.empty()) { - boost::process::spawn(p, "-x", "-m", "--shmid", id, "-d", "-t", "2000", env); + boost::process::spawn(p, "-x", "-m", "--shmid", id, "-d", "-t", "2000", verbose ? "--verbose" : "", env); int numTries = 0; do { try { diff --git a/fairmq/shmem/runMonitor.cxx b/fairmq/shmem/runMonitor.cxx index c83e67f7..bc197782 100644 --- a/fairmq/shmem/runMonitor.cxx +++ b/fairmq/shmem/runMonitor.cxx @@ -86,6 +86,7 @@ int main(int argc, char** argv) bool debug = false; bool cleanOnExit = false; bool getShmId = false; + bool verbose = false; int userId = -1; options_description desc("Options"); @@ -103,6 +104,7 @@ int main(int argc, char** argv) ("clean-on-exit,e", value(&cleanOnExit)->implicit_value(true), "Perform cleanup on exit") ("interval" , value(&intervalInMS)->default_value(100), "Output interval for interactive mode") ("get-shmid" , value(&getShmId)->implicit_value(true), "Translate given session id and user id to a shmem id (uses current user id if none provided)") + ("verbose" , value(&verbose)->implicit_value(true), "Verbose mode (daemon will output to a file 'fairmq-shmmonitor_log_')") ("user-id" , value(&userId)->default_value(-1), "User id (used with --get-shmid)") ("help,h", "Print help"); @@ -117,6 +119,9 @@ int main(int argc, char** argv) notify(vm); if (runAsDaemon) { + if (verbose) { + fair::Logger::InitFileSink("trace", "fairmq-shmmonitor_log"); + } daemonize(); }