summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fc7eb73)
raw | patch | inline | side by side (parent: fc7eb73)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 10 Jul 2006 09:42:10 +0000 (11:42 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 10 Jul 2006 09:42:10 +0000 (11:42 +0200) |
src/plugin.c | patch | blob | history | |
src/plugin.h | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index 2f52157082a0d0929428307999bae4551498fb04..be28671a7cb7b5efae25d14db22b5fd8c2713e3b 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
else
plugin_write (NULL, type, inst, val);
}
+
+void plugin_complain (int level, complain_t *c, const char *format, ...)
+{
+ char message[512];
+ va_list ap;
+ int step;
+
+ if (c->delay > 0)
+ {
+ c->delay--;
+ return;
+ }
+
+ step = atoi (COLLECTD_STEP);
+ assert (step > 0);
+
+ if (c->interval < step)
+ c->interval = step;
+ else
+ c->interval *= 2;
+
+ if (c->interval > 86400)
+ c->interval = 86400;
+
+ c->delay = c->interval / step;
+
+ va_start (ap, format);
+ vsnprintf (message, 512, format, ap);
+ message[511] = '\0';
+ va_end (ap);
+
+ syslog (level, message);
+}
+
+void plugin_relief (int level, complain_t *c, const char *format, ...)
+{
+ char message[512];
+ va_list ap;
+
+ if (c->interval == 0)
+ return;
+
+ c->interval = 0;
+
+ va_start (ap, format);
+ vsnprintf (message, 512, format, ap);
+ message[511] = '\0';
+ va_end (ap);
+
+ syslog (level, message);
+}
diff --git a/src/plugin.h b/src/plugin.h
index e1303c76f2a5a86ccec668902a57db03e65fb597..e1e2e7cfa2e8c889e23e193c341574550fadb3b8 100644 (file)
--- a/src/plugin.h
+++ b/src/plugin.h
+#ifndef PLUGIN_H
+#define PLUGIN_H
+
/**
* collectd - src/plugin.h
* Copyright (C) 2005,2006 Florian octo Forster
* Florian octo Forster <octo at verplant.org>
**/
-#ifndef PLUGIN_H
-#define PLUGIN_H
+/*
+ *
+ */
+typedef struct complain_s
+{
+ unsigned int interval; /* how long we wait for reporting this error again */
+ unsigned int delay; /* how many more iterations we still need to wait */
+} complain_t;
/*
* NAME
void plugin_submit (char *type, char *inst, char *val);
+
+void plugin_complain (int level, complain_t *c, const char *format, ...);
+void plugin_relief (int level, complain_t *c, const char *format, ...);
+
#endif /* PLUGIN_H */