diff --git a/src/plugin.c b/src/plugin.c
index 37c91a9ba2aa0d2fb79b5ec754d8d618ac0eb8f2..6b17290f32dbe08a9a4bb6406cbc8fef35efdd01 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
#include "configfile.h"
#include "utils_llist.h"
#include "utils_cache.h"
+#include "utils_threshold.h"
/*
* Private structures
static llist_t *list_shutdown;
static llist_t *list_data_set;
static llist_t *list_log;
+static llist_t *list_notification;
static char *plugindir = NULL;
return (register_callback (&list_log, name, (void *) callback));
} /* int plugin_register_log */
+int plugin_register_notification (const char *name,
+ int (*callback) (const notification_t *notif))
+{
+ return (register_callback (&list_log, name, (void *) callback));
+} /* int plugin_register_log */
+
int plugin_unregister_config (const char *name)
{
cf_unregister (name);
return (plugin_unregister (list_log, name));
}
+int plugin_unregister_notification (const char *name)
+{
+ return (plugin_unregister (list_notification, name));
+}
+
void plugin_init_all (void)
{
int (*callback) (void);
/* Update the value cache */
uc_update (ds, vl);
+ ut_check_threshold (ds, vl);
le = llist_head (list_write);
while (le != NULL)
return (0);
} /* int plugin_dispatch_values */
+int plugin_dispatch_notification (const notification_t *notif)
+{
+ int (*callback) (const notification_t *);
+ llentry_t *le;
+ /* Possible TODO: Add flap detection here */
+
+ DEBUG ("plugin_dispatch_notification: severity = %i; message = %s; "
+ "time = %u; host = %s;",
+ notif->severity, notif->message,
+ (unsigned int) notif->time, notif->host);
+
+ /* Nobody cares for notifications */
+ if (list_notification == NULL)
+ return (-1);
+
+ le = llist_head (list_notification);
+ while (le != NULL)
+ {
+ callback = (int (*) (const notification_t *)) le->value;
+ (*callback) (notif);
+
+ le = le->next;
+ }
+
+ return (0);
+} /* int plugin_dispatch_notification */
+
void plugin_log (int level, const char *format, ...)
{
char msg[512];