summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 365be10)
raw | patch | inline | side by side (parent: 365be10)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 1 Nov 2007 11:27:56 +0000 (12:27 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 1 Nov 2007 11:27:56 +0000 (12:27 +0100) |
src/plugin.c | patch | blob | history | |
src/plugin.h | patch | blob | history | |
src/utils_threshold.c | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index 84b7e0be9f175e0f1ed6b0e4321e7e20c7a42e3f..6b17290f32dbe08a9a4bb6406cbc8fef35efdd01 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
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);
diff --git a/src/plugin.h b/src/plugin.h
index f1a985f6a6973c1805843358cd083a9eca52589b..96eb0cb5633cf1cbe5fe6153b176f46040b49c5e 100644 (file)
--- a/src/plugin.h
+++ b/src/plugin.h
# define LOG_DEBUG 7
#endif
-#define NOTIF_MAX_MSG_LEN 128
+#define NOTIF_MAX_MSG_LEN 256
#define NOTIF_FAILURE 1
#define NOTIF_WARNING 2
diff --git a/src/utils_threshold.c b/src/utils_threshold.c
index 91407e0cbffa531468b86e1e81fc8aa9fb3b987d..1c9ccdd15b00692ecdba03eb8817d52fbd546207 100644 (file)
--- a/src/utils_threshold.c
+++ b/src/utils_threshold.c
for (i = 0; i < ds->ds_num; i++)
{
if ((th->min > values[i]) || (th->max < values[i]))
- WARNING ("ut_check_threshold: ds%i: %lf <= !%lf <= %lf",
- i, th->min, values[i], th->max);
- }
+ {
+ notification_t n;
+ char *buf;
+ size_t bufsize;
+ int status;
+
+ WARNING ("ut_check_threshold: ds[%s]: %lf <= !%lf <= %lf",
+ ds->ds[i].name, th->min, values[i], th->max);
+
+ buf = n.message;
+ bufsize = sizeof (n.message);
+
+ status = snprintf (buf, bufsize, "Host %s, plugin %s",
+ vl->host, vl->plugin);
+ buf += status;
+ bufsize -= status;
+
+ if (vl->plugin_instance[0] != '\0')
+ {
+ status = snprintf (buf, bufsize, " (instance %s)",
+ vl->plugin_instance);
+ buf += status;
+ bufsize -= status;
+ }
+
+ status = snprintf (buf, bufsize, " type %s", ds->type);
+ buf += status;
+ bufsize -= status;
+
+ if (vl->type_instance[0] != '\0')
+ {
+ status = snprintf (buf, bufsize, " (instance %s)",
+ vl->type_instance);
+ buf += status;
+ bufsize -= status;
+ }
+
+ status = snprintf (buf, bufsize, ": Data source \"%s\" is currently "
+ "%lf. That is %s the configured threshold of %lf.",
+ ds->ds[i].name, values[i],
+ (values[i] < th->min) ? "below" : "above",
+ (values[i] < th->min) ? th->min : th->max);
+ buf += status;
+ bufsize -= status;
+
+ n.severity = NOTIF_FAILURE;
+ n.time = vl->time;
+
+ strncpy (n.host, vl->host, sizeof (n.host));
+ n.host[sizeof (n.host) - 1] = '\0';
+
+ plugin_dispatch_notification (&n);
+ }
+ } /* for (i = 0; i < ds->ds_num; i++) */
sfree (values);