19 static char *notify_script = NULL;
20 static char *notify_target = NULL;
23 pe_enable_legacy_alerts(
const char *script,
const char *target)
25 static bool need_warning = TRUE;
28 notify_script = (script && strcmp(script,
"/dev/null"))?
29 strdup(script) : NULL;
32 notify_target = target? strdup(target): NULL;
34 if (notify_script || notify_target) {
36 crm_warn(
"Support for 'notification-agent' and 'notification-target' cluster options"
37 " is deprecated and will be removed in a future release"
38 " (use alerts feature instead)");
49 GHashTable *config_hash = crm_str_table_new();
51 const char *value = NULL;
54 config_hash, NULL, FALSE, now);
62 crm_trace(
"Alert %s uses default timeout of %dmsec",
65 crm_warn(
"Alert %s has invalid timeout value '%s', using default %dmsec",
70 crm_trace(
"Alert %s uses timeout of %dmsec",
73 if (entry->
timeout > *max_timeout) {
83 crm_trace(
"Alert %s uses timestamp format '%s'",
87 g_hash_table_destroy(config_hash);
95 if ((basenode == NULL) || (entry == NULL)) {
105 entry->
envvars = crm_str_table_new();
117 g_hash_table_insert(entry->
envvars, strdup(name), strdup(value));
118 crm_trace(
"Alert %s: added environment variable %s='%s'",
119 entry->
id, name, value);
127 xmlNode *event_type = NULL;
130 for (event_type = __xml_first_child(select); event_type != NULL;
131 event_type = __xml_next(event_type)) {
133 const char *tagname = crm_element_name(event_type);
135 if (tagname == NULL) {
149 const char *attr_name;
165 (nattrs + 1) *
sizeof(
char*));
175 crm_debug(
"Alert %s receives events: attributes:%s, fencing:%s, nodes:%s, resources:%s",
188 get_envvars_from_cib(alert, entry);
189 get_meta_attrs_from_cib(alert, entry, max_timeout);
190 unpack_alert_filter(alert, entry);
209 guint max_timeout = 0;
215 crm_warn(
"Ignoring deprecated notification configuration because alerts available");
222 entry->
recipient = strdup(notify_target);
224 alert_list = g_list_prepend(alert_list, entry);
225 crm_warn(
"Deprecated notification syntax in use (alerts syntax is preferable)");
236 const char *alert_id =
ID(alert);
240 if ((alert_id == NULL) || (alert_path == NULL)) {
241 crm_warn(
"Ignoring invalid alert without id and path");
247 unpack_alert(alert, entry, &max_timeout);
253 crm_debug(
"Alert %s: path=%s timeout=%dms tstamp-format='%s' %u vars",
265 unpack_alert(recipient, recipient_entry, &max_timeout);
266 alert_list = g_list_prepend(alert_list, recipient_entry);
267 crm_debug(
"Alert %s has recipient %s with value %s and %d envvars",
270 g_hash_table_size(recipient_entry->
envvars) : 0));
273 if (recipients == 0) {
274 alert_list = g_list_prepend(alert_list, entry);
#define CRM_ALERT_DEFAULT_TSTAMP_FORMAT
void pe_free_alert_list(GListPtr alert_list)
struct crm_time_s crm_time_t
#define CRM_ALERT_DEFAULT_TIMEOUT_MS
#define XML_CIB_TAG_ALERT_RESOURCES
long long crm_get_msec(const char *input)
#define XML_NVPAIR_ATTR_NAME
#define XML_CIB_TAG_ALERT_ATTRIBUTES
#define XML_CIB_TAG_NVPAIR
#define XML_ALERT_ATTR_REC_VALUE
crm_alert_entry_t * crm_dup_alert_entry(crm_alert_entry_t *entry)
GListPtr pe_unpack_alerts(xmlNode *alerts)
#define XML_TAG_ATTR_SETS
#define crm_warn(fmt, args...)
#define crm_debug(fmt, args...)
#define XML_CIB_TAG_ALERT_NODES
#define crm_trace(fmt, args...)
#define XML_TAG_META_SETS
const char * crm_element_value(xmlNode *data, const char *name)
xmlNode * crm_next_same_xml(xmlNode *sibling)
Get next instance of same XML tag.
#define XML_ALERT_ATTR_TIMEOUT
#define XML_ALERT_ATTR_TSTAMP_FORMAT
#define XML_CIB_TAG_ALERT
crm_time_t * crm_time_new(const char *string)
crm_alert_entry_t * crm_alert_entry_new(const char *id, const char *path)
Create a new alert entry structure.
char ** select_attribute_name
#define XML_CIB_TAG_ALERT_FENCING
#define XML_NVPAIR_ATTR_VALUE
void unpack_instance_attributes(xmlNode *top, xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now)
xmlNode * first_named_child(xmlNode *parent, const char *name)
#define XML_CIB_TAG_ALERT_SELECT
#define XML_ALERT_ATTR_PATH
#define XML_CIB_TAG_ALERT_ATTR
#define XML_CIB_TAG_ALERT_RECIPIENT
void crm_free_alert_entry(crm_alert_entry_t *entry)
void crm_time_free(crm_time_t *dt)