Hi, A suggestion/request was raised with regard to the utilization feature: The ability to see the remaining capacity of nodes, and how the load is distributed right now.
I've added a new option "--show-utilization" of ptest to achieve that. Attached the patch. Please help review it. Thanks a lot! btw, because the following change: http://hg.clusterlabs.org/pacemaker/1.1/rev/c23bbc5262b2 was only merged into 1.1 branch. The attached patch depends on that, so it cannot be applied to devel branch by now. Will they be merged into devel branch later, or is there any consideration? Regards, Yan -- Yan Gao <y...@novell.com> Software Engineer China Server Team, OPS Engineering, Novell, Inc.
# HG changeset patch # User Yan Gao <y...@novell.com> # Date 1269420054 -28800 # Node ID 3bcedb849f50d32e8416136538ae3d14d047fedd # Parent 53be04557e146ab4e600fc6e3d1700181fee8f8a Dev: PE: (bnc#589873) Show utilization/capacity information diff -r 53be04557e14 -r 3bcedb849f50 lib/pengine/utils.c --- a/lib/pengine/utils.c Tue Mar 23 17:15:22 2010 +0100 +++ b/lib/pengine/utils.c Wed Mar 24 16:40:54 2010 +0800 @@ -388,6 +388,64 @@ } } +static void +append_dump_text(gpointer key, gpointer value, gpointer user_data) +{ + char **dump_text = user_data; + int len = 0; + char *new_text = NULL; + + len = strlen(*dump_text) + strlen(" ") + strlen(key) + strlen("=") + strlen(value) + 1; + crm_malloc0(new_text, len); + sprintf(new_text, "%s %s=%s", *dump_text, (char *)key, (char *)value); + + free(*dump_text); + *dump_text = new_text; +} + +void +dump_node_capacity(int level, const char *comment, node_t *node) +{ + int len = 0; + char *dump_text = NULL; + + len = strlen(comment) + strlen(": ") + strlen(node->details->uname) + strlen(" capacity:") + 1; + crm_malloc0(dump_text, len); + sprintf(dump_text, "%s: %s capacity:", comment, node->details->uname); + + g_hash_table_foreach(node->details->utilization, append_dump_text, &dump_text); + + if(level == 0) { + fprintf(stdout, "%s\n", dump_text); + } else { + do_crm_log_unlikely(level, "%s", dump_text); + } + + crm_free(dump_text); +} + +void +dump_rsc_utilization(int level, const char *comment, resource_t *rsc, node_t *node) +{ + int len = 0; + char *dump_text = NULL; + + len = strlen(comment) + strlen(": ") + strlen(rsc->id) + strlen(" utilization on ") + + strlen(node->details->uname) + strlen(":") + 1; + crm_malloc0(dump_text, len); + sprintf(dump_text, "%s: %s utilization on %s:", comment, rsc->id, node->details->uname); + + g_hash_table_foreach(rsc->utilization, append_dump_text, &dump_text); + + if(level == 0) { + fprintf(stdout, "%s\n", dump_text); + } else { + do_crm_log_unlikely(level, "%s", dump_text); + } + + crm_free(dump_text); +} + gint sort_rsc_index(gconstpointer a, gconstpointer b) { const resource_t *resource1 = (const resource_t*)a; diff -r 53be04557e14 -r 3bcedb849f50 lib/pengine/utils.h --- a/lib/pengine/utils.h Tue Mar 23 17:15:22 2010 +0100 +++ b/lib/pengine/utils.h Wed Mar 24 16:40:54 2010 +0800 @@ -54,6 +54,9 @@ extern void dump_node_scores(int level, resource_t *rsc, const char *comment, GListPtr nodes); +extern void dump_node_capacity(int level, const char *comment, node_t *node); +extern void dump_rsc_utilization(int level, const char *comment, resource_t *rsc, node_t *node); + /* Sorting functions */ extern gint sort_rsc_priority(gconstpointer a, gconstpointer b); extern gint sort_rsc_index(gconstpointer a, gconstpointer b); diff -r 53be04557e14 -r 3bcedb849f50 pengine/allocate.c --- a/pengine/allocate.c Tue Mar 23 17:15:22 2010 +0100 +++ b/pengine/allocate.c Wed Mar 24 16:40:54 2010 +0800 @@ -835,12 +835,22 @@ gboolean stage5(pe_working_set_t *data_set) { + slist_iter( + node, node_t, data_set->nodes, lpc, + dump_node_capacity(show_utilization?0:utilization_log_level, "Original", node); + ); + /* Take (next) highest resource, assign it and create its actions */ slist_iter( rsc, resource_t, data_set->resources, lpc, rsc->cmds->color(rsc, data_set); ); + slist_iter( + node, node_t, data_set->nodes, lpc, + dump_node_capacity(show_utilization?0:utilization_log_level, "Remaining", node); + ); + probe_resources(data_set); slist_iter( diff -r 53be04557e14 -r 3bcedb849f50 pengine/pengine.c --- a/pengine/pengine.c Tue Mar 23 17:15:22 2010 +0100 +++ b/pengine/pengine.c Wed Mar 24 16:40:54 2010 +0800 @@ -39,6 +39,8 @@ gboolean show_scores = FALSE; int scores_log_level = LOG_DEBUG_2; +gboolean show_utilization = FALSE; +int utilization_log_level = LOG_DEBUG_2; extern int transition_id; #define get_series() was_processing_error?1:was_processing_warning?2:3 diff -r 53be04557e14 -r 3bcedb849f50 pengine/pengine.h --- a/pengine/pengine.h Tue Mar 23 17:15:22 2010 +0100 +++ b/pengine/pengine.h Wed Mar 24 16:40:54 2010 +0800 @@ -168,6 +168,8 @@ extern gboolean show_scores; extern int scores_log_level; +extern gboolean show_utilization; +extern int utilization_log_level; extern const char* transition_idle_timeout; #endif diff -r 53be04557e14 -r 3bcedb849f50 pengine/ptest.c --- a/pengine/ptest.c Tue Mar 23 17:15:22 2010 +0100 +++ b/pengine/ptest.c Wed Mar 24 16:40:54 2010 +0800 @@ -124,6 +124,7 @@ {"simulate", 0, 0, 'S', "Simulate the transition's execution to find invalid graphs\n"}, {"show-scores", 0, 0, 's', "Display resource allocation scores"}, + {"show-utilization", 0, 0, 'z', "Display utilization information"}, {"all-actions", 0, 0, 'a', "Display all possible actions - even ones not part of the transition graph"}, {"live-check", 0, 0, 'L', "Connect to the CIB and use the current contents as input"}, @@ -175,7 +176,7 @@ g_mem_set_vtable(&vtable); crm_log_init("ptest", LOG_CRIT, FALSE, FALSE, 0, NULL); - crm_set_options("V?$XD:G:I:Lwx:d:aSs", "[-?Vv] -[Xxp] {other options}", long_options, + crm_set_options("V?$XD:G:I:Lwx:d:aSsz", "[-?Vv] -[Xxp] {other options}", long_options, "Calculate the cluster's response to the supplied cluster state\n"); while (1) { @@ -200,6 +201,9 @@ case 's': show_scores = TRUE; break; + case 'z': + show_utilization = TRUE; + break; case 'x': xml_file = optarg; break; diff -r 53be04557e14 -r 3bcedb849f50 pengine/utils.c --- a/pengine/utils.c Tue Mar 23 17:15:22 2010 +0100 +++ b/pengine/utils.c Wed Mar 24 16:40:54 2010 +0800 @@ -332,8 +332,8 @@ struct calculate_data { - node_t *node; - gboolean allocate; + node_t *node; + gboolean allocate; }; static void @@ -366,6 +366,10 @@ data.allocate = allocate; g_hash_table_foreach(rsc->utilization, do_calculate_utilization, &data); + + if (allocate) { + dump_rsc_utilization(show_utilization?0:utilization_log_level, __FUNCTION__, rsc, node); + } } gboolean
_______________________________________________ Pacemaker mailing list Pacemaker@oss.clusterlabs.org http://oss.clusterlabs.org/mailman/listinfo/pacemaker