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 <glib.h>
  14 #include <stdbool.h>
  15 #include <stdint.h>
  16 
  17 #ifdef __cplusplus
  18 extern "C" {
  19 #endif
  20 
  21 /* Default-Timeout to use before killing a alerts script (in milliseconds) */
  22 #define PCMK__ALERT_DEFAULT_TIMEOUT_MS (30000)
  23 
  24 /* Default-Format-String used to pass timestamps to the alerts scripts */
  25 #define PCMK__ALERT_DEFAULT_TSTAMP_FORMAT "%H:%M:%S.%06N"
  26 
  27 enum pcmk__alert_flags {
  28     pcmk__alert_none         = 0,
  29     pcmk__alert_node         = (1 << 0),
  30     pcmk__alert_fencing      = (1 << 1),
  31     pcmk__alert_resource     = (1 << 2),
  32     pcmk__alert_attribute    = (1 << 3),
  33     pcmk__alert_default      = pcmk__alert_node|pcmk__alert_fencing|
  34                                pcmk__alert_resource,
  35 };
  36 
  37 typedef struct {
  38     char *id;
  39     char *path;
  40     char *tstamp_format;
  41     char *recipient;
  42     char **select_attribute_name;
  43     GHashTable *envvars;
  44     int timeout;
  45     uint32_t flags;
  46 } pcmk__alert_t;
  47 
  48 enum pcmk__alert_keys_e {
  49     PCMK__alert_key_recipient = 0,
  50     PCMK__alert_key_node,
  51     PCMK__alert_key_nodeid,
  52     PCMK__alert_key_rsc,
  53     PCMK__alert_key_task,
  54     PCMK__alert_key_interval,
  55     PCMK__alert_key_desc,
  56     PCMK__alert_key_status,
  57     PCMK__alert_key_target_rc,
  58     PCMK__alert_key_rc,
  59     PCMK__alert_key_kind,
  60     PCMK__alert_key_version,
  61     PCMK__alert_key_node_sequence,
  62     PCMK__alert_key_timestamp,
  63     PCMK__alert_key_attribute_name,
  64     PCMK__alert_key_attribute_value,
  65     PCMK__alert_key_timestamp_epoch,
  66     PCMK__alert_key_timestamp_usec,
  67     PCMK__alert_key_exec_time,
  68     PCMK__alert_key_select_kind,
  69     PCMK__alert_key_select_attribute_name
  70 };
  71 
  72 #define PCMK__ALERT_INTERNAL_KEY_MAX 19
  73 #define PCMK__ALERT_NODE_SEQUENCE "CRM_alert_node_sequence"
  74 
  75 extern const char *pcmk__alert_keys[PCMK__ALERT_INTERNAL_KEY_MAX];
  76 
  77 pcmk__alert_t *pcmk__dup_alert(const pcmk__alert_t *entry);
  78 pcmk__alert_t *pcmk__alert_new(const char *id, const char *path);
  79 void pcmk__free_alert(pcmk__alert_t *entry);
  80 void pcmk__add_alert_key(GHashTable *table, enum pcmk__alert_keys_e name,
  81                          const char *value);
  82 void pcmk__add_alert_key_int(GHashTable *table, enum pcmk__alert_keys_e name,
  83                              int value);
  84 
  85 static inline const char *
  86 pcmk__alert_flag2text(enum pcmk__alert_flags flag)
     /* [previous][next][first][last][top][bottom][index][help] */
  87 {
  88     switch (flag) {
  89         case pcmk__alert_node:      return "node";
  90         case pcmk__alert_fencing:   return "fencing";
  91         case pcmk__alert_resource:  return "resource";
  92         case pcmk__alert_attribute: return "attribute";
  93         default:                    return "unknown";
  94     }
  95 }
  96 
  97 #ifdef __cplusplus
  98 }
  99 #endif
 100 
 101 #endif // PCMK__CRM_COMMON_ALERTS_INTERNAL__H

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