38 timespec_string(time_t sec,
long nsec,
bool show_usec) {
39 const struct timespec ts = {
64 switch (history->
state) {
66 case st_done:
return "successful";
67 default:
return "pending";
90 bool full_history,
const char *later_succeeded,
93 GString *str = g_string_sized_new(256);
94 char *completed_time_s = NULL;
97 completed_time_s = timespec_string(history->
completed,
115 g_string_append(str,
" last");
119 pcmk__add_word(&str, 0, state_str(history));
128 g_string_append(str,
": ");
144 if (completed_time_s != NULL) {
146 g_string_append(str,
", completed");
148 g_string_append(str,
", last-failed");
150 g_string_append(str,
", last-successful");
154 }
else if (completed_time_s != NULL) {
161 " (a later attempt from ", later_succeeded,
162 " succeeded)", NULL);
165 free(completed_time_s);
166 return g_string_free(str, FALSE);
170 "uint32_t",
"uint32_t",
"bool")
175 GList *only_node = va_arg(args, GList *);
176 uint32_t section_opts = va_arg(args, uint32_t);
177 uint32_t show_opts = va_arg(args, uint32_t);
178 bool print_spacer = va_arg(args,
int);
192 out->message(out,
"stonith-event", hp,
195 out->increment_list(out);
208 GList *only_node = va_arg(args, GList *);
209 uint32_t section_opts = va_arg(args, uint32_t);
210 uint32_t show_opts = va_arg(args, uint32_t);
211 bool print_spacer = va_arg(args,
int);
222 out->message(out,
"stonith-event", hp,
223 pcmk_all_flags_set(section_opts,
226 out->increment_list(out);
235 "GList *",
"uint32_t",
"uint32_t",
"bool")
241 GList *only_node = va_arg(args, GList *);
242 uint32_t section_opts = va_arg(args, uint32_t);
243 uint32_t show_opts = va_arg(args, uint32_t);
244 bool print_spacer = va_arg(args,
int);
254 out->message(out,
"stonith-event", hp,
257 out->increment_list(out);
265 "GList *",
"uint32_t",
"uint32_t",
"bool")
271 GList *only_node = va_arg(args, GList *);
272 uint32_t section_opts = va_arg(args, uint32_t);
273 uint32_t show_opts = va_arg(args, uint32_t);
274 bool print_spacer G_GNUC_UNUSED = va_arg(args,
int);
278 if (history_rc == 0) {
285 out->message(out,
"stonith-event", hp,
286 pcmk_all_flags_set(section_opts,
289 out->increment_list(out);
294 char *rc_s = pcmk__itoa(history_rc);
310 const char *
target = va_arg(args,
const char *);
311 time_t when = va_arg(args, time_t);
326 const char *
target = va_arg(args,
const char *);
327 time_t when = va_arg(args, time_t);
341 const char *
target = va_arg(args,
const char *);
342 time_t when = va_arg(args, time_t);
345 char *buf = timespec_string(when, 0,
false);
360 "uint32_t",
"uint32_t",
"bool")
365 GList *only_node = va_arg(args, GList *);
366 uint32_t section_opts = va_arg(args, uint32_t);
367 uint32_t show_opts = va_arg(args, uint32_t);
368 bool print_spacer = va_arg(args,
int);
383 out->message(out,
"stonith-event", hp,
386 out->increment_list(out);
394 "const char *",
"uint32_t")
399 bool full_history = va_arg(args,
int);
400 bool completed_only G_GNUC_UNUSED = va_arg(args,
int);
401 const char *succeeded = va_arg(args,
const char *);
402 uint32_t show_opts = va_arg(args, uint32_t);
407 switch(event->state) {
409 out->list_item(out,
"successful-stonith-event",
"%s", desc);
413 out->list_item(out,
"failed-stonith-event",
"%s", desc);
417 out->list_item(out,
"pending-stonith-event",
"%s", desc);
425 "const char *",
"uint32_t")
430 bool full_history = va_arg(args,
int);
431 bool completed_only = va_arg(args,
int);
432 const char *succeeded = va_arg(args,
const char *);
433 uint32_t show_opts = va_arg(args, uint32_t);
435 if (completed_only) {
449 "const char *",
"uint32_t")
454 bool full_history G_GNUC_UNUSED = va_arg(args,
int);
455 bool completed_only G_GNUC_UNUSED = va_arg(args,
int);
456 const char *succeeded G_GNUC_UNUSED = va_arg(args,
const char *);
457 uint32_t show_opts G_GNUC_UNUSED = va_arg(args, uint32_t);
459 xmlNodePtr node = NULL;
468 switch (event->state) {
481 char *state = pcmk__itoa(event->state);
491 if (event->delegate != NULL) {
496 char *time_s = timespec_string(event->completed, event->completed_nsec,
507 "const char *",
"int")
510 const char *agent = va_arg(args,
const char *);
511 const char *device = va_arg(args,
const char *);
512 const char *output = va_arg(args,
const char *);
513 const char *error_output = va_arg(args,
const char *);
514 int rc = va_arg(args,
int);
518 rc ?
"failed" :
"succeeded");
523 rc ?
"failed" :
"succeeded");
528 out->subprocess_output(out, rc, output, error_output);
533 "const char *",
"int")
536 const char *agent = va_arg(args,
const char *);
537 const char *device = va_arg(args,
const char *);
538 const char *output = va_arg(args,
const char *);
539 const char *error_output = va_arg(args,
const char *);
540 int rc = va_arg(args,
int);
544 rc ?
"failed" :
"succeeded");
547 rc ?
"failed" :
"succeeded");
550 out->subprocess_output(out, rc, output, error_output);
555 "const char *",
"int")
558 const char *agent = va_arg(args,
const char *);
559 const char *device = va_arg(args,
const char *);
560 const char *output = va_arg(args,
const char *);
561 const char *error_output = va_arg(args,
const char *);
562 int rc = va_arg(args,
int);
564 const char *valid = pcmk__btoa(rc ==
pcmk_ok);
570 if (device != NULL) {
575 out->subprocess_output(out, rc, output, error_output);
582 {
"failed-fencing-list",
"default", failed_history },
583 {
"fencing-list",
"default", stonith_history },
584 {
"full-fencing-list",
"default", full_history },
585 {
"full-fencing-list",
"xml", full_history_xml },
586 {
"last-fenced",
"html", last_fenced_html },
587 {
"last-fenced",
"log", last_fenced_text },
588 {
"last-fenced",
"text", last_fenced_text },
589 {
"last-fenced",
"xml", last_fenced_xml },
590 {
"pending-fencing-list",
"default", pending_actions },
591 {
"stonith-event",
"html", stonith_event_html },
592 {
"stonith-event",
"log", stonith_event_text },
593 {
"stonith-event",
"text", stonith_event_text },
594 {
"stonith-event",
"xml", stonith_event_xml },
595 {
"validate",
"html", validate_agent_html },
596 {
"validate",
"log", validate_agent_text },
597 {
"validate",
"text", validate_agent_text },
598 {
"validate",
"xml", validate_agent_xml },
#define PCMK_XE_FENCE_HISTORY
void pcmk__output_xml_push_parent(pcmk__output_t *out, xmlNodePtr parent)
struct stonith_history_s * next
Control output from tools.
void pcmk__register_messages(pcmk__output_t *out, const pcmk__message_entry_t *table)
#define crm_time_log_timeofday
#define PCMK_VALUE_FAILED
#define PCMK_XA_EXIT_REASON
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
enum crm_exit_e crm_exit_t
xmlNodePtr pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, const char *id, const char *class_name, const char *text)
void void void pcmk__formatted_printf(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
Formatted output for pacemaker tools.
const char * stonith_action_str(const char *action)
Turn fence action into a more readable string.
const char * stonith__later_succeeded(const stonith_history_t *event, const stonith_history_t *top_history)
gchar * stonith__history_description(const stonith_history_t *history, bool full_history, const char *later_succeeded, uint32_t show_opts)
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
void stonith__register_messages(pcmk__output_t *out)
#define PCMK_XE_LAST_FENCED
#define PCMK_XA_EXTENDED_STATUS
Wrappers for and extensions to libxml2.
void pcmk__indented_printf(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
xmlNodePtr pcmk__output_create_xml_node(pcmk__output_t *out, const char *name,...) G_GNUC_NULL_TERMINATED
#define pcmk_section_fencing_all
#define crm_time_log_with_timezone
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
#define PCMK__OUTPUT_LIST_FOOTER(out_obj, retcode)
#define PCMK__OUTPUT_LIST_HEADER(out_obj, cond, retcode, title...)
#define PCMK_XA_COMPLETED
PCMK__OUTPUT_ARGS("failed-fencing-list", "stonith_history_t *", "GList *", "uint32_t", "uint32_t", "bool")
This structure contains everything that makes up a single output formatter.
#define PCMK_VALUE_SUCCESS
char * pcmk__timespec2str(const struct timespec *ts, uint32_t flags)
#define PCMK_VALUE_PENDING
#define PCMK_XE_FENCE_EVENT
#define crm_time_log_date
gboolean pcmk__str_in_list(const gchar *s, const GList *lst, uint32_t flags)