root/include/crm/common/alerts_internal.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pcmk__alert_flag2text

   1 /*
   2  * Copyright 2015-2024 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #ifndef PCMK__CRM_COMMON_ALERTS_INTERNAL__H
  11 #define PCMK__CRM_COMMON_ALERTS_INTERNAL__H
  12 
  13 #include <stdbool.h>
  14 #include <stdint.h>         // uint32_t
  15 
  16 #include <glib.h>           // GList, GHashTable
  17 #include <libxml/tree.h>    // xmlNode
  18 
  19 #ifdef __cplusplus
  20 extern "C" {
  21 #endif
  22 
  23 /* Default-Timeout to use before killing a alerts script (in milliseconds) */
  24 #define PCMK__ALERT_DEFAULT_TIMEOUT_MS (30000)
  25 
  26 /* Default-Format-String used to pass timestamps to the alerts scripts */
  27 #define PCMK__ALERT_DEFAULT_TSTAMP_FORMAT "%H:%M:%S.%06N"
  28 
  29 enum pcmk__alert_flags {
  30     pcmk__alert_none         = 0,
  31     pcmk__alert_node         = (1 << 0),
  32     pcmk__alert_fencing      = (1 << 1),
  33     pcmk__alert_resource     = (1 << 2),
  34     pcmk__alert_attribute    = (1 << 3),
  35     pcmk__alert_default      = pcmk__alert_node|pcmk__alert_fencing|
  36                                pcmk__alert_resource,
  37 };
  38 
  39 typedef struct {
  40     char *id;
  41     char *path;
  42     char *tstamp_format;
  43     char *recipient;
  44     char **select_attribute_name;
  45     GHashTable *envvars;
  46     int timeout;
  47     uint32_t flags;
  48 } pcmk__alert_t;
  49 
  50 enum pcmk__alert_keys_e {
  51     PCMK__alert_key_recipient = 0,
  52     PCMK__alert_key_node,
  53     PCMK__alert_key_nodeid,
  54     PCMK__alert_key_rsc,
  55     PCMK__alert_key_task,
  56     PCMK__alert_key_interval,
  57     PCMK__alert_key_desc,
  58     PCMK__alert_key_status,
  59     PCMK__alert_key_target_rc,
  60     PCMK__alert_key_rc,
  61     PCMK__alert_key_kind,
  62     PCMK__alert_key_version,
  63     PCMK__alert_key_node_sequence,
  64     PCMK__alert_key_timestamp,
  65     PCMK__alert_key_attribute_name,
  66     PCMK__alert_key_attribute_value,
  67     PCMK__alert_key_timestamp_epoch,
  68     PCMK__alert_key_timestamp_usec,
  69     PCMK__alert_key_exec_time,
  70     PCMK__alert_key_select_kind,
  71     PCMK__alert_key_select_attribute_name
  72 };
  73 
  74 #define PCMK__ALERT_INTERNAL_KEY_MAX 19
  75 #define PCMK__ALERT_NODE_SEQUENCE "CRM_alert_node_sequence"
  76 
  77 extern const char *pcmk__alert_keys[PCMK__ALERT_INTERNAL_KEY_MAX];
  78 
  79 pcmk__alert_t *pcmk__dup_alert(const pcmk__alert_t *entry);
  80 pcmk__alert_t *pcmk__alert_new(const char *id, const char *path);
  81 void pcmk__free_alert(pcmk__alert_t *entry);
  82 void pcmk__add_alert_key(GHashTable *table, enum pcmk__alert_keys_e name,
  83                          const char *value);
  84 void pcmk__add_alert_key_int(GHashTable *table, enum pcmk__alert_keys_e name,
  85                              int value);
  86 GList *pcmk__unpack_alerts(const xmlNode *alerts);
  87 void pcmk__free_alerts(GList *alert_list);
  88 
  89 static inline const char *
  90 pcmk__alert_flag2text(enum pcmk__alert_flags flag)
     /* [previous][next][first][last][top][bottom][index][help] */
  91 {
  92     switch (flag) {
  93         case pcmk__alert_node:      return "node";
  94         case pcmk__alert_fencing:   return "fencing";
  95         case pcmk__alert_resource:  return "resource";
  96         case pcmk__alert_attribute: return "attribute";
  97         default:                    return "unknown";
  98     }
  99 }
 100 
 101 #ifdef __cplusplus
 102 }
 103 #endif
 104 
 105 #endif // PCMK__CRM_COMMON_ALERTS_INTERNAL__H

/* [previous][next][first][last][top][bottom][index][help] */