39 timespec_string(time_t sec,
long nsec,
bool show_usec) {
40 const struct timespec ts = {
65 switch (history->
state) {
67 case st_done:
return "successful";
68 default:
return "pending";
91 bool full_history,
const char *later_succeeded,
94 GString *str = g_string_sized_new(256);
95 char *completed_time_s = NULL;
98 completed_time_s = timespec_string(history->
completed,
116 g_string_append(str,
" last");
120 pcmk__add_word(&str, 0, state_str(history));
129 g_string_append(str,
": ");
140 "client=", history->
client,
", origin=", history->
origin,
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);
460 "action", event->action,
461 "target", event->target,
462 "client", event->client,
463 "origin", event->origin,
466 switch (event->state) {
478 char *state = pcmk__itoa(event->state);
480 "extended-status", state,
487 if (event->delegate != NULL) {
492 char *time_s = timespec_string(event->completed, event->completed_nsec,
503 "const char *",
"int")
506 const char *agent = va_arg(args,
const char *);
507 const char *device = va_arg(args,
const char *);
508 const char *output = va_arg(args,
const char *);
509 const char *error_output = va_arg(args,
const char *);
510 int rc = va_arg(args,
int);
514 rc ?
"failed" :
"succeeded");
519 rc ?
"failed" :
"succeeded");
524 out->subprocess_output(out, rc, output, error_output);
529 "const char *",
"int")
532 const char *agent = va_arg(args,
const char *);
533 const char *device = va_arg(args,
const char *);
534 const char *output = va_arg(args,
const char *);
535 const char *error_output = va_arg(args,
const char *);
536 int rc = va_arg(args,
int);
540 rc ?
"failed" :
"succeeded");
543 rc ?
"failed" :
"succeeded");
546 out->subprocess_output(out, rc, output, error_output);
551 "const char *",
"int")
554 const char *agent = va_arg(args,
const char *);
555 const char *device = va_arg(args,
const char *);
556 const char *output = va_arg(args,
const char *);
557 const char *error_output = va_arg(args,
const char *);
558 int rc = va_arg(args,
int);
561 out,
"validate",
"agent", agent,
"valid", pcmk__btoa(rc ==
pcmk_ok),
564 if (device != NULL) {
569 out->subprocess_output(out, rc, output, error_output);
576 {
"failed-fencing-list",
"default", failed_history },
577 {
"fencing-list",
"default", stonith_history },
578 {
"full-fencing-list",
"default", full_history },
579 {
"full-fencing-list",
"xml", full_history_xml },
580 {
"last-fenced",
"html", last_fenced_html },
581 {
"last-fenced",
"log", last_fenced_text },
582 {
"last-fenced",
"text", last_fenced_text },
583 {
"last-fenced",
"xml", last_fenced_xml },
584 {
"pending-fencing-list",
"default", pending_actions },
585 {
"stonith-event",
"html", stonith_event_html },
586 {
"stonith-event",
"log", stonith_event_text },
587 {
"stonith-event",
"text", stonith_event_text },
588 {
"stonith-event",
"xml", stonith_event_xml },
589 {
"validate",
"html", validate_agent_html },
590 {
"validate",
"log", validate_agent_text },
591 {
"validate",
"text", validate_agent_text },
592 {
"validate",
"xml", validate_agent_xml },
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
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)
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 XML_LRM_ATTR_EXIT_REASON
#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...)
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.
char * pcmk__timespec2str(const struct timespec *ts, uint32_t flags)
#define crm_time_log_date
gboolean pcmk__str_in_list(const gchar *s, const GList *lst, uint32_t flags)