root/src/modules/external_proc.h

Revision cdee833bf18a568bdb18eaf9c50b24b43c9de9bf, 2.6 kB (checked in by Theo Schlossnagle <theo.schlossnagle@circonus.com>, 3 months ago)

Implement JSON parsing in the external module.

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2009, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  * Copyright (c) 2015, Circonus, Inc. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above
13  *       copyright notice, this list of conditions and the following
14  *       disclaimer in the documentation and/or other materials provided
15  *       with the distribution.
16  *     * Neither the name OmniTI Computer Consulting, Inc. nor the names
17  *       of its contributors may be used to endorse or promote products
18  *       derived from this software without specific prior written
19  *       permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef MODULES_EXTERNAL_PROC_H
35 #define MODULES_EXTERNAL_PROC_H
36
37 #include <mtev_defines.h>
38 #include <eventer/eventer.h>
39 #include <mtev_atomic.h>
40 #include <mtev_hash.h>
41
42 typedef enum {
43   EXTERNAL_DEFAULT_TYPE = 0,
44   EXTERNAL_NAGIOS_TYPE = 1,
45   EXTERNAL_JSON_TYPE = 2
46 } external_special_t;
47
48 struct external_response {
49   int64_t check_no;
50   int32_t exit_code;
51   int stdoutlen_sofar;
52   u_int16_t stdoutlen;
53   char *stdoutbuff;
54   int stderrlen_sofar;
55   u_int16_t stderrlen;
56   char *stderrbuff;
57 };
58 typedef struct {
59   mtev_log_stream_t nlerr;
60   mtev_log_stream_t nldeb;
61   int child;
62   int pipe_n2e[2];
63   int pipe_e2n[2];
64   char* path;
65   char* nagios_regex;
66   eventer_jobq_t *jobq;
67   mtev_atomic64_t check_no_seq;
68   mtev_hash_table external_checks;
69   mtev_hash_table *options;
70
71   struct external_response *cr;
72 } external_data_t;
73
74 typedef struct {
75   int64_t check_no;
76   int32_t exit_code;
77   u_int16_t stdoutlen;
78 } __attribute__((packed)) external_header;
79
80 int external_child(external_data_t *);
81
82 #endif
Note: See TracBrowser for help on using the browser.