diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 26f9c8a..a67911c 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am | |||
@@ -1,5 +1,7 @@ | |||
1 | ## Process this file with automake to produce Makefile.in | 1 | ## Process this file with automake to produce Makefile.in |
2 | 2 | ||
3 | SUBDIRS = tests | ||
4 | |||
3 | VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t | 5 | VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t |
4 | 6 | ||
5 | INCLUDES = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/intl @LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@ | 7 | INCLUDES = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/intl @LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@ |
@@ -41,6 +43,7 @@ TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir) | |||
41 | TESTS = @PLUGIN_TEST@ | 43 | TESTS = @PLUGIN_TEST@ |
42 | 44 | ||
43 | test: | 45 | test: |
46 | cd tests && make test | ||
44 | perl -I $(top_builddir) -I $(top_srcdir) ../test.pl | 47 | perl -I $(top_builddir) -I $(top_srcdir) ../test.pl |
45 | 48 | ||
46 | AM_INSTALL_PROGRAM_FLAGS = @INSTALL_OPTS@ | 49 | AM_INSTALL_PROGRAM_FLAGS = @INSTALL_OPTS@ |
diff --git a/plugins/utils.c b/plugins/utils.c index 8b31c5a..dbb2520 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -265,7 +265,62 @@ is_option (char *str) | |||
265 | return FALSE; | 265 | return FALSE; |
266 | } | 266 | } |
267 | 267 | ||
268 | void set_threshold_start (threshold *this, double value) { | ||
269 | this->start = value; | ||
270 | this->start_infinity = FALSE; | ||
271 | } | ||
272 | |||
273 | void set_threshold_end (threshold *this, double value) { | ||
274 | this->end = value; | ||
275 | this->end_infinity = FALSE; | ||
276 | } | ||
277 | |||
278 | threshold | ||
279 | *parse_threshold (char *str) { | ||
280 | threshold *temp_threshold; | ||
281 | double start; | ||
282 | double end; | ||
283 | char *end_str; | ||
268 | 284 | ||
285 | temp_threshold = (threshold *) malloc(sizeof(threshold)); | ||
286 | |||
287 | /* Set defaults */ | ||
288 | temp_threshold->start = 0; | ||
289 | temp_threshold->start_infinity = FALSE; | ||
290 | temp_threshold->end = 0; | ||
291 | temp_threshold->end_infinity = TRUE; | ||
292 | temp_threshold->alert_on = OUTSIDE; | ||
293 | |||
294 | if (str[0] == '@') { | ||
295 | temp_threshold->alert_on = INSIDE; | ||
296 | str++; | ||
297 | } | ||
298 | |||
299 | end_str = index(str, ':'); | ||
300 | if (end_str != NULL) { | ||
301 | if (str[0] == '~') { | ||
302 | temp_threshold->start_infinity = TRUE; | ||
303 | } else { | ||
304 | start = strtod(str, NULL); /* Will stop at the ':' */ | ||
305 | set_threshold_start(temp_threshold, start); | ||
306 | } | ||
307 | end_str++; /* Move past the ':' */ | ||
308 | } else { | ||
309 | end_str = str; | ||
310 | } | ||
311 | end = strtod(end_str, NULL); | ||
312 | if (strcmp(end_str, "") != 0) { | ||
313 | set_threshold_end(temp_threshold, end); | ||
314 | } | ||
315 | |||
316 | if (temp_threshold->start_infinity == TRUE || | ||
317 | temp_threshold->end_infinity == TRUE || | ||
318 | temp_threshold->start <= temp_threshold->end) { | ||
319 | return temp_threshold; | ||
320 | } | ||
321 | free(temp_threshold); | ||
322 | return NULL; | ||
323 | } | ||
269 | 324 | ||
270 | #ifdef NEED_GETTIMEOFDAY | 325 | #ifdef NEED_GETTIMEOFDAY |
271 | int | 326 | int |
diff --git a/plugins/utils.h b/plugins/utils.h index 2d97634..f47d053 100644 --- a/plugins/utils.h +++ b/plugins/utils.h | |||
@@ -58,6 +58,19 @@ struct timeval { | |||
58 | }; | 58 | }; |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | #define OUTSIDE 0 | ||
62 | #define INSIDE 1 | ||
63 | |||
64 | typedef struct threshold_struct { | ||
65 | double start; | ||
66 | int start_infinity; /* FALSE (default) or TRUE */ | ||
67 | double end; | ||
68 | int end_infinity; | ||
69 | int alert_on; /* OUTSIDE (default) or INSIDE */ | ||
70 | } threshold; | ||
71 | |||
72 | threshold *parse_threshold (char *); | ||
73 | |||
61 | #ifndef HAVE_GETTIMEOFDAY | 74 | #ifndef HAVE_GETTIMEOFDAY |
62 | int gettimeofday(struct timeval *, struct timezone *); | 75 | int gettimeofday(struct timeval *, struct timezone *); |
63 | #endif | 76 | #endif |