[ofa-general] [PATCH] opensm: Add "perfmgr print_counters node" to the console to print individual values
Ira Weiny
weiny2 at llnl.gov
Mon Dec 17 17:30:14 PST 2007
>From 14671d63a4315a98a7f8ed17ece2bd833aed39f2 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Fri, 14 Dec 2007 15:57:30 -0800
Subject: [PATCH] Add "perfmgr print_counters node" to the console to print individual values
directly on the console.
Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
opensm/include/opensm/osm_perfmgr.h | 2 +
opensm/include/opensm/osm_perfmgr_db.h | 2 +
opensm/opensm/osm_console.c | 10 +++++++
opensm/opensm/osm_perfmgr.c | 14 +++++++++
opensm/opensm/osm_perfmgr_db.c | 46 ++++++++++++++++++++++++++++++++
5 files changed, 74 insertions(+), 0 deletions(-)
diff --git a/opensm/include/opensm/osm_perfmgr.h b/opensm/include/opensm/osm_perfmgr.h
index 0dd3ce4..4bd05f5 100644
--- a/opensm/include/opensm/osm_perfmgr.h
+++ b/opensm/include/opensm/osm_perfmgr.h
@@ -219,6 +219,8 @@ inline static uint16_t osm_perfmgr_get_sweep_time_s(osm_perfmgr_t * p_perfmgr)
void osm_perfmgr_clear_counters(osm_perfmgr_t * p_perfmgr);
void osm_perfmgr_dump_counters(osm_perfmgr_t * p_perfmgr,
perfmgr_db_dump_t dump_type);
+void osm_perfmgr_print_counters(osm_perfmgr_t *pm, char *nodename,
+ FILE *fp);
ib_api_status_t osm_perfmgr_bind(osm_perfmgr_t * const p_perfmgr,
const ib_net64_t port_guid);
diff --git a/opensm/include/opensm/osm_perfmgr_db.h b/opensm/include/opensm/osm_perfmgr_db.h
index 0991102..2c4c520 100644
--- a/opensm/include/opensm/osm_perfmgr_db.h
+++ b/opensm/include/opensm/osm_perfmgr_db.h
@@ -186,6 +186,8 @@ perfmgr_db_err_t perfmgr_db_clear_prev_dc(perfmgr_db_t * db, uint64_t guid,
void perfmgr_db_clear_counters(perfmgr_db_t * db);
perfmgr_db_err_t perfmgr_db_dump(perfmgr_db_t * db, char *file,
perfmgr_db_dump_t dump_type);
+void perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp);
+void perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t guid, FILE *fp);
/** =========================================================================
* helper functions to fill in the various db objects from wire objects
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index f669240..5407209 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -180,6 +180,8 @@ static void help_perfmgr(FILE * out, int detail)
" [clear_counters] -- clear the counters stored\n");
fprintf(out,
" [dump_counters [mach]] -- dump the counters (optionally in [mach]ine readable format)\n");
+ fprintf(out,
+ " [print_counters <nodename|nodeguid>] -- print the counters for the specified node\n");
}
}
#endif /* ENABLE_OSM_PERF_MGR */
@@ -796,6 +798,14 @@ static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
osm_perfmgr_dump_counters(&(p_osm->perfmgr),
PERFMGR_EVENT_DB_DUMP_HR);
}
+ } else if (strcmp(p_cmd, "print_counters") == 0) {
+ p_cmd = next_token(p_last);
+ if (p_cmd) {
+ osm_perfmgr_print_counters(&(p_osm->perfmgr), p_cmd, out);
+ } else {
+ fprintf(out,
+ "print_counters requires a node name to be specified\n");
+ }
} else if (strcmp(p_cmd, "sweep_time") == 0) {
p_cmd = next_token(p_last);
if (p_cmd) {
diff --git a/opensm/opensm/osm_perfmgr.c b/opensm/opensm/osm_perfmgr.c
index f2024ea..310e8cb 100644
--- a/opensm/opensm/osm_perfmgr.c
+++ b/opensm/opensm/osm_perfmgr.c
@@ -1335,4 +1335,18 @@ void osm_perfmgr_dump_counters(osm_perfmgr_t * pm, perfmgr_db_dump_t dump_type)
pm->event_db_dump_file, strerror(errno));
}
+/*******************************************************************
+ * Have the DB print its information to the fp specified
+ *******************************************************************/
+void
+osm_perfmgr_print_counters(osm_perfmgr_t *pm, char *nodename, FILE *fp)
+{
+ uint64_t guid = strtoull(nodename, NULL, 0);
+ if (guid == 0 && errno == EINVAL) {
+ perfmgr_db_print_by_name(pm->db, nodename, fp);
+ } else {
+ perfmgr_db_print_by_guid(pm->db, guid, fp);
+ }
+}
+
#endif /* ENABLE_OSM_PERF_MGR */
diff --git a/opensm/opensm/osm_perfmgr_db.c b/opensm/opensm/osm_perfmgr_db.c
index 35f77ed..de36cad 100644
--- a/opensm/opensm/osm_perfmgr_db.c
+++ b/opensm/opensm/osm_perfmgr_db.c
@@ -677,6 +677,52 @@ static void __db_dump(cl_map_item_t * const p_map_item, void *context)
}
/**********************************************************************
+ * print node data to fp
+ **********************************************************************/
+void
+perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp)
+{
+ cl_map_item_t *item = NULL;
+ _db_node_t *node = NULL;
+
+ cl_plock_acquire(&(db->lock));
+
+ /* find the node */
+ item = cl_qmap_head(&(db->pc_data));
+ while (item != cl_qmap_end(&(db->pc_data))) {
+ node = (_db_node_t *)item;
+ if (strcmp(node->node_name, nodename) == 0) {
+ __dump_node_hr(node, fp);
+ goto done;
+ }
+ item = cl_qmap_next(item);
+ }
+
+ fprintf(fp, "Node %s not found...\n", nodename);
+done:
+ cl_plock_release(&(db->lock));
+}
+
+/**********************************************************************
+ * print node data to fp
+ **********************************************************************/
+void
+perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t nodeguid, FILE *fp)
+{
+ cl_map_item_t *node = NULL;
+
+ cl_plock_acquire(&(db->lock));
+
+ node = cl_qmap_get(&(db->pc_data), nodeguid);
+ if (node != cl_qmap_end(&(db->pc_data)))
+ __dump_node_hr((_db_node_t *)node, fp);
+ else
+ fprintf(fp, "Node %"PRIx64" not found...\n", nodeguid);
+
+ cl_plock_release(&(db->lock));
+}
+
+/**********************************************************************
* dump the data to the file "file"
**********************************************************************/
perfmgr_db_err_t
--
1.5.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-perfmgr-print_counters-node-to-the-console-to.patch
Type: application/octet-stream
Size: 5814 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20071217/607a8b8c/attachment.obj>
More information about the general
mailing list