From 8d59bc607adf50397467f310a8def7bf7aa2a7ba Mon Sep 17 00:00:00 2001 From: Sara Walton Date: Tue, 19 Dec 2023 23:05:33 -0700 Subject: [PATCH] adding LDMS switch and fixing env checks/messages --- .github/workflows/darshan_ldms_test_ci.yml | 1 + darshan-runtime/lib/darshan-core.c | 5 +-- darshan-runtime/lib/darshan-ldms.c | 41 +++++++++++++++------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.github/workflows/darshan_ldms_test_ci.yml b/.github/workflows/darshan_ldms_test_ci.yml index cc27a7c0d..91fd4b42a 100644 --- a/.github/workflows/darshan_ldms_test_ci.yml +++ b/.github/workflows/darshan_ldms_test_ci.yml @@ -72,6 +72,7 @@ jobs: export DARSHAN_LDMS_HOST=localhost export DARSHAN_LDMS_XPRT=sock export DARSHAN_LDMS_AUTH=none + export DARSHAN_LDMS_ENABLE= export DARSHAN_LDMS_ENABLE_MPIIO= export DARSHAN_LDMS_ENABLE_POSIX= export DARSHAN_LDMS_ENABLE_STDIO= diff --git a/darshan-runtime/lib/darshan-core.c b/darshan-runtime/lib/darshan-core.c index a3b6bdec6..d3b15d3e8 100644 --- a/darshan-runtime/lib/darshan-core.c +++ b/darshan-runtime/lib/darshan-core.c @@ -354,8 +354,9 @@ void darshan_core_initialize(int argc, char **argv) } #ifdef HAVE_LDMS - /* pass init_core to darshan-ldms connector initialization*/ - darshan_ldms_connector_initialize(init_core); + /* check if user turns on LDMS -- pass init_core to darshan-ldms connector initialization*/ + if (getenv("DARSHAN_LDMS_ENABLE")) + darshan_ldms_connector_initialize(init_core); #endif /* if darshan was successfully initialized, set the global pointer diff --git a/darshan-runtime/lib/darshan-ldms.c b/darshan-runtime/lib/darshan-ldms.c index be101c1f1..250b0f48e 100644 --- a/darshan-runtime/lib/darshan-ldms.c +++ b/darshan-runtime/lib/darshan-ldms.c @@ -87,8 +87,10 @@ ldms_t setup_connection(const char *xprt, const char *host, return NULL; } sem_timedwait(&dC.conn_sem, &ts); - if (dC.conn_status) + if (dC.conn_status){ + darshan_core_fprintf(stderr, "LDMS library: Error %i setting up connection to LDMS streams daemon.\n", dC.conn_status); return NULL; + } return dC.ldms_g; } @@ -150,26 +152,39 @@ void darshan_ldms_connector_initialize(struct darshan_core_runtime *init_core) dC.hdf5_enable_ldms = 0; } - if (!getenv("DARSHAN_LDMS_STREAM")) - dC.env_ldms_stream = "darshanConnector"; - else - dC.env_ldms_stream = getenv("DARSHAN_LDMS_STREAM"); - const char* env_ldms_xprt = getenv("DARSHAN_LDMS_XPRT"); const char* env_ldms_host = getenv("DARSHAN_LDMS_HOST"); const char* env_ldms_port = getenv("DARSHAN_LDMS_PORT"); const char* env_ldms_auth = getenv("DARSHAN_LDMS_AUTH"); + dC.env_ldms_stream = getenv("DARSHAN_LDMS_STREAM"); + + /* Check/set LDMS deamon connection */ + if (!env_ldms_xprt || *env_ldms_xprt == '\0'){ + darshan_core_fprintf(stderr, "LDMS library: darshanConnector - transport for LDMS streams deamon connection is not set. Setting to default value \"sock\".\n"); + env_ldms_xprt = "sock";} + + if (!env_ldms_host || *env_ldms_host == '\0'){ + darshan_core_fprintf(stderr, "LDMS library: darshanConnector - hostname for LDMS streams deamon connection is not set. Setting to default value \"localhost\".\n"); + env_ldms_host = "localhost";} + + if (!env_ldms_port || *env_ldms_port == '\0'){ + darshan_core_fprintf(stderr, "LDMS library: darshanConnector - port for LDMS streams deamon connection is not set. Setting to default value \"412\".\n"); + env_ldms_port = "412";} + + if (!env_ldms_auth || *env_ldms_auth == '\0'){ + darshan_core_fprintf(stderr, "LDMS library: darshanConnector - authentication for LDMS streams deamon connection is not set. Setting to default value \"munge\".\n"); + env_ldms_auth = "munge";} + + if (!dC.env_ldms_stream || *dC.env_ldms_stream == '\0'){ + darshan_core_fprintf(stderr, "LDMS library: darshanConnector - stream name for LDMS streams deamon connection is not set. Setting to default value \"darshanConnector\".\n"); + dC.env_ldms_stream = "darshanConnector";} - /* Check/set LDMS transport type */ - if (!env_ldms_xprt || !env_ldms_host || !env_ldms_port || !env_ldms_auth){ - darshan_core_fprintf(stderr, "LDMS library: darshanConnector - transport, host, port or authentication for LDMS streams daemon connection is not set -- exiting.\n"); - return; - } pthread_mutex_lock(&dC.ln_lock); + dC.ldms_darsh = setup_connection(env_ldms_xprt, env_ldms_host, env_ldms_port, env_ldms_auth); - if (dC.conn_status != 0) { - darshan_core_fprintf(stderr, "LDMS library: darshanConnector - error %i setting up connection to LDMS streams daemon -- exiting.\n", dC.conn_status); + + if (dC.ldms_darsh == NULL){ pthread_mutex_unlock(&dC.ln_lock); return; }