From 45f7beaa3a603e9b94c4ab22b5e2186fcf350f1f Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Mon, 2 Feb 2009 22:22:57 +0000 Subject: [PATCH] finish work for slurmdbd to report state to sacctmgr --- NEWS | 1 + src/api/config_info.c | 2 +- src/slurmdbd/proc_req.c | 11 +-- src/slurmdbd/read_config.c | 180 ++++++++++++++++++++++++++++++++++++- src/slurmdbd/read_config.h | 7 +- 5 files changed, 186 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 6b4e71d98b3..88eb8a6bb92 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ documents those changes that are of interest to users and admins. upon partitions that already exist). -- Added environment variable SLURM_RESTART_COUNT to batch jobs to indicated the count of job restarts made. + -- Added sacctmgr command "show config". * Changes in SLURM 1.4.0-pre7 ============================= diff --git a/src/api/config_info.c b/src/api/config_info.c index 488dbd3ea52..fd1ed0fe305 100644 --- a/src/api/config_info.c +++ b/src/api/config_info.c @@ -330,7 +330,7 @@ void slurm_print_ctl_conf ( FILE* out, slurm_ctl_conf_ptr->slurmd_spooldir); fprintf(out, "SlurmdTimeout = %u sec\n", slurm_ctl_conf_ptr->slurmd_timeout); - fprintf(out, "SLURM_CONFIG_FILE = %s\n", + fprintf(out, "SLURM_CONF (Path) = %s\n", slurm_ctl_conf_ptr->slurm_conf); fprintf(out, "SLURM_VERSION = %s\n", SLURM_VERSION); fprintf(out, "SrunEpilog = %s\n", diff --git a/src/slurmdbd/proc_req.c b/src/slurmdbd/proc_req.c index 349667fa611..54fc6cc3c44 100644 --- a/src/slurmdbd/proc_req.c +++ b/src/slurmdbd/proc_req.c @@ -1058,16 +1058,7 @@ static int _get_config(slurmdbd_conn_t *slurmdbd_conn, debug2("DBD_GET_CONFIG: called"); /* No message body to unpack */ - list_msg.my_list = list_create(NULL); -test = xmalloc(sizeof(config_key_pair_t)); -test->name = xstrdup("NAME1"); -test->value = xstrdup("VALUE1"); -list_append(list_msg.my_list, test); -test = xmalloc(sizeof(config_key_pair_t)); -test->name = xstrdup("NAME2"); -test->value = xstrdup("VALUE2"); -/* NEED TO FREE LIST and it's contents */ - list_append(list_msg.my_list, test); + list_msg.my_list = dump_config(); *out_buffer = init_buf(1024); pack16((uint16_t) DBD_GOT_CONFIG, *out_buffer); slurmdbd_pack_list_msg(slurmdbd_conn->rpc_version, diff --git a/src/slurmdbd/read_config.c b/src/slurmdbd/read_config.c index d7acc2d67bb..da7ada7e7bf 100644 --- a/src/slurmdbd/read_config.c +++ b/src/slurmdbd/read_config.c @@ -2,7 +2,7 @@ * read_config.c - functions for reading slurmdbd.conf ***************************************************************************** * Copyright (C) 2003-2007 The Regents of the University of California. - * Copyright (C) 2008 Lawrence Livermore National Security. + * Copyright (C) 2008-2009 Lawrence Livermore National Security. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Jette <jette1@llnl.gov> * LLNL-CODE-402394. @@ -39,15 +39,19 @@ #include <pwd.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <slurm/slurm_errno.h> -#include "src/common/macros.h" #include "src/common/log.h" +#include "src/common/list.h" +#include "src/common/macros.h" #include "src/common/parse_config.h" +#include "src/common/parse_time.h" #include "src/common/read_config.h" +#include "src/common/slurm_accounting_storage.h" #include "src/common/uid.h" #include "src/common/xmalloc.h" #include "src/common/xstring.h" @@ -61,6 +65,8 @@ pthread_mutex_t conf_mutex = PTHREAD_MUTEX_INITIALIZER; static void _clear_slurmdbd_conf(void); static char * _get_conf_path(void); +static time_t boot_time; + /* * free_slurmdbd_conf - free storage associated with the global variable * slurmdbd_conf @@ -148,8 +154,10 @@ extern int read_slurmdbd_conf(void) /* Set initial values */ slurm_mutex_lock(&conf_mutex); - if (slurmdbd_conf == NULL) + if (slurmdbd_conf == NULL) { slurmdbd_conf = xmalloc(sizeof(slurm_dbd_conf_t)); + boot_time = time(NULL); + } slurmdbd_conf->debug_level = LOG_LEVEL_INFO; _clear_slurmdbd_conf(); @@ -397,3 +405,169 @@ static char * _get_conf_path(void) return path; } + +/* Dump the configuration in name,value pairs for output to + * "sacctmgr show config", caller must call list_destroy() */ +extern List dump_config(void) +{ + config_key_pair_t *key_pair; + List my_list = list_create(destroy_acct_config_rec); + + if (!my_list) + fatal("malloc failure on list_create"); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("ArchiveDir"); + key_pair->value = xstrdup(slurmdbd_conf->archive_dir); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("ArchiveScript"); + key_pair->value = xstrdup(slurmdbd_conf->archive_script); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("AuthInfo"); + key_pair->value = xstrdup(slurmdbd_conf->auth_info); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("AuthType"); + key_pair->value = xstrdup(slurmdbd_conf->auth_type); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("BOOT_TIME"); + key_pair->value = xmalloc(128); + slurm_make_time_str ((time_t *)&boot_time, key_pair->value, 128); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("DbdAddr"); + key_pair->value = xstrdup(slurmdbd_conf->dbd_addr); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("DbdHost"); + key_pair->value = xstrdup(slurmdbd_conf->dbd_host); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("DbdPort"); + key_pair->value = xmalloc(32); + snprintf(key_pair->value, 32, "%u", slurmdbd_conf->dbd_port); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("DebugLevel"); + key_pair->value = xmalloc(32); + snprintf(key_pair->value, 32, "%u", slurmdbd_conf->debug_level); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("DefaultQOS"); + key_pair->value = xstrdup(slurmdbd_conf->default_qos); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("JobPurge"); + if(slurmdbd_conf->job_purge) { + key_pair->value = xmalloc(32); + snprintf(key_pair->value, 32, "%u months", + slurmdbd_conf->job_purge); + } else + key_pair->value = xstrdup("NONE"); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("LogFile"); + key_pair->value = xstrdup(slurmdbd_conf->log_file); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("MessageTimeout"); + key_pair->value = xmalloc(32); + snprintf(key_pair->value, 32, "%u secs", slurmdbd_conf->msg_timeout); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("PidFile"); + key_pair->value = xstrdup(slurmdbd_conf->pid_file); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("PluginDir"); + key_pair->value = xstrdup(slurmdbd_conf->plugindir); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("PrivateData"); + key_pair->value = xmalloc(128); + private_data_string(slurmdbd_conf->private_data, + key_pair->value, 128); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("SLURMDBD_CONF (path)"); + key_pair->value = _get_conf_path(); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("SLURMDBD_VERSION"); + key_pair->value = xstrdup(SLURM_VERSION); + list_append(my_list, key_pair); + + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("SlurmUser"); + key_pair->value = xmalloc(128); + snprintf(key_pair->value, 128, "%s(%u)", + slurmdbd_conf->slurm_user_name, slurmdbd_conf->slurm_user_id); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("StepPurge"); + if(slurmdbd_conf->job_purge) { + key_pair->value = xmalloc(32); + snprintf(key_pair->value, 32, "%u months", + slurmdbd_conf->step_purge); + } else + key_pair->value = xstrdup("NONE"); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("StorageHost"); + key_pair->value = xstrdup(slurmdbd_conf->storage_host); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("StorageLoc"); + key_pair->value = xstrdup(slurmdbd_conf->storage_loc); + list_append(my_list, key_pair); + + /* StoragePass should NOT be passed due to security reasons */ + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("StoragePort"); + key_pair->value = xmalloc(32); + snprintf(key_pair->value, 32, "%u", slurmdbd_conf->storage_port); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("StorageType"); + key_pair->value = xstrdup(slurmdbd_conf->storage_type); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("StorageUser"); + key_pair->value = xstrdup(slurmdbd_conf->storage_user); + list_append(my_list, key_pair); + + key_pair = xmalloc(sizeof(config_key_pair_t)); + key_pair->name = xstrdup("TrackWCKey"); + key_pair->value = xmalloc(32); + snprintf(key_pair->value, 32, "%u", slurmdbd_conf->track_wckey); + list_append(my_list, key_pair); + + return my_list; +} diff --git a/src/slurmdbd/read_config.h b/src/slurmdbd/read_config.h index 20d4c27de8d..898aa8a87a6 100644 --- a/src/slurmdbd/read_config.h +++ b/src/slurmdbd/read_config.h @@ -2,7 +2,7 @@ * read_config.h - functions and declarations for reading slurmdbd.conf ***************************************************************************** * Copyright (C) 2003-2007 The Regents of the University of California. - * Copyright (C) 2008 Lawrence Livermore National Security. + * Copyright (C) 2008-2009 Lawrence Livermore National Security. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Jette <jette1@llnl.gov> * LLNL-CODE-402394. @@ -53,6 +53,7 @@ #endif /* HAVE_CONFIG_H */ #include <time.h> +#include "src/common/list.h" #define DEFAULT_SLURMDBD_AUTHTYPE "auth/none" //#define DEFAULT_SLURMDBD_JOB_PURGE 12 @@ -124,4 +125,8 @@ extern void log_config(void); */ extern int read_slurmdbd_conf(void); +/* Dump the configuration in name,value pairs for output to + * "sacctmgr show config", caller must call list_destroy() */ +extern List dump_config(void); + #endif /* !_DBD_READ_CONFIG_H */ -- GitLab