Commit 8947c2c0 authored by Philip Carns's avatar Philip Carns
Browse files

new (optional) configure argument --with-logpath-by-env

- Allows the administrator, at configure time, to specify a list of
  environment variables to check at runtime to find the absolute path to
  place log files in, overriding the normal year/month/day hierarchy
- Falls back to --with-logpath path (if specified) if there is no
  environment variable match
- example: --with-logpath-by-env=FOO,HOME --with-logpath=/log will cause
  darshan to try (in order):
  - $FOO
  - $HOME
  - /log/<year>/<month>/<day>


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@428 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 48c45903
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
Darshan Release Change Log Darshan Release Change Log
-------------------------- --------------------------
darshan-2.1.1
=============
* added --with-logpath-by-env configure option to allow absolute
log path to be specified via environment variable
darshan-2.1.0 darshan-2.1.0
============= =============
* additinoal environment variables to control log, jobid and * additinoal environment variables to control log, jobid and
......
...@@ -664,6 +664,7 @@ with_mpi ...@@ -664,6 +664,7 @@ with_mpi
enable_ld_preload enable_ld_preload
with_mem_align with_mem_align
with_zlib_for_mpi with_zlib_for_mpi
with_log_path_by_env
with_log_path with_log_path
with_jobid_env with_jobid_env
' '
...@@ -1296,6 +1297,7 @@ Optional Packages: ...@@ -1296,6 +1297,7 @@ Optional Packages:
--with-mpi=<dir> Location of the MPI installation --with-mpi=<dir> Location of the MPI installation
--with-mem-align=<num> Memory alignment in bytes --with-mem-align=<num> Memory alignment in bytes
--with-zlib-for-mpi=<dir> base dir for zlib to use on mpi processes --with-zlib-for-mpi=<dir> base dir for zlib to use on mpi processes
--with-log-path-by-env=<env var list> Comma separated list of environment variables to check for log path location before --with-log-path path
--with-log-path=<path> Location to store log files at run time --with-log-path=<path> Location to store log files at run time
--with-jobid-env=<name> Name of environment variable that stores the jobid --with-jobid-env=<name> Name of environment variable that stores the jobid
(specify "NONE" if no appropriate environment variable is available: (specify "NONE" if no appropriate environment variable is available:
...@@ -3662,6 +3664,24 @@ fi ...@@ -3662,6 +3664,24 @@ fi
# Check whether --with-log-path-by-env was given.
if test "${with_log_path_by_env+set}" = set; then :
withval=$with_log_path_by_env; if test x$withval = xyes; then
as_fn_error $? "--with-log-path-by-env must be given at least one variable name" "$LINENO" 5
else
cat >>confdefs.h <<_ACEOF
#define __CP_LOG_ENV "${withval}"
_ACEOF
__CP_LOG_ENV="${withval}"
GOT_LOG_PATH=1
fi
fi
# Check whether --with-log-path was given. # Check whether --with-log-path was given.
if test "${with_log_path+set}" = set; then : if test "${with_log_path+set}" = set; then :
withval=$with_log_path; if test x$withval = xyes; then withval=$with_log_path; if test x$withval = xyes; then
...@@ -3704,7 +3724,7 @@ if test x$GOT_ALIGNMENT != x1; then ...@@ -3704,7 +3724,7 @@ if test x$GOT_ALIGNMENT != x1; then
as_fn_error $? "must provide --with-mem-align=<num> argument to configure." "$LINENO" 5 as_fn_error $? "must provide --with-mem-align=<num> argument to configure." "$LINENO" 5
fi fi
if test x$GOT_LOG_PATH != x1; then if test x$GOT_LOG_PATH != x1; then
as_fn_error $? "must provide --with-log-path=<path> argument to configure." "$LINENO" 5 as_fn_error $? "must provide --with-log-path=<path> _or_ --with-log-path-by-env=<variable list> argument to configure." "$LINENO" 5
fi fi
if test x$GOT_JOBID != x1; then if test x$GOT_JOBID != x1; then
as_fn_error $? "must provide --with-jobid-env=<name> argument to configure." "$LINENO" 5 as_fn_error $? "must provide --with-jobid-env=<name> argument to configure." "$LINENO" 5
......
...@@ -58,6 +58,17 @@ AC_ARG_WITH(zlib-for-mpi, ...@@ -58,6 +58,17 @@ AC_ARG_WITH(zlib-for-mpi,
fi fi
) )
AC_ARG_WITH(log-path-by-env,
[ --with-log-path-by-env=<env var list> Comma separated list of environment variables to check for log path location before --with-log-path path],
if test x$withval = xyes; then
AC_MSG_ERROR(--with-log-path-by-env must be given at least one variable name)
else
AC_DEFINE_UNQUOTED(__CP_LOG_ENV, "${withval}", Comma separated list of env. variables to use for log path)
__CP_LOG_ENV="${withval}"
GOT_LOG_PATH=1
fi
)
AC_ARG_WITH(log-path, AC_ARG_WITH(log-path,
[ --with-log-path=<path> Location to store log files at run time], [ --with-log-path=<path> Location to store log files at run time],
if test x$withval = xyes; then if test x$withval = xyes; then
...@@ -89,7 +100,7 @@ if test x$GOT_ALIGNMENT != x1; then ...@@ -89,7 +100,7 @@ if test x$GOT_ALIGNMENT != x1; then
AC_MSG_ERROR(must provide --with-mem-align=<num> argument to configure.) AC_MSG_ERROR(must provide --with-mem-align=<num> argument to configure.)
fi fi
if test x$GOT_LOG_PATH != x1; then if test x$GOT_LOG_PATH != x1; then
AC_MSG_ERROR(must provide --with-log-path=<path> argument to configure.) AC_MSG_ERROR(must provide --with-log-path=<path> _or_ --with-log-path-by-env=<variable list> argument to configure.)
fi fi
if test x$GOT_JOBID != x1; then if test x$GOT_JOBID != x1; then
AC_MSG_ERROR(must provide --with-jobid-env=<name> argument to configure.) AC_MSG_ERROR(must provide --with-jobid-env=<name> argument to configure.)
......
...@@ -81,6 +81,9 @@ ...@@ -81,6 +81,9 @@
# endif # endif
#endif #endif
/* Comma separated list of env. variables to use for log path */
#undef __CP_LOG_ENV
/* Location to store log files at run time */ /* Location to store log files at run time */
#undef __CP_LOG_PATH #undef __CP_LOG_PATH
......
...@@ -434,6 +434,11 @@ void darshan_shutdown(int timing_flag) ...@@ -434,6 +434,11 @@ void darshan_shutdown(int timing_flag)
time_t start_time_tmp = 0; time_t start_time_tmp = 0;
uint64_t logmod; uint64_t logmod;
char hname[HOST_NAME_MAX]; char hname[HOST_NAME_MAX];
char* logpath_override = NULL;
#ifdef __CP_LOG_ENV
char env_check[256];
char* env_tok;
#endif
CP_LOCK(); CP_LOCK();
if(!darshan_global_job) if(!darshan_global_job)
...@@ -602,21 +607,70 @@ void darshan_shutdown(int timing_flag) ...@@ -602,21 +607,70 @@ void darshan_shutdown(int timing_flag)
(void) gethostname(hname, sizeof(hname)); (void) gethostname(hname, sizeof(hname));
logmod = darshan_hash((void*)hname,strlen(hname),0); logmod = darshan_hash((void*)hname,strlen(hname),0);
ret = snprintf(logfile_name, PATH_MAX, /* see if darshan was configured using the --with-logpath-by-env
"%s/%d/%d/%d/%s_%s_id%d_%d-%d-%d-%" PRIu64 ".darshan_partial", * argument, which allows the user to specify an absolute path to
logpath, (my_tm->tm_year+1900), * place logs via an env variable.
(my_tm->tm_mon+1), my_tm->tm_mday, */
cuser, __progname, jobid, #ifdef __CP_LOG_ENV
(my_tm->tm_mon+1), /* just silently skip if the environment variable list is too big */
my_tm->tm_mday, if(strlen(__CP_LOG_ENV) < 256)
(my_tm->tm_hour*60*60 + my_tm->tm_min*60 + my_tm->tm_sec), {
logmod); /* copy env variable list to a temporary buffer */
if(ret == (PATH_MAX-1)) strcpy(env_check, __CP_LOG_ENV);
/* tokenize the comma-separated list */
env_tok = strtok(env_check, ",");
if(env_tok)
{
do
{
/* check each env variable in order */
logpath_override = getenv(env_tok);
if(logpath_override)
{
/* stop as soon as we find a match */
break;
}
}while((env_tok = strtok(NULL, ",")));
}
}
#endif
if(logpath_override)
{
ret = snprintf(logfile_name, PATH_MAX,
"%s/%s_%s_id%d_%d-%d-%d-%" PRIu64 ".darshan_partial",
logpath_override,
cuser, __progname, jobid,
(my_tm->tm_mon+1),
my_tm->tm_mday,
(my_tm->tm_hour*60*60 + my_tm->tm_min*60 + my_tm->tm_sec),
logmod);
if(ret == (PATH_MAX-1))
{
/* file name was too big; squish it down */
snprintf(logfile_name, PATH_MAX,
"%s/id%d.darshan_partial",
logpath_override, jobid);
}
}
else
{ {
/* file name was too big; squish it down */ ret = snprintf(logfile_name, PATH_MAX,
snprintf(logfile_name, PATH_MAX, "%s/%d/%d/%d/%s_%s_id%d_%d-%d-%d-%" PRIu64 ".darshan_partial",
"%s/id%d.darshan_partial", logpath, (my_tm->tm_year+1900),
logpath, jobid); (my_tm->tm_mon+1), my_tm->tm_mday,
cuser, __progname, jobid,
(my_tm->tm_mon+1),
my_tm->tm_mday,
(my_tm->tm_hour*60*60 + my_tm->tm_min*60 + my_tm->tm_sec),
logmod);
if(ret == (PATH_MAX-1))
{
/* file name was too big; squish it down */
snprintf(logfile_name, PATH_MAX,
"%s/id%d.darshan_partial",
logpath, jobid);
}
} }
/* add jobid */ /* add jobid */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment