19 #define FILTER_STR { PCMK__FAIL_COUNT_PREFIX, PCMK__LAST_FAILURE_PREFIX, \ 20 "shutdown", "terminate", "standby", "probe_complete", \ 24 compare_attribute(gconstpointer a, gconstpointer b)
28 rc = strcmp((
const char *)a, (
const char *)b);
49 const char *attrname,
int *expected_score)
53 for (gIter = rsc_list; gIter != NULL; gIter = gIter->next) {
55 const char *
type = g_hash_table_lookup(rsc->
meta,
"type");
56 const char *
name = NULL;
57 GHashTable *params = NULL;
60 if (add_extra_info(node, rsc->
children, data_set, attrname,
71 name = g_hash_table_lookup(params,
"name");
79 int host_list_num = 0;
80 const char *hosts = g_hash_table_lookup(params,
"host_list");
81 const char *multiplier = g_hash_table_lookup(params,
"multiplier");
85 char **host_list = g_strsplit(hosts,
" ", 0);
86 host_list_num = g_strv_length(host_list);
87 g_strfreev(host_list);
90 if ((multiplier == NULL)
99 *expected_score = host_list_num * multiplier_i;
108 filter_attr_list(GList *attr_list,
char *
name)
116 for (i = 0; filt_str[i] != NULL; i++) {
117 if (g_str_has_prefix(
name, filt_str[i])) {
122 return g_list_insert_sorted(attr_list,
name, compare_attribute);
126 get_operation_list(xmlNode *rsc_entry) {
127 GList *op_list = NULL;
128 xmlNode *rsc_op = NULL;
130 for (rsc_op = pcmk__xe_first_child(rsc_entry); rsc_op != NULL;
131 rsc_op = pcmk__xe_next(rsc_op)) {
152 op_list = g_list_append(op_list, rsc_op);
161 add_dump_node(gpointer key, gpointer value, gpointer user_data)
163 xmlNodePtr node = user_data;
168 append_dump_text(gpointer key, gpointer value, gpointer user_data)
170 char **dump_text = user_data;
172 *dump_text, (
char *)key, (
char *)value);
175 *dump_text = new_text;
179 failed_action_string(xmlNodePtr xml_op) {
185 time_t last_change = 0;
202 "='%s', queued=%sms, exec=%sms",
203 op_key ? op_key :
ID(xml_op),
205 services_ocf_exitcode_str(
rc),
rc,
207 services_lrm_status_str(status),
208 exit_reason ? exit_reason :
"none",
217 return crm_strdup_printf(
"%s on %s '%s' (%d): call=%s, status=%s, exitreason='%s'",
218 op_key ? op_key :
ID(xml_op),
220 services_ocf_exitcode_str(
rc),
rc,
222 services_lrm_status_str(status),
223 exit_reason ? exit_reason :
"none");
230 xmlNode *stack =
get_xpath_object(
"//nvpair[@name='cluster-infrastructure']",
231 data_set->
input, LOG_DEBUG);
236 last_changed_string(
const char *last_written,
const char *user,
237 const char *client,
const char *origin) {
238 if (last_written != NULL || user != NULL || client != NULL || origin != NULL) {
240 last_written ? last_written :
"",
243 client ?
" via " :
"",
244 client ? client :
"",
245 origin ?
" on " :
"",
246 origin ? origin :
"");
253 op_history_string(xmlNode *xml_op,
const char *task,
const char *interval_ms_s,
254 int rc, gboolean print_timing) {
256 char *interval_str = NULL;
259 if (interval_ms_s && !pcmk__str_eq(interval_ms_s,
"0",
pcmk__str_casei)) {
266 char *last_change_str = NULL;
267 char *exec_str = NULL;
268 char *queue_str = NULL;
270 const char *value = NULL;
297 interval_str ? interval_str :
"",
298 last_change_str ? last_change_str :
"",
299 exec_str ? exec_str :
"",
300 queue_str ? queue_str :
"",
301 rc, services_ocf_exitcode_str(
rc));
303 if (last_change_str) {
304 free(last_change_str);
316 interval_str ?
":" :
"",
317 interval_str ? interval_str :
"");
328 resource_history_string(
pe_resource_t *rsc,
const char *rsc_id, gboolean all,
329 int failcount, time_t last_failure) {
334 }
else if (all || failcount || last_failure > 0) {
335 char *failcount_s = NULL;
336 char *lastfail_s = NULL;
342 failcount_s = strdup(
"");
344 if (last_failure > 0) {
352 lastfail_s? lastfail_s :
"");
362 PCMK__OUTPUT_ARGS(
"cluster-summary",
"pe_working_set_t *",
"unsigned int",
"unsigned int")
366 unsigned int section_opts = va_arg(args,
unsigned int);
367 unsigned int show_opts = va_arg(args,
unsigned int);
370 const char *stack_s = get_cluster_stack(data_set);
374 out->message(out,
"cluster-stack", stack_s);
380 data_set->
input, LOG_DEBUG);
381 const char *dc_version_s = dc_version?
388 out->message(out,
"cluster-dc", data_set->
dc_node, quorum, dc_version_s, dc_name);
399 out->message(out,
"cluster-times", last_written, user, client, origin);
404 out->message(out,
"cluster-counts", g_list_length(data_set->
nodes),
411 out->message(out,
"cluster-options", data_set);
423 PCMK__OUTPUT_ARGS(
"cluster-summary",
"pe_working_set_t *",
"unsigned int",
"unsigned int")
427 unsigned int section_opts = va_arg(args,
unsigned int);
428 unsigned int show_opts = va_arg(args,
unsigned int);
431 const char *stack_s = get_cluster_stack(data_set);
435 out->message(out,
"cluster-stack", stack_s);
441 data_set->
input, LOG_DEBUG);
442 const char *dc_version_s = dc_version?
449 out->message(out,
"cluster-dc", data_set->
dc_node, quorum, dc_version_s, dc_name);
460 out->message(out,
"cluster-times", last_written, user, client, origin);
465 out->message(out,
"cluster-counts", g_list_length(data_set->
nodes),
477 out->begin_list(out, NULL, NULL,
"Config Options");
478 out->message(out,
"cluster-options", data_set);
494 const char *node_host = NULL;
495 const char *node_id = NULL;
504 if (host_node && host_node->
details) {
507 if (node_host == NULL) {
520 name_len += strlen(node_host) + 1;
523 name_len += strlen(node_id) + 3;
527 node_name = malloc(name_len);
531 strcat(node_name,
"@");
532 strcat(node_name, node_host);
535 strcat(node_name,
" (");
536 strcat(node_name, node_id);
537 strcat(node_name,
")");
544 ,
size_t pairs_count, ...)
546 xmlNodePtr xml_node = NULL;
555 : xmlNewChild(xml_node, NULL, (
pcmkXmlStr) tag_name, NULL);
557 va_start(args, pairs_count);
558 while(pairs_count--) {
559 const char *param_name = va_arg(args,
const char *);
560 const char *param_value = va_arg(args,
const char *);
561 if (param_name && param_value) {
577 #ifdef PCMK__COMPAT_2_0 591 unsigned int show_opts = va_arg(args,
unsigned int);
611 unsigned int show_opts = va_arg(args,
unsigned int);
615 out->list_item(out, NULL,
"%s\tprevents %s from running %son %s",
628 unsigned int show_opts G_GNUC_UNUSED = va_arg(args,
unsigned int);
631 char *weight_s = pcmk__itoa(pe_node->
weight);
638 "promoted-only", promoted_only,
645 "master_only", promoted_only,
653 "unsigned int",
"gboolean")
657 const char *prefix = va_arg(args,
const char *);
658 GList *only_rsc = va_arg(args, GList *);
659 unsigned int show_opts = va_arg(args,
unsigned int);
660 gboolean print_spacer = va_arg(args, gboolean);
662 GList *gIter, *gIter2;
669 if (prefix != NULL && !g_str_has_prefix(location->
id, prefix)) {
678 for (gIter2 = location->
node_list_rh; gIter2 != NULL; gIter2 = gIter2->next) {
683 out->message(out,
"ban", node, location, show_opts);
695 unsigned int nnodes = va_arg(args,
unsigned int);
696 int nresources = va_arg(args,
int);
697 int ndisabled = va_arg(args,
int);
698 int nblocked = va_arg(args,
int);
709 if (ndisabled && nblocked) {
724 " from further action due to failure)");
725 }
else if (ndisabled && !nblocked) {
734 }
else if (!ndisabled && nblocked) {
743 " from further action due to failure)");
757 unsigned int nnodes = va_arg(args,
unsigned int);
758 int nresources = va_arg(args,
int);
759 int ndisabled = va_arg(args,
int);
760 int nblocked = va_arg(args,
int);
762 out->list_item(out, NULL,
"%d node%s configured",
765 if (ndisabled && nblocked) {
766 out->list_item(out, NULL,
"%d resource instance%s configured " 767 "(%d DISABLED, %d BLOCKED from " 768 "further action due to failure)",
771 }
else if (ndisabled && !nblocked) {
772 out->list_item(out, NULL,
"%d resource instance%s configured " 775 }
else if (!ndisabled && nblocked) {
776 out->list_item(out, NULL,
"%d resource instance%s configured " 777 "(%d BLOCKED from further action " 781 out->list_item(out, NULL,
"%d resource instance%s configured",
791 unsigned int nnodes = va_arg(args,
unsigned int);
792 int nresources = va_arg(args,
int);
793 int ndisabled = va_arg(args,
int);
794 int nblocked = va_arg(args,
int);
799 char *s = pcmk__itoa(nnodes);
803 s = pcmk__itoa(nresources);
807 s = pcmk__itoa(ndisabled);
811 s = pcmk__itoa(nblocked);
818 PCMK__OUTPUT_ARGS(
"cluster-dc",
"pe_node_t *",
"const char *",
"const char *",
"char *")
822 const char *quorum = va_arg(args,
const char *);
823 const char *dc_version_s = va_arg(args,
const char *);
824 char *dc_name = va_arg(args,
char *);
833 dc_name, dc_version_s ? dc_version_s :
"unknown");
838 dc_name, dc_version_s ? dc_version_s :
"unknown");
852 PCMK__OUTPUT_ARGS(
"cluster-dc",
"pe_node_t *",
"const char *",
"const char *",
"char *")
856 const char *quorum = va_arg(args,
const char *);
857 const char *dc_version_s = va_arg(args,
const char *);
858 char *dc_name = va_arg(args,
char *);
861 out->list_item(out,
"Current DC",
"%s (version %s) - partition %s quorum",
862 dc_name, dc_version_s ? dc_version_s :
"unknown",
865 out->list_item(out,
"Current DC",
"NONE");
871 PCMK__OUTPUT_ARGS(
"cluster-dc",
"pe_node_t *",
"const char *",
"const char *",
"char *")
875 const char *quorum = va_arg(args,
const char *);
876 const char *dc_version_s = va_arg(args,
const char *);
877 char *dc_name G_GNUC_UNUSED = va_arg(args,
char *);
882 "version", dc_version_s ? dc_version_s :
"",
899 unsigned long long flags = va_arg(args,
unsigned long long);
919 out->list_item(out, NULL,
"STONITH of failed nodes %s",
922 out->list_item(out, NULL,
"Cluster is %s",
927 out->list_item(out, NULL,
"No quorum policy: Freeze resources");
931 out->list_item(out, NULL,
"No quorum policy: Stop ALL resources");
935 out->list_item(out, NULL,
"No quorum policy: Demote promotable " 936 "resources and stop all other resources");
940 out->list_item(out, NULL,
"No quorum policy: Ignore");
944 out->list_item(out, NULL,
"No quorum policy: Suicide");
954 " (the cluster will not attempt to start, stop, or recover services)");
961 " (the cluster will keep all resources stopped)");
963 out->list_item(out, NULL,
"Resource management: enabled");
975 return out->info(out,
"Resource management is DISABLED. The cluster will not attempt to start, stop or recover services.");
977 return out->info(out,
"Resource management is DISABLED. The cluster has stopped all resources.");
988 out->list_item(out, NULL,
"STONITH of failed nodes %s",
991 out->list_item(out, NULL,
"Cluster is %s",
996 out->list_item(out, NULL,
"No quorum policy: Freeze resources");
1000 out->list_item(out, NULL,
"No quorum policy: Stop ALL resources");
1004 out->list_item(out, NULL,
"No quorum policy: Demote promotable " 1005 "resources and stop all other resources");
1009 out->list_item(out, NULL,
"No quorum policy: Ignore");
1013 out->list_item(out, NULL,
"No quorum policy: Suicide");
1025 const char *no_quorum_policy = NULL;
1031 no_quorum_policy =
"freeze";
1035 no_quorum_policy =
"stop";
1039 no_quorum_policy =
"demote";
1043 no_quorum_policy =
"ignore";
1047 no_quorum_policy =
"suicide";
1054 "no-quorum-policy", no_quorum_policy,
1057 "stonith-timeout-ms", stonith_timeout_str,
1058 "priority-fencing-delay-ms", priority_fencing_delay_str,
1060 free(stonith_timeout_str);
1061 free(priority_fencing_delay_str);
1069 const char *stack_s = va_arg(args,
const char *);
1082 const char *stack_s = va_arg(args,
const char *);
1084 out->list_item(out,
"Stack",
"%s", stack_s);
1091 const char *stack_s = va_arg(args,
const char *);
1100 PCMK__OUTPUT_ARGS(
"cluster-times",
"const char *",
"const char *",
"const char *",
"const char *")
1103 const char *last_written = va_arg(args,
const char *);
1104 const char *user = va_arg(args,
const char *);
1105 const char *client = va_arg(args,
const char *);
1106 const char *origin = va_arg(args,
const char *);
1111 char *buf = last_changed_string(last_written, user, client, origin);
1124 PCMK__OUTPUT_ARGS(
"cluster-times",
"const char *",
"const char *",
"const char *",
"const char *")
1127 const char *last_written = va_arg(args,
const char *);
1128 const char *user = va_arg(args,
const char *);
1129 const char *client = va_arg(args,
const char *);
1130 const char *origin = va_arg(args,
const char *);
1136 "time", last_written ? last_written :
"",
1137 "user", user ? user :
"",
1138 "client", client ? client :
"",
1139 "origin", origin ? origin :
"",
1145 PCMK__OUTPUT_ARGS(
"cluster-times",
"const char *",
"const char *",
"const char *",
"const char *")
1148 const char *last_written = va_arg(args,
const char *);
1149 const char *user = va_arg(args,
const char *);
1150 const char *client = va_arg(args,
const char *);
1151 const char *origin = va_arg(args,
const char *);
1153 char *buf = last_changed_string(last_written, user, client, origin);
1156 out->list_item(out,
"Last change",
" %s", buf);
1165 xmlNodePtr xml_op = va_arg(args, xmlNodePtr);
1167 char *s = failed_action_string(xml_op);
1169 out->list_item(out, NULL,
"%s", s);
1177 xmlNodePtr xml_op = va_arg(args, xmlNodePtr);
1186 char *reason_s =
crm_xml_escape(exit_reason ? exit_reason :
"none");
1187 xmlNodePtr node = NULL;
1193 rc_s = pcmk__itoa(
rc);
1195 (op_key == NULL)?
"id" :
"op_key",
1196 (op_key == NULL)?
ID(xml_op) : op_key,
1198 "exitstatus", services_ocf_exitcode_str(
rc),
1199 "exitreason", reason_s,
1202 "status", services_lrm_status_str(status),
1207 &epoch) ==
pcmk_ok) && (epoch > 0)) {
1208 guint interval_ms = 0;
1211 char *rc_change = NULL;
1214 s = pcmk__itoa(interval_ms);
1236 "GList *",
"gboolean")
1240 GList *only_node = va_arg(args, GList *);
1241 GList *only_rsc = va_arg(args, GList *);
1242 gboolean print_spacer = va_arg(args, gboolean);
1244 xmlNode *xml_op = NULL;
1247 const char *
id = NULL;
1249 if (xmlChildElementCount(data_set->
failed) == 0) {
1253 for (xml_op = pcmk__xml_first_child(data_set->
failed); xml_op != NULL;
1254 xml_op = pcmk__xml_next(xml_op)) {
1262 if (
parse_op_key(
id ?
id :
ID(xml_op), &rsc, NULL, NULL) == FALSE) {
1274 out->message(out,
"failed-action", xml_op);
1282 status_node(
pe_node_t *node, xmlNodePtr parent)
1304 "GList *",
"GList *")
1308 unsigned int show_opts = va_arg(args,
unsigned int);
1309 gboolean full = va_arg(args, gboolean);
1310 const char *node_mode G_GNUC_UNUSED = va_arg(args,
const char *);
1311 GList *only_node = va_arg(args, GList *);
1312 GList *only_rsc = va_arg(args, GList *);
1317 xmlNodePtr item_node;
1322 out->begin_list(out, NULL, NULL,
"Node: %s", node_name);
1325 status_node(node, item_node);
1329 out->begin_list(out, NULL, NULL,
"Resources");
1341 out->begin_list(out, NULL, NULL,
"Node: %s", node_name);
1344 status_node(node, item_node);
1351 rsc, only_node, only_rsc);
1363 status_node(node, item_node);
1368 out->begin_list(out, NULL, NULL,
"Node: %s", node_name);
1375 PCMK__OUTPUT_ARGS(
"node",
"pe_node_t *",
"unsigned int",
"gboolean",
"const char *",
1376 "GList *",
"GList *")
1380 unsigned int show_opts = va_arg(args,
unsigned int);
1381 gboolean full = va_arg(args, gboolean);
1382 const char *node_mode = va_arg(args,
const char *);
1383 GList *only_node = va_arg(args, GList *);
1384 GList *only_rsc = va_arg(args, GList *);
1406 out->begin_list(out, NULL, NULL,
"%s", buf);
1407 out->begin_list(out, NULL, NULL,
"Resources");
1418 GList *gIter2 = NULL;
1420 out->begin_list(out, NULL, NULL,
"%s", buf);
1421 out->begin_list(out, NULL, NULL,
"Resources");
1426 rsc, only_node, only_rsc);
1433 out->list_item(out, NULL,
"%s", buf);
1440 out->begin_list(out, NULL, NULL,
"Node: %s", node_name);
1447 PCMK__OUTPUT_ARGS(
"node",
"pe_node_t *",
"unsigned int",
"gboolean",
"const char *",
1448 "GList *",
"GList *")
1452 unsigned int show_opts G_GNUC_UNUSED = va_arg(args,
unsigned int);
1453 gboolean full = va_arg(args, gboolean);
1454 const char *node_mode G_GNUC_UNUSED = va_arg(args,
const char *);
1455 GList *only_node = va_arg(args, GList *);
1456 GList *only_rsc = va_arg(args, GList *);
1485 "resources_running", length_s,
1499 rsc, only_node, only_rsc);
1515 PCMK__OUTPUT_ARGS(
"node-attribute",
"const char *",
"const char *",
"gboolean",
"int")
1518 const char *
name = va_arg(args,
const char *);
1519 const char *value = va_arg(args,
const char *);
1520 gboolean add_extra = va_arg(args, gboolean);
1521 int expected_score = va_arg(args,
int);
1526 if (value == NULL) {
1532 out->list_item(out, NULL,
"%-32s\t: %-10s\t: Connectivity is lost",
name, value);
1533 }
else if (v < expected_score) {
1534 out->list_item(out, NULL,
"%-32s\t: %-10s\t: Connectivity is degraded (Expected=%d)",
name, value, expected_score);
1536 out->list_item(out, NULL,
"%-32s\t: %-10s",
name, value);
1539 out->list_item(out, NULL,
"%-32s\t: %-10s",
name, value);
1545 PCMK__OUTPUT_ARGS(
"node-attribute",
"const char *",
"const char *",
"gboolean",
"int")
1548 const char *
name = va_arg(args,
const char *);
1549 const char *value = va_arg(args,
const char *);
1550 gboolean add_extra = va_arg(args, gboolean);
1551 int expected_score = va_arg(args,
int);
1558 if (value == NULL) {
1569 }
else if (v < expected_score) {
1570 char *buf =
crm_strdup_printf(
"(connectivity is degraded -- expected %d", expected_score);
1575 out->list_item(out, NULL,
"%s: %s",
name, value);
1585 xmlNodePtr xml_op = va_arg(args, xmlNodePtr);
1588 gchar *node_str = NULL;
1589 char *last_change_str = NULL;
1594 time_t last_change = 0;
1602 pe_node_t *node = pe__current_node(rsc);
1611 show_opts, target_role,
false);
1624 out->list_item(out, NULL,
"%s: %s (node=%s, call=%s, rc=%s%s): %s",
1625 node_str, op_key ? op_key :
ID(xml_op),
1629 last_change_str ? last_change_str :
"",
1630 services_lrm_status_str(status));
1633 free(last_change_str);
1641 xmlNodePtr xml_op = va_arg(args, xmlNodePtr);
1647 time_t last_change = 0;
1648 xmlNode *node = NULL;
1653 "op", op_key ? op_key :
ID(xml_op),
1657 "status", services_lrm_status_str(status),
1665 char *agent_tuple = NULL;
1672 "agent", agent_tuple,
1688 PCMK__OUTPUT_ARGS(
"node-attribute",
"const char *",
"const char *",
"gboolean",
"int")
1691 const char *
name = va_arg(args,
const char *);
1692 const char *value = va_arg(args,
const char *);
1693 gboolean add_extra = va_arg(args, gboolean);
1694 int expected_score = va_arg(args,
int);
1702 char *buf = pcmk__itoa(expected_score);
1711 "gboolean",
"GList *",
"GList *")
1715 unsigned int show_opts = va_arg(args,
unsigned int);
1716 gboolean print_spacer = va_arg(args, gboolean);
1717 GList *only_node = va_arg(args, GList *);
1718 GList *only_rsc = va_arg(args, GList *);
1723 for (GList *gIter = data_set->
nodes; gIter != NULL; gIter = gIter->next) {
1726 GList *attr_list = NULL;
1727 GHashTableIter iter;
1735 while (g_hash_table_iter_next (&iter, &key, NULL)) {
1736 attr_list = filter_attr_list(attr_list, key);
1739 if (attr_list == NULL) {
1744 g_list_free(attr_list);
1750 out->message(out,
"node", node, show_opts, FALSE, NULL, only_node, only_rsc);
1752 for (GList *aIter = attr_list; aIter != NULL; aIter = aIter->next) {
1753 const char *
name = aIter->data;
1754 const char *value = NULL;
1755 int expected_score = 0;
1756 gboolean add_extra = FALSE;
1761 data_set,
name, &expected_score);
1764 out->message(out,
"node-attribute",
name, value, add_extra,
1768 g_list_free(attr_list);
1781 const char *comment = va_arg(args,
const char *);
1787 out->list_item(out, NULL,
"%s", dump_text);
1798 const char *comment = va_arg(args,
const char *);
1810 "GList *",
"GList *",
"unsigned int",
"unsigned int")
1815 xmlNode *node_state = va_arg(args, xmlNode *);
1816 GList *only_node = va_arg(args, GList *);
1817 GList *only_rsc = va_arg(args, GList *);
1818 unsigned int section_opts = va_arg(args,
unsigned int);
1819 unsigned int show_opts = va_arg(args,
unsigned int);
1821 xmlNode *lrm_rsc = NULL;
1822 xmlNode *rsc_entry = NULL;
1854 time_t last_failure = 0;
1858 if (failcount <= 0) {
1864 out->message(out,
"node", node, show_opts, FALSE, NULL, only_node, only_rsc);
1867 out->message(out,
"resource-history", rsc, rsc_id, FALSE,
1868 failcount, last_failure, FALSE);
1870 GList *op_list = get_operation_list(rsc_entry);
1874 if (op_list == NULL) {
1880 out->message(out,
"node", node, show_opts, FALSE, NULL, only_node, only_rsc);
1883 out->message(out,
"resource-operation-list", data_set, rsc, node,
1884 op_list, show_opts);
1895 GList *nodes = va_arg(args, GList *);
1896 GList *only_node = va_arg(args, GList *);
1897 GList *only_rsc = va_arg(args, GList *);
1898 unsigned int show_opts = va_arg(args,
unsigned int);
1902 for (GList *gIter = nodes; gIter != NULL; gIter = gIter->next) {
1911 out->message(out,
"node", node, show_opts, TRUE, NULL, only_node, only_rsc);
1921 GList *nodes = va_arg(args, GList *);
1922 GList *only_node = va_arg(args, GList *);
1923 GList *only_rsc = va_arg(args, GList *);
1924 unsigned int show_opts = va_arg(args,
unsigned int);
1927 char *online_nodes = NULL;
1928 char *online_remote_nodes = NULL;
1929 char *online_guest_nodes = NULL;
1930 char *offline_nodes = NULL;
1931 char *offline_remote_nodes = NULL;
1933 size_t online_nodes_len = 0;
1934 size_t online_remote_nodes_len = 0;
1935 size_t online_guest_nodes_len = 0;
1936 size_t offline_nodes_len = 0;
1937 size_t offline_remote_nodes_len = 0;
1941 for (GList *gIter = nodes; gIter != NULL; gIter = gIter->next) {
1943 const char *node_mode = NULL;
1956 node_mode =
"UNCLEAN (online)";
1959 node_mode =
"UNCLEAN (pending)";
1962 node_mode =
"UNCLEAN (offline)";
1966 node_mode =
"pending";
1969 node_mode =
"standby (on-fail)";
1974 node_mode =
"standby (with active resources)";
1976 node_mode =
"standby";
1979 node_mode =
"OFFLINE (standby)";
1984 node_mode =
"maintenance";
1986 node_mode =
"OFFLINE (maintenance)";
1990 node_mode =
"online";
1993 pcmk__add_word(&online_guest_nodes,
1994 &online_guest_nodes_len, node_name);
1996 pcmk__add_word(&online_remote_nodes,
1997 &online_remote_nodes_len, node_name);
1999 pcmk__add_word(&online_nodes, &online_nodes_len, node_name);
2006 node_mode =
"OFFLINE";
2009 pcmk__add_word(&offline_remote_nodes,
2010 &offline_remote_nodes_len, node_name);
2014 pcmk__add_word(&offline_nodes,
2015 &offline_nodes_len, node_name);
2023 out->message(out,
"node", node, show_opts, TRUE, node_mode, only_node, only_rsc);
2029 out->list_item(out,
"Online",
"[ %s ]", online_nodes);
2032 if (offline_nodes) {
2033 out->list_item(out,
"OFFLINE",
"[ %s ]", offline_nodes);
2034 free(offline_nodes);
2036 if (online_remote_nodes) {
2037 out->list_item(out,
"RemoteOnline",
"[ %s ]", online_remote_nodes);
2038 free(online_remote_nodes);
2040 if (offline_remote_nodes) {
2041 out->list_item(out,
"RemoteOFFLINE",
"[ %s ]", offline_remote_nodes);
2042 free(offline_remote_nodes);
2044 if (online_guest_nodes) {
2045 out->list_item(out,
"GuestOnline",
"[ %s ]", online_guest_nodes);
2046 free(online_guest_nodes);
2056 GList *nodes = va_arg(args, GList *);
2057 GList *only_node = va_arg(args, GList *);
2058 GList *only_rsc = va_arg(args, GList *);
2059 unsigned int show_opts = va_arg(args,
unsigned int);
2061 out->begin_list(out, NULL, NULL,
"nodes");
2062 for (GList *gIter = nodes; gIter != NULL; gIter = gIter->next) {
2069 out->message(out,
"node", node, show_opts, TRUE, NULL, only_node, only_rsc);
2077 "unsigned int",
"unsigned int",
"gboolean")
2081 GList *only_node = va_arg(args, GList *);
2082 GList *only_rsc = va_arg(args, GList *);
2083 unsigned int section_opts = va_arg(args,
unsigned int);
2084 unsigned int show_opts = va_arg(args,
unsigned int);
2085 gboolean print_spacer = va_arg(args, gboolean);
2087 xmlNode *node_state = NULL;
2091 if (xmlChildElementCount(cib_status) == 0) {
2110 out->message(out,
"node-history-list", data_set, node, node_state,
2111 only_node, only_rsc, section_opts, show_opts);
2118 PCMK__OUTPUT_ARGS(
"node-weight",
"pe_resource_t *",
"const char *",
"const char *",
"char *")
2123 const char *prefix = va_arg(args,
const char *);
2124 const char *
uname = va_arg(args,
const char *);
2125 char *score = va_arg(args,
char *);
2128 out->list_item(out, NULL,
"%s: %s allocation score on %s: %s",
2129 prefix, rsc->
id,
uname, score);
2131 out->list_item(out, NULL,
"%s: %s = %s", prefix,
uname, score);
2137 PCMK__OUTPUT_ARGS(
"node-weight",
"pe_resource_t *",
"const char *",
"const char *",
"char *")
2142 const char *prefix = va_arg(args,
const char *);
2143 const char *
uname = va_arg(args,
const char *);
2144 char *score = va_arg(args,
char *);
2163 xmlNodePtr xml_op = va_arg(args, xmlNodePtr);
2164 const char *task = va_arg(args,
const char *);
2165 const char *interval_ms_s = va_arg(args,
const char *);
2166 int rc = va_arg(args,
int);
2167 unsigned int show_opts = va_arg(args,
unsigned int);
2169 char *buf = op_history_string(xml_op, task, interval_ms_s,
rc,
2172 out->list_item(out, NULL,
"%s", buf);
2178 PCMK__OUTPUT_ARGS(
"op-history",
"xmlNodePtr",
"const char *",
"const char *",
"int",
2182 xmlNodePtr xml_op = va_arg(args, xmlNodePtr);
2183 const char *task = va_arg(args,
const char *);
2184 const char *interval_ms_s = va_arg(args,
const char *);
2185 int rc = va_arg(args,
int);
2186 unsigned int show_opts = va_arg(args,
unsigned int);
2188 char *rc_s = pcmk__itoa(
rc);
2193 "rc_text", services_ocf_exitcode_str(
rc),
2197 if (interval_ms_s && !pcmk__str_eq(interval_ms_s,
"0",
pcmk__str_casei)) {
2204 const char *value = NULL;
2208 &epoch) ==
pcmk_ok) && (epoch > 0)) {
2229 PCMK__OUTPUT_ARGS(
"promotion-score",
"pe_resource_t *",
"pe_node_t *",
"char *")
2235 char *score = va_arg(args,
char *);
2237 out->list_item(out, NULL,
"%s promotion score on %s: %s",
2244 PCMK__OUTPUT_ARGS(
"promotion-score",
"pe_resource_t *",
"pe_node_t *",
"char *")
2250 char *score = va_arg(args,
char *);
2253 "id", child_rsc->
id,
2268 gboolean raw = va_arg(args, gboolean);
2270 char *rsc_xml = NULL;
2279 out->output_xml(out,
"xml", rsc_xml);
2285 PCMK__OUTPUT_ARGS(
"resource-history",
"pe_resource_t *",
"const char *",
"gboolean",
"int",
"time_t",
"gboolean")
2289 const char *rsc_id = va_arg(args,
const char *);
2290 gboolean all = va_arg(args, gboolean);
2291 int failcount = va_arg(args,
int);
2292 time_t last_failure = va_arg(args,
int);
2293 gboolean as_header = va_arg(args, gboolean);
2295 char *buf = resource_history_string(rsc, rsc_id, all, failcount, last_failure);
2298 out->begin_list(out, NULL, NULL,
"%s", buf);
2300 out->list_item(out, NULL,
"%s", buf);
2307 PCMK__OUTPUT_ARGS(
"resource-history",
"pe_resource_t *",
"const char *",
"gboolean",
"int",
"time_t",
"gboolean")
2311 const char *rsc_id = va_arg(args,
const char *);
2312 gboolean all = va_arg(args, gboolean);
2313 int failcount = va_arg(args,
int);
2314 time_t last_failure = va_arg(args,
int);
2315 gboolean as_header = va_arg(args, gboolean);
2323 }
else if (all || failcount || last_failure > 0) {
2327 "migration-threshold", migration_s,
2331 if (failcount > 0) {
2332 char *s = pcmk__itoa(failcount);
2338 if (last_failure > 0) {
2343 if (as_header == FALSE) {
2351 print_resource_header(
pcmk__output_t *out,
unsigned int show_opts)
2355 out->
begin_list(out, NULL, NULL,
"Inactive Resources");
2357 out->
begin_list(out, NULL, NULL,
"Full List of Resources");
2359 out->
begin_list(out, NULL, NULL,
"Active Resources");
2365 "gboolean",
"GList *",
"GList *",
"gboolean")
2370 unsigned int show_opts = va_arg(args,
unsigned int);
2371 gboolean print_summary = va_arg(args, gboolean);
2372 GList *only_node = va_arg(args, GList *);
2373 GList *only_rsc = va_arg(args, GList *);
2374 gboolean print_spacer = va_arg(args, gboolean);
2378 bool printed_header =
false;
2394 print_resource_header(out, show_opts);
2395 printed_header =
true;
2402 for (rsc_iter = data_set->
resources; rsc_iter != NULL; rsc_iter = rsc_iter->next) {
2407 gboolean is_active = rsc->
fns->
active(rsc, TRUE);
2408 gboolean partially_active = rsc->
fns->
active(rsc, FALSE);
2434 if (!printed_header) {
2436 print_resource_header(out, show_opts);
2437 printed_header =
true;
2441 x = out->message(out, crm_map_element_name(rsc->
xml), show_opts, rsc,
2442 only_node, only_rsc);
2449 if (!printed_header) {
2451 print_resource_header(out, show_opts);
2452 printed_header =
true;
2456 out->list_item(out, NULL,
"No inactive resources");
2458 out->list_item(out, NULL,
"No resources");
2460 out->list_item(out, NULL,
"No active resources");
2464 if (printed_header) {
2472 "pe_node_t *",
"GList *",
"unsigned int")
2479 GList *op_list = va_arg(args, GList *);
2480 unsigned int show_opts = va_arg(args,
unsigned int);
2482 GList *gIter = NULL;
2486 for (gIter = op_list; gIter != NULL; gIter = gIter->next) {
2487 xmlNode *xml_op = (xmlNode *) gIter->data;
2504 time_t last_failure = 0;
2509 failcount, last_failure, TRUE);
2514 out->message(out,
"op-history", xml_op, task, interval_ms_s,
2515 op_rc_i, show_opts);
2519 g_list_free(op_list);
2525 PCMK__OUTPUT_ARGS(
"resource-util",
"pe_resource_t *",
"pe_node_t *",
"const char *")
2531 const char *fn = va_arg(args,
const char *);
2536 g_hash_table_foreach(rsc->
utilization, append_dump_text, &dump_text);
2537 out->list_item(out, NULL,
"%s", dump_text);
2543 PCMK__OUTPUT_ARGS(
"resource-util",
"pe_resource_t *",
"pe_node_t *",
"const char *")
2549 const char *fn = va_arg(args,
const char *);
2552 "resource", rsc->
id,
2556 g_hash_table_foreach(rsc->
utilization, add_dump_node, xml_node);
2570 out->list_item(out, NULL,
"%s:\t%s%s %s", ticket->
id,
2571 ticket->
granted ?
"granted" :
"revoked",
2572 ticket->
standby ?
" [standby]" :
"",
2576 out->list_item(out, NULL,
"%s:\t%s%s", ticket->
id,
2577 ticket->
granted ?
"granted" :
"revoked",
2578 ticket->
standby ?
" [standby]" :
"");
2593 out->list_item(out, ticket->
id,
"%s%s %s",
2594 ticket->
granted ?
"granted" :
"revoked",
2595 ticket->
standby ?
" [standby]" :
"",
2599 out->list_item(out, ticket->
id,
"%s%s",
2600 ticket->
granted ?
"granted" :
"revoked",
2601 ticket->
standby ?
" [standby]" :
"");
2612 xmlNodePtr node = NULL;
2616 "status", ticket->
granted ?
"granted" :
"revoked",
2617 "standby", pcmk__btoa(ticket->
standby),
2631 gboolean print_spacer = va_arg(args, gboolean);
2633 GHashTableIter iter;
2634 gpointer key, value;
2636 if (g_hash_table_size(data_set->
tickets) == 0) {
2643 out->begin_list(out, NULL, NULL,
"Tickets");
2646 g_hash_table_iter_init(&iter, data_set->
tickets);
2647 while (g_hash_table_iter_next(&iter, &key, &value)) {
2649 out->message(out,
"ticket", ticket);
2658 {
"ban",
"default", ban_text },
2659 {
"ban",
"html", ban_html },
2660 {
"ban",
"xml", ban_xml },
2661 {
"ban-list",
"default", ban_list },
2667 {
"cluster-counts",
"default", cluster_counts_text },
2668 {
"cluster-counts",
"html", cluster_counts_html },
2669 {
"cluster-counts",
"xml", cluster_counts_xml },
2670 {
"cluster-dc",
"default", cluster_dc_text },
2671 {
"cluster-dc",
"html", cluster_dc_html },
2672 {
"cluster-dc",
"xml", cluster_dc_xml },
2673 {
"cluster-options",
"default", cluster_options_text },
2674 {
"cluster-options",
"html", cluster_options_html },
2675 {
"cluster-options",
"log", cluster_options_log },
2676 {
"cluster-options",
"xml", cluster_options_xml },
2677 {
"cluster-summary",
"default", cluster_summary },
2678 {
"cluster-summary",
"html", cluster_summary_html },
2679 {
"cluster-stack",
"default", cluster_stack_text },
2680 {
"cluster-stack",
"html", cluster_stack_html },
2681 {
"cluster-stack",
"xml", cluster_stack_xml },
2682 {
"cluster-times",
"default", cluster_times_text },
2683 {
"cluster-times",
"html", cluster_times_html },
2684 {
"cluster-times",
"xml", cluster_times_xml },
2685 {
"failed-action",
"default", failed_action_text },
2686 {
"failed-action",
"xml", failed_action_xml },
2687 {
"failed-action-list",
"default", failed_action_list },
2690 {
"maint-mode",
"text", cluster_maint_mode_text },
2691 {
"node",
"default", node_text },
2692 {
"node",
"html", node_html },
2693 {
"node",
"xml", node_xml },
2694 {
"node-and-op",
"default", node_and_op },
2695 {
"node-and-op",
"xml", node_and_op_xml },
2696 {
"node-capacity",
"default", node_capacity },
2697 {
"node-capacity",
"xml", node_capacity_xml },
2698 {
"node-history-list",
"default", node_history_list },
2699 {
"node-list",
"default", node_list_text },
2700 {
"node-list",
"html", node_list_html },
2701 {
"node-list",
"xml", node_list_xml },
2702 {
"node-weight",
"default", node_weight },
2703 {
"node-weight",
"xml", node_weight_xml },
2704 {
"node-attribute",
"default", node_attribute_text },
2705 {
"node-attribute",
"html", node_attribute_html },
2706 {
"node-attribute",
"xml", node_attribute_xml },
2707 {
"node-attribute-list",
"default", node_attribute_list },
2708 {
"node-summary",
"default", node_summary },
2709 {
"op-history",
"default", op_history_text },
2710 {
"op-history",
"xml", op_history_xml },
2714 {
"promotion-score",
"default", promotion_score },
2715 {
"promotion-score",
"xml", promotion_score_xml },
2716 {
"resource-config",
"default", resource_config },
2717 {
"resource-history",
"default", resource_history_text },
2718 {
"resource-history",
"xml", resource_history_xml },
2719 {
"resource-list",
"default", resource_list },
2720 {
"resource-operation-list",
"default", resource_operation_list },
2721 {
"resource-util",
"default", resource_util },
2722 {
"resource-util",
"xml", resource_util_xml },
2723 {
"ticket",
"default", ticket_text },
2724 {
"ticket",
"html", ticket_html },
2725 {
"ticket",
"xml", ticket_xml },
2726 {
"ticket-list",
"default", ticket_list },
2728 { NULL, NULL, NULL }
2745 crm_trace(
"%sNode %s: (weight=%d, fixed=%s)",
2750 char *pe_mutable = strdup(
"\t\t");
2754 all = g_list_prepend(all, (gpointer)
"*");
2762 for (; gIter != NULL; gIter = gIter->next) {
2765 out->
message(out, crm_map_element_name(rsc->
xml),
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
#define CRM_CHECK(expr, failure_action)
#define XML_RSC_OP_LAST_CHANGE
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
#define XML_ATTR_UPDATE_ORIG
enum rsc_role_e role_filter
enum pe_quorum_policy no_quorum_policy
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
#define XML_ATTR_UPDATE_CLIENT
Control output from tools.
int pcmk__scan_min_int(const char *text, int *result, int minimum)
#define crm_time_log_timeofday
pe_resource_t * container
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
int(* message)(pcmk__output_t *out, const char *message_id,...)
struct crm_time_s crm_time_t
#define pe_flag_symmetric_cluster
int priority_fencing_delay
xmlNode * get_object_root(const char *object_type, xmlNode *the_root)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
#define pe_flag_maintenance_mode
xmlNode * pcmk_create_html_node(xmlNode *parent, const char *element_name, const char *id, const char *class_name, const char *text)
gboolean pcmk__str_in_list(GList *lst, const gchar *s, uint32_t flags)
#define XML_ATTR_UPDATE_USER
int pe__group_default(pcmk__output_t *out, va_list args)
pe_resource_t * remote_rsc
#define CRMD_ACTION_NOTIFY
#define XML_RSC_OP_T_EXEC
resource_object_functions_t * fns
#define XML_LRM_TAG_RESOURCE
int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name, size_t pairs_count,...)
xmlNodePtr pcmk__output_xml_create_parent(pcmk__output_t *out, const char *name,...) G_GNUC_NULL_TERMINATED
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
int pe__clone_default(pcmk__output_t *out, va_list args)
xmlNodePtr pcmk__output_xml_peek_parent(pcmk__output_t *out)
gint sort_op_by_callid(gconstpointer a, gconstpointer b)
#define RSC_ROLE_PROMOTED_LEGACY_S
pe_resource_t * pe_find_resource(GList *rsc_list, const char *id_rh)
enum crm_ais_msg_types type
bool pe__rsc_running_on_any(pe_resource_t *rsc, GList *node_list)
xmlNodePtr pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, const char *id, const char *class_name, const char *text)
int pe__resource_text(pcmk__output_t *out, va_list args)
#define XML_RSC_OP_T_QUEUE
char * pcmk__format_named_time(const char *name, time_t epoch_time)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
#define PCMK__LAST_FAILURE_PREFIX
int pe__bundle_html(pcmk__output_t *out, va_list args)
void void void pcmk__formatted_printf(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
#define pe_flag_stop_everything
GList * pe__filter_rsc_list(GList *rscs, GList *filter)
char * pcmk__format_nvpair(const char *name, const char *value, const char *units)
#define PCMK__OUTPUT_SPACER_IF(out_obj, cond)
#define XML_LRM_ATTR_TASK_KEY
bool pe__is_remote_node(const pe_node_t *node)
#define XML_LRM_ATTR_TASK
int crm_element_value_ms(const xmlNode *data, const char *name, guint *dest)
Retrieve the millisecond value of an XML attribute.
int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, unsigned int options)
int pe__bundle_text(pcmk__output_t *out, va_list args)
pe_resource_t * uber_parent(pe_resource_t *rsc)
void pcmk__output_xml_push_parent(pcmk__output_t *out, xmlNodePtr node)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_STATE
bool pe__is_guest_node(const pe_node_t *node)
char * pe__node_display_name(pe_node_t *node, bool print_detail)
xmlNode * pcmk_create_xml_text_node(xmlNode *parent, const char *name, const char *content)
#define crm_trace(fmt, args...)
int pe__clone_xml(pcmk__output_t *out, va_list args)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
void crm_time_set_timet(crm_time_t *target, time_t *source)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
#define XML_AGENT_ATTR_PROVIDER
#define XML_ATTR_HAVE_QUORUM
GHashTable * pe_rsc_params(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
char * dump_xml_formatted(xmlNode *msg)
xmlNodePtr pcmk__output_create_xml_node(pcmk__output_t *out, const char *name,...) G_GNUC_NULL_TERMINATED
#define pe_flag_stonith_enabled
int crm_element_value_epoch(const xmlNode *xml, const char *name, time_t *dest)
Retrieve the seconds-since-epoch value of an XML attribute.
const char * pe_node_attribute_raw(pe_node_t *node, const char *name)
#define PCMK__FAIL_COUNT_PREFIX
void pe__output_node(pe_node_t *node, gboolean details, pcmk__output_t *out)
#define XML_RSC_ATTR_TARGET_ROLE
#define XML_LRM_ATTR_EXIT_REASON
#define crm_time_log_with_timezone
enum pe_obj_types variant
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
#define RSC_ROLE_PROMOTED_S
const char * pcmk__epoch2str(time_t *when)
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
char * crm_time_as_string(crm_time_t *dt, int flags)
int pe__resource_xml(pcmk__output_t *out, va_list args)
const xmlChar * pcmkXmlStr
pe_node_t * pe_find_node_id(GList *node_list, const char *id)
#define PCMK__OUTPUT_LIST_FOOTER(out_obj, retcode)
int pe__bundle_xml(pcmk__output_t *out, va_list args)
#define PCMK__OUTPUT_LIST_HEADER(out_obj, cond, retcode, title...)
gboolean(* is_filtered)(pe_resource_t *, GList *, gboolean)
#define XML_LRM_TAG_RESOURCES
gchar * pcmk__native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node, unsigned long show_opts, const char *target_role, bool show_nodes)
const char * rsc_printable_id(pe_resource_t *rsc)
#define XML_CIB_ATTR_WRITTEN
crm_time_t * crm_time_new(const char *string)
int pe__group_xml(pcmk__output_t *out, va_list args)
This structure contains everything that makes up a single output formatter.
#define XML_LRM_ATTR_INTERVAL_MS
#define XML_LRM_ATTR_CALLID
#define XML_NVPAIR_ATTR_VALUE
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
#define XML_LRM_ATTR_OPSTATUS
int pe__resource_html(pcmk__output_t *out, va_list args)
#define pcmk__plural_s(i)
rsc_role_e
Possible roles that a resource can be in.
void pcmk__register_messages(pcmk__output_t *out, pcmk__message_entry_t *table)
GList * placement_constraints
#define XML_CIB_TAG_STATUS
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
gboolean crm_is_true(const char *s)
char * pcmk__trim(char *str)
#define XML_LRM_TAG_RSC_OP
char * crm_xml_escape(const char *text)
void print_str_str(gpointer key, gpointer value, gpointer user_data)
PCMK__OUTPUT_ARGS("ban-list", "pe_working_set_t *", "const char *", "GList *", "unsigned int", "gboolean")
void pe__register_messages(pcmk__output_t *out)
#define crm_time_log_date
int pe_get_failcount(pe_node_t *node, pe_resource_t *rsc, time_t *last_failure, uint32_t flags, xmlNode *xml_op, pe_working_set_t *data_set)
gboolean(* active)(pe_resource_t *, gboolean)
#define XML_AGENT_ATTR_CLASS
#define CRMD_ACTION_STATUS
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.
void crm_time_free(crm_time_t *dt)