[ofa-general] [PATCH] opensm/perfmgr: move event_db_dump_file to common OpenSM dump dir

Sasha Khapyorsky sashak at voltaire.com
Sat Jun 14 05:51:48 PDT 2008


This places default PerfMgr port counters dump file into common OpenSM
dump files directory. Also file name definitions is only in subnet's
options, so if config is reloaded PerfMgr will take a new value.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/opensm/osm_perfmgr.h |    7 +------
 opensm/opensm/osm_perfmgr.c         |   16 ++++++++++++----
 opensm/opensm/osm_subnet.c          |    5 +++--
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/opensm/include/opensm/osm_perfmgr.h b/opensm/include/opensm/osm_perfmgr.h
index 9152f5f..50a2c32 100644
--- a/opensm/include/opensm/osm_perfmgr.h
+++ b/opensm/include/opensm/osm_perfmgr.h
@@ -72,7 +72,7 @@ extern "C" {
 *********/
 
 #define OSM_PERFMGR_DEFAULT_SWEEP_TIME_S 180
-#define OSM_PERFMGR_DEFAULT_DUMP_FILE OSM_DEFAULT_TMP_DIR "/opensm_port_counters.log"
+#define OSM_PERFMGR_DEFAULT_DUMP_FILE "opensm_port_counters.log"
 #define OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES 500
 
 /****s* OpenSM: PerfMgr/osm_perfmgr_state_t */
@@ -124,8 +124,6 @@ typedef struct _osm_perfmgr {
 	osm_perfmgr_state_t state;
 	osm_perfmgr_sweep_state_t sweep_state;
 	uint16_t sweep_time_s;
-	char *db_file;
-	char *event_db_dump_file;
 	perfmgr_db_t *db;
 	atomic32_t outstanding_queries;	/* this along with sig_query */
 	cl_event_t sig_query;	/* will throttle our querys */
@@ -145,9 +143,6 @@ typedef struct _osm_perfmgr {
 *	mad_pool
 *		Pointer to the MAD pool.
 *
-*       event_db_dump_file
-*               File to be used to dump the Port Counters
-*
 *	mad_ctrl
 *		Mad Controller
 *********/
diff --git a/opensm/opensm/osm_perfmgr.c b/opensm/opensm/osm_perfmgr.c
index 5c53c24..1633c41 100644
--- a/opensm/opensm/osm_perfmgr.c
+++ b/opensm/opensm/osm_perfmgr.c
@@ -856,7 +856,6 @@ void osm_perfmgr_shutdown(osm_perfmgr_t * const pm)
 void osm_perfmgr_destroy(osm_perfmgr_t * const pm)
 {
 	OSM_LOG_ENTER(pm->log);
-	free(pm->event_db_dump_file);
 	perfmgr_db_destroy(pm->db);
 	cl_timer_destroy(&pm->sweep_timer);
 	OSM_LOG_EXIT(pm->log);
@@ -1245,7 +1244,6 @@ osm_perfmgr_init(osm_perfmgr_t * const pm,
 	pm->state =
 	    p_opt->perfmgr ? PERFMGR_STATE_ENABLED : PERFMGR_STATE_DISABLE;
 	pm->sweep_time_s = p_opt->perfmgr_sweep_time_s;
-	pm->event_db_dump_file = strdup(p_opt->event_db_dump_file);
 	pm->max_outstanding_queries = p_opt->perfmgr_max_outstanding_queries;
 	pm->event_plugin = event_plugin;
 
@@ -1290,9 +1288,19 @@ void osm_perfmgr_clear_counters(osm_perfmgr_t * pm)
  *******************************************************************/
 void osm_perfmgr_dump_counters(osm_perfmgr_t * pm, perfmgr_db_dump_t dump_type)
 {
-	if (perfmgr_db_dump(pm->db, pm->event_db_dump_file, dump_type) != 0)
+	char path[256];
+	char *file_name;
+	if (pm->subn->opt.event_db_dump_file)
+		file_name = pm->subn->opt.event_db_dump_file;
+	else {
+		snprintf(path, sizeof(path), "%s/%s",
+			 pm->subn->opt.dump_files_dir,
+			 OSM_PERFMGR_DEFAULT_DUMP_FILE);
+		file_name = path;
+	}
+	if (perfmgr_db_dump(pm->db, file_name, dump_type) != 0)
 		OSM_LOG(pm->log, OSM_LOG_ERROR, "Failed to dump file %s : %s",
-			pm->event_db_dump_file, strerror(errno));
+			file_name, strerror(errno));
 }
 
 /*******************************************************************
diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index b1486ca..1bf3daf 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -427,7 +427,7 @@ void osm_subn_set_default_opt(IN osm_subn_opt_t * const p_opt)
 	p_opt->perfmgr_sweep_time_s = OSM_PERFMGR_DEFAULT_SWEEP_TIME_S;
 	p_opt->perfmgr_max_outstanding_queries =
 	    OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES;
-	p_opt->event_db_dump_file = OSM_PERFMGR_DEFAULT_DUMP_FILE;
+	p_opt->event_db_dump_file = NULL; /* use default */
 #endif				/* ENABLE_OSM_PERF_MGR */
 
 	p_opt->event_plugin_name = OSM_DEFAULT_EVENT_PLUGIN_NAME;
@@ -1600,7 +1600,8 @@ int osm_subn_write_conf_file(char *file_name, IN osm_subn_opt_t *const p_opts)
 	fprintf(opts_file,
 		"#\n# Event DB Options\n#\n"
 		"# Dump file to dump the events to\n"
-		"event_db_dump_file %s\n\n", p_opts->event_db_dump_file);
+		"event_db_dump_file %s\n\n", p_opts->event_db_dump_file ?
+		p_opts->event_db_dump_file : null_str);
 #endif				/* ENABLE_OSM_PERF_MGR */
 
 	fprintf(opts_file,
-- 
1.5.5.1.178.g1f811




More information about the general mailing list