root/src/modules/external.c

Revision 967946027f391d9ee29dbaab2986f915c6a3ec3e, 20.1 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 4 years ago)

cleanup... make should not rebuild noitd and stratcond every time now

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  *       notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  *       copyright notice, this list of conditions and the following
13  *       disclaimer in the documentation and/or other materials provided
14  *       with the distribution.
15  *     * Neither the name OmniTI Computer Consulting, Inc. nor the names
16  *       of its contributors may be used to endorse or promote products
17  *       derived from this software without specific prior written
18  *       permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #include "noit_defines.h"
34
35 #include <stdio.h>
36 #include <unistd.h>
37 #include <netdb.h>
38 #include <errno.h>
39 #include <fcntl.h>
40 #include <assert.h>
41 #include <sys/uio.h>
42 #ifdef HAVE_SYS_WAIT_H
43 #include <sys/wait.h>
44 #endif
45 #ifdef HAVE_SYS_FILIO_H
46 #include <sys/filio.h>
47 #endif
48 #ifdef HAVE_NETINET_IN_SYSTM_H
49 #include <netinet/in_systm.h>
50 #endif
51 #include <pcre.h>
52
53 #include "noit_module.h"
54 #include "noit_check.h"
55 #include "noit_check_tools.h"
56 #include "utils/noit_log.h"
57 #include "utils/noit_security.h"
58 #include "external_proc.h"
59
60 struct check_info {
61   int64_t check_no;
62   u_int16_t argcnt;
63   u_int16_t *arglens;
64   char **args;
65   u_int16_t envcnt;
66   u_int16_t *envlens;
67   char **envs;
68   noit_check_t *check;
69   int exit_code;
70
71   int timedout;
72   char *output;
73   char *error;
74   pcre *matcher;
75   eventer_t timeout_event;
76 };
77
78 typedef struct external_closure {
79   noit_module_t *self;
80   noit_check_t *check;
81 } external_closure_t;
82
83 /* Protocol:
84  *   noit 2 ext:
85  *     int64(check_no)
86  *     uint16(0) -> cancel .end
87
88  *     int64(check_no)
89  *     uint16(argcnt) [argcnt > 0]
90  *     uint16(arglen) x argcnt  (arglen includes \0)
91  *     string of sum(arglen)
92  *     uint16(envcnt)
93  *     uint16(envlen) x envcnt  (envlen includes \0)
94  *     string of sum(envlen) -> execve .end
95  *
96  *   ext 2 noit:
97  *     int64(check_no)
98  *     int32(exitcode) [0 -> good, {1,2} -> bad, 3 -> unknown]
99  *     uint16(outlen) (includes \0)
100  *     string of outlen
101  *     uint16(errlen) (includes \0)
102  *     string of errlen -> complete .end
103  */
104
105 static int external_config(noit_module_t *self, noit_hash_table *options) {
106   external_data_t *data;
107   data = noit_module_get_userdata(self);
108   if(data) {
109     if(data->options) {
110       noit_hash_destroy(data->options, free, free);
111       free(data->options);
112     }
113   }
114   else
115     data = calloc(1, sizeof(*data));
116   data->options = options;
117   if(!data->options) data->options = calloc(1, sizeof(*data->options));
118   noit_module_set_userdata(self, data);
119   return 1;
120 }
121
122 static void external_log_results(noit_module_t *self, noit_check_t *check) {
123   external_data_t *data;
124   struct check_info *ci;
125   stats_t current;
126   struct timeval duration;
127
128   noit_check_stats_clear(&current);
129
130   data = noit_module_get_userdata(self);
131   ci = (struct check_info *)check->closure;
132
133   noitL(data->nldeb, "external(%s) (timeout: %d, exit: %x)\n",
134         check->target, ci->timedout, ci->exit_code);
135
136   gettimeofday(&current.whence, NULL);
137   sub_timeval(current.whence, check->last_fire_time, &duration);
138   current.duration = duration.tv_sec * 1000 + duration.tv_usec / 1000;
139   if(ci->timedout) {
140     current.available = NP_UNAVAILABLE;
141     current.state = NP_BAD;
142   }
143   else if(WEXITSTATUS(ci->exit_code) == 3) {
144     current.available = NP_UNKNOWN;
145     current.state = NP_UNKNOWN;
146   }
147   else {
148     current.available = NP_AVAILABLE;
149     current.state = (WEXITSTATUS(ci->exit_code) == 0) ? NP_GOOD : NP_BAD;
150   }
151
152   /* Hack the output into metrics */
153   if(ci->output && ci->matcher) {
154     int rc, len, startoffset = 0;
155     int ovector[30];
156     len = strlen(ci->output);
157     noitL(data->nldeb, "going to match output at %d/%d\n", startoffset, len);
158     while((rc = pcre_exec(ci->matcher, NULL, ci->output, len, startoffset, 0,
159                           ovector, sizeof(ovector)/sizeof(*ovector))) > 0) {
160       char metric[128];
161       char value[128];
162       startoffset = ovector[1];
163       noitL(data->nldeb, "matched at offset %d\n", rc);
164       if(pcre_copy_named_substring(ci->matcher, ci->output, ovector, rc,
165                                    "key", metric, sizeof(metric)) > 0 &&
166          pcre_copy_named_substring(ci->matcher, ci->output, ovector, rc,
167                                    "value", value, sizeof(value)) > 0) {
168         /* We're able to extract something... */
169         noit_stats_set_metric(&current, metric, METRIC_GUESS, value);
170       }
171       noitL(data->nldeb, "going to match output at %d/%d\n", startoffset, len);
172     }
173     noitL(data->nldeb, "match failed.... %d\n", rc);
174   }
175
176   current.status = ci->output;
177   noit_check_set_stats(self, check, &current);
178
179   /* If we didn't exit normally, or we core, or we have stderr to report...
180    * provide a full report.
181    */
182   if((WTERMSIG(ci->exit_code) != SIGQUIT && WTERMSIG(ci->exit_code) != 0) ||
183      WCOREDUMP(ci->exit_code) ||
184      (ci->error && *ci->error)) {
185     char uuid_str[37];
186     uuid_unparse_lower(check->checkid, uuid_str);
187     noitL(data->nlerr, "external/%s: (sig:%d%s) [%s]\n", uuid_str,
188           WTERMSIG(ci->exit_code), WCOREDUMP(ci->exit_code)?", cored":"",
189           ci->error ? ci->error : "");
190   }
191 }
192 static int external_timeout(eventer_t e, int mask,
193                             void *closure, struct timeval *now) {
194   external_closure_t *ecl = (external_closure_t *)closure;
195   struct check_info *data;
196   if(!NOIT_CHECK_KILLED(ecl->check) && !NOIT_CHECK_DISABLED(ecl->check)) {
197     data = (struct check_info *)ecl->check->closure;
198     data->timedout = 1;
199     data->exit_code = 3;
200     external_log_results(ecl->self, ecl->check);
201     data->timeout_event = NULL;
202   }
203   ecl->check->flags &= ~NP_RUNNING;
204   free(ecl);
205   return 0;
206 }
207 static void check_info_clean(struct check_info *ci) {
208   int i;
209   for(i=0; i<ci->argcnt; i++)
210     if(ci->args[i]) free(ci->args[i]);
211   if(ci->arglens) free(ci->arglens);
212   if(ci->args) free(ci->args);
213   for(i=0; i<ci->envcnt; i++)
214     if(ci->envs[i]) free(ci->envs[i]);
215   if(ci->envlens) free(ci->envlens);
216   if(ci->envs) free(ci->envs);
217   if(ci->matcher) pcre_free(ci->matcher);
218   memset(ci, 0, sizeof(*ci));
219 }
220 static int external_handler(eventer_t e, int mask,
221                             void *closure, struct timeval *now) {
222   noit_module_t *self = (noit_module_t *)closure;
223   external_data_t *data;
224
225   data = noit_module_get_userdata(self);
226   while(1) {
227     int inlen, expectlen;
228     noit_check_t *check;
229     struct check_info *ci;
230     void *vci;
231
232     if(!data->cr) {
233       struct external_response r;
234       struct msghdr msg;
235       struct iovec v[3];
236       memset(&r, 0, sizeof(r));
237       v[0].iov_base = (char *)&r.check_no;
238       v[0].iov_len = sizeof(r.check_no);
239       v[1].iov_base = (char *)&r.exit_code;
240       v[1].iov_len = sizeof(r.exit_code);
241       v[2].iov_base = (char *)&r.stdoutlen;
242       v[2].iov_len = sizeof(r.stdoutlen);
243       expectlen = v[0].iov_len + v[1].iov_len + v[2].iov_len;
244
245       /* Make this into a recv'ble message so we can PEEK */
246       memset(&msg, 0, sizeof(msg));
247       msg.msg_iov = v;
248       msg.msg_iovlen = 3;
249       inlen = recvmsg(e->fd, &msg, MSG_PEEK);
250       if(inlen == 0) goto widowed;
251       if((inlen == -1 && errno == EAGAIN) ||
252          (inlen > 0 && inlen < expectlen))
253         return EVENTER_READ | EVENTER_EXCEPTION;
254       if(inlen == -1)
255         noitL(noit_error, "recvmsg() failed: %s\n", strerror(errno));
256       assert(inlen == expectlen);
257       while(-1 == (inlen = recvmsg(e->fd, &msg, 0)) && errno == EINTR);
258       assert(inlen == expectlen);
259       data->cr = calloc(sizeof(*data->cr), 1);
260       memcpy(data->cr, &r, sizeof(r));
261       data->cr->stdoutbuff = malloc(data->cr->stdoutlen);
262     }
263     if(data->cr) {
264       while(data->cr->stdoutlen_sofar < data->cr->stdoutlen) {
265         while((inlen =
266                  read(e->fd,
267                       data->cr->stdoutbuff + data->cr->stdoutlen_sofar,
268                       data->cr->stdoutlen - data->cr->stdoutlen_sofar)) == -1 &&
269                errno == EINTR);
270         if(inlen == -1 && errno == EAGAIN)
271           return EVENTER_READ | EVENTER_EXCEPTION;
272         if(inlen == 0) goto widowed;
273         data->cr->stdoutlen_sofar += inlen;
274       }
275       assert(data->cr->stdoutbuff[data->cr->stdoutlen-1] == '\0');
276       if(!data->cr->stderrbuff) {
277         while((inlen = read(e->fd, &data->cr->stderrlen,
278                             sizeof(data->cr->stderrlen))) == -1 &&
279               errno == EINTR);
280         if(inlen == -1 && errno == EAGAIN)
281           return EVENTER_READ | EVENTER_EXCEPTION;
282         if(inlen == 0) goto widowed;
283         assert(inlen == sizeof(data->cr->stderrlen));
284         data->cr->stderrbuff = malloc(data->cr->stderrlen);
285       }
286       while(data->cr->stderrlen_sofar < data->cr->stderrlen) {
287         while((inlen =
288                  read(e->fd,
289                       data->cr->stderrbuff + data->cr->stderrlen_sofar,
290                       data->cr->stderrlen - data->cr->stderrlen_sofar)) == -1 &&
291                errno == EINTR);
292         if(inlen == -1 && errno == EAGAIN)
293           return EVENTER_READ | EVENTER_EXCEPTION;
294         if(inlen == 0) goto widowed;
295         data->cr->stderrlen_sofar += inlen;
296       }
297       assert(data->cr->stderrbuff[data->cr->stderrlen-1] == '\0');
298     }
299     assert(data->cr && data->cr->stdoutbuff && data->cr->stderrbuff);
300
301     gettimeofday(now, NULL); /* set it, as we care about accuracy */
302
303     /* Lookup data in check_no hash */
304     if(noit_hash_retrieve(&data->external_checks,
305                           (const char *)&data->cr->check_no,
306                           sizeof(data->cr->check_no),
307                           &vci) == 0)
308       vci = NULL;
309     ci = (struct check_info *)vci;
310
311     /* We've seen it, it ain't coming again...
312      * remove it, we'll free it ourselves */
313     noit_hash_delete(&data->external_checks,
314                      (const char *)&data->cr->check_no,
315                      sizeof(data->cr->check_no), NULL, NULL);
316
317     /* If there is no timeout_event, the check must have completed.
318      * We have nothing to do. */
319     if(!ci || !ci->timeout_event) {
320       free(data->cr->stdoutbuff);
321       free(data->cr->stderrbuff);
322       free(data->cr);
323       data->cr = NULL;
324       continue;
325     }
326     ci->exit_code = data->cr->exit_code;
327     ci->output = data->cr->stdoutbuff;
328     ci->error = data->cr->stderrbuff;
329     free(data->cr);
330     data->cr = NULL;
331     check = ci->check;
332     external_log_results(self, check);
333     eventer_remove(ci->timeout_event);
334     free(ci->timeout_event->closure);
335     eventer_free(ci->timeout_event);
336     ci->timeout_event = NULL;
337     check->flags &= ~NP_RUNNING;
338   }
339
340  widowed:
341   noitL(noit_error, "external module terminated, must restart.\n");
342   exit(1);
343 }
344
345 static int external_init(noit_module_t *self) {
346   external_data_t *data;
347
348   data = noit_module_get_userdata(self);
349   if(!data) data = malloc(sizeof(*data));
350   data->nlerr = noit_log_stream_find("error/external");
351   data->nldeb = noit_log_stream_find("debug/external");
352
353   data->jobq = calloc(1, sizeof(*data->jobq));
354   eventer_jobq_init(data->jobq, "external");
355   data->jobq->backq = eventer_default_backq();
356   eventer_jobq_increase_concurrency(data->jobq);
357
358   if(socketpair(AF_UNIX, SOCK_STREAM, 0, data->pipe_n2e) != 0 ||
359      socketpair(AF_UNIX, SOCK_STREAM, 0, data->pipe_e2n) != 0) {
360     noitL(noit_error, "external: pipe() failed: %s\n", strerror(errno));
361     return -1;
362   }
363
364   data->child = fork();
365   if(data->child == -1) {
366     /* No child, bail. */
367     noitL(noit_error, "external: fork() failed: %s\n", strerror(errno));
368     return -1;
369   }
370
371   /* parent must close the read side of n2e and the write side of e2n */
372   /* The child must do the opposite */
373   close(data->pipe_n2e[(data->child == 0) ? 1 : 0]);
374   close(data->pipe_e2n[(data->child == 0) ? 0 : 1]);
375
376   /* Now the parent must set its bits non-blocking, the child need not */
377   if(data->child != 0) {
378     /* in the parent */
379     if(eventer_set_fd_nonblocking(data->pipe_e2n[0]) == -1) {
380       close(data->pipe_n2e[1]);
381       close(data->pipe_e2n[0]);
382       noitL(noit_error,
383             "external: could not set pipe non-blocking: %s\n",
384             strerror(errno));
385       return -1;
386     }
387     eventer_t newe;
388     newe = eventer_alloc();
389     newe->fd = data->pipe_e2n[0];
390     newe->mask = EVENTER_READ | EVENTER_EXCEPTION;
391     newe->callback = external_handler;
392     newe->closure = self;
393     eventer_add(newe);
394   }
395   else {
396     const char *user = NULL, *group = NULL;
397     if(data->options) {
398       noit_hash_retr_str(data->options, "user", 4, &user);
399       noit_hash_retr_str(data->options, "group", 4, &group);
400     }
401     noit_security_usergroup(user, group, noit_false);
402     exit(external_child(data));
403   }
404   noit_module_set_userdata(self, data);
405   return 0;
406 }
407
408 static void external_cleanup(noit_module_t *self, noit_check_t *check) {
409   struct check_info *ci = (struct check_info *)check->closure;
410   if(ci) {
411     if(ci->timeout_event) {
412       eventer_remove(ci->timeout_event);
413       free(ci->timeout_event->closure);
414       eventer_free(ci->timeout_event);
415       ci->timeout_event = NULL;
416     }
417   }
418 }
419 #define assert_write(fd, w, s) assert(write(fd, w, s) == s)
420 static int external_enqueue(eventer_t e, int mask, void *closure,
421                             struct timeval *now) {
422   external_closure_t *ecl = (external_closure_t *)closure;
423   struct check_info *ci = (struct check_info *)ecl->check->closure;
424   external_data_t *data;
425   int fd, i;
426
427   if(mask == EVENTER_ASYNCH_CLEANUP) {
428     e->mask = 0;
429     return 0;
430   }
431   if(!(mask & EVENTER_ASYNCH_WORK)) return 0;
432   data = noit_module_get_userdata(ecl->self);
433   fd = data->pipe_n2e[1];
434   assert_write(fd, &ci->check_no, sizeof(ci->check_no));
435   assert_write(fd, &ci->argcnt, sizeof(ci->argcnt));
436   assert_write(fd, ci->arglens, sizeof(*ci->arglens)*ci->argcnt);
437   for(i=0; i<ci->argcnt; i++)
438     assert_write(fd, ci->args[i], ci->arglens[i]);
439   assert_write(fd, &ci->envcnt, sizeof(ci->envcnt));
440   assert_write(fd, ci->envlens, sizeof(*ci->envlens)*ci->envcnt);
441   for(i=0; i<ci->envcnt; i++)
442     assert_write(fd, ci->envs[i], ci->envlens[i]);
443   return 0;
444 }
445 static int external_invoke(noit_module_t *self, noit_check_t *check) {
446   struct timeval when, p_int;
447   external_closure_t *ecl;
448   struct check_info *ci = (struct check_info *)check->closure;
449   eventer_t newe;
450   external_data_t *data;
451   noit_hash_table check_attrs_hash = NOIT_HASH_EMPTY;
452   int i, klen;
453   noit_hash_iter iter = NOIT_HASH_ITER_ZERO;
454   const char *name, *value;
455   char interp_fmt[4096], interp_buff[4096];
456
457   data = noit_module_get_userdata(self);
458
459   check->flags |= NP_RUNNING;
460   noitL(data->nldeb, "external_invoke(%p,%s)\n",
461         self, check->target);
462
463   /* remove a timeout if we still have one -- we should unless someone
464    * has set a lower timeout than the period.
465    */
466   if(ci->timeout_event) {
467     eventer_remove(ci->timeout_event);
468     free(ci->timeout_event->closure);
469     eventer_free(ci->timeout_event);
470     ci->timeout_event = NULL;
471   }
472
473   check_info_clean(ci);
474
475   gettimeofday(&when, NULL);
476   memcpy(&check->last_fire_time, &when, sizeof(when));
477
478   /* Setup all our check bits */
479   ci->check_no = noit_atomic_inc64(&data->check_no_seq);
480   ci->check = check;
481   /* We might want to extract metrics */
482   if(noit_hash_retr_str(check->config,
483                         "output_extract", strlen("output_extract"),
484                         &value) != 0) {
485     const char *error;
486     int erroffset;
487     ci->matcher = pcre_compile(value, 0, &error, &erroffset, NULL);
488     if(!ci->matcher) {
489       noitL(data->nlerr, "external pcre /%s/ failed @ %d: %s\n",
490             value, erroffset, error);
491     }
492   }
493
494   noit_check_make_attrs(check, &check_attrs_hash);
495
496   /* Count the args */
497   i = 1;
498   while(1) {
499     char argname[10];
500     snprintf(argname, sizeof(argname), "arg%d", i);
501     if(noit_hash_retr_str(check->config, argname, strlen(argname),
502                           &value) == 0) break;
503     i++;
504   }
505   ci->argcnt = i + 1; /* path, arg0, (i-1 more args) */
506   ci->arglens = calloc(ci->argcnt, sizeof(*ci->arglens));
507   ci->args = calloc(ci->argcnt, sizeof(*ci->args));
508
509   /* Make the command */
510   if(noit_hash_retr_str(check->config, "command", strlen("command"),
511                         &value) == 0) {
512     value = "/bin/true";
513   }
514   ci->args[0] = strdup(value);
515   ci->arglens[0] = strlen(ci->args[0]) + 1;
516
517   i = 0;
518   while(1) {
519     char argname[10];
520     snprintf(argname, sizeof(argname), "arg%d", i);
521     if(noit_hash_retr_str(check->config, argname, strlen(argname),
522                           &value) == 0) {
523       if(i == 0) {
524         /* if we don't have arg0, make it last element of path */
525         char *cp = ci->args[0] + strlen(ci->args[0]);
526         while(cp > ci->args[0] && *(cp-1) != '/') cp--;
527         value = cp;
528       }
529       else break; /* if we don't have argn, we're done */
530     }
531     noit_check_interpolate(interp_buff, sizeof(interp_buff), value,
532                            &check_attrs_hash, check->config);
533     ci->args[i+1] = strdup(interp_buff);
534     ci->arglens[i+1] = strlen(ci->args[i+1]) + 1;
535     i++;
536   }
537
538   /* Make the environment */
539   memset(&iter, 0, sizeof(iter));
540   ci->envcnt = 0;
541   while(noit_hash_next_str(check->config, &iter, &name, &klen, &value))
542     if(!strncasecmp(name, "env_", 4))
543       ci->envcnt++;
544   memset(&iter, 0, sizeof(iter));
545   ci->envlens = calloc(ci->envcnt, sizeof(*ci->envlens));
546   ci->envs = calloc(ci->envcnt, sizeof(*ci->envs));
547   ci->envcnt = 0;
548   while(noit_hash_next_str(check->config, &iter, &name, &klen, &value))
549     if(!strncasecmp(name, "env_", 4)) {
550       snprintf(interp_fmt, sizeof(interp_fmt), "%s=%s", name+4, value);
551       noit_check_interpolate(interp_buff, sizeof(interp_buff), interp_fmt,
552                              &check_attrs_hash, check->config);
553       ci->envs[ci->envcnt] = strdup(interp_buff);
554       ci->envlens[ci->envcnt] = strlen(ci->envs[ci->envcnt]) + 1;
555       ci->envcnt++;
556     }
557
558   noit_hash_destroy(&check_attrs_hash, NULL, NULL);
559
560   noit_hash_store(&data->external_checks,
561                   (const char *)&ci->check_no, sizeof(ci->check_no),
562                   ci);
563
564   /* Setup a timeout */
565   newe = eventer_alloc();
566   newe->mask = EVENTER_TIMER;
567   gettimeofday(&when, NULL);
568   p_int.tv_sec = check->timeout / 1000;
569   p_int.tv_usec = (check->timeout % 1000) * 1000;
570   add_timeval(when, p_int, &newe->whence);
571   ecl = calloc(1, sizeof(*ecl));
572   ecl->self = self;
573   ecl->check = check;
574   newe->closure = ecl;
575   newe->callback = external_timeout;
576   eventer_add(newe);
577   ci->timeout_event = newe;
578
579   /* Setup push */
580   newe = eventer_alloc();
581   newe->mask = EVENTER_ASYNCH;
582   add_timeval(when, p_int, &newe->whence);
583   ecl = calloc(1, sizeof(*ecl));
584   ecl->self = self;
585   ecl->check = check;
586   newe->closure = ecl;
587   newe->callback = external_enqueue;
588   eventer_add(newe);
589
590   return 0;
591 }
592 static int external_initiate_check(noit_module_t *self, noit_check_t *check,
593                                     int once, noit_check_t *cause) {
594   if(!check->closure) check->closure = calloc(1, sizeof(struct check_info));
595   INITIATE_CHECK(external_invoke, self, check);
596   return 0;
597 }
598
599 static int external_onload(noit_image_t *self) {
600   eventer_name_callback("external/timeout", external_timeout);
601   eventer_name_callback("external/handler", external_handler);
602   return 0;
603 }
604
605 #include "external.xmlh"
606 noit_module_t external = {
607   {
608     NOIT_MODULE_MAGIC,
609     NOIT_MODULE_ABI_VERSION,
610     "external",
611     "checks via external programs",
612     external_xml_description,
613     external_onload
614   },
615   external_config,
616   external_init,
617   external_initiate_check,
618   external_cleanup
619 };
620
Note: See TracBrowser for help on using the browser.