summaryrefslogtreecommitdiffstats
path: root/plugins/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/common.h')
-rw-r--r--plugins/common.h200
1 files changed, 94 insertions, 106 deletions
diff --git a/plugins/common.h b/plugins/common.h
index 833479ce..ef888d08 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -1,126 +1,122 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2 *
3* Monitoring Plugins common include file 3 * Monitoring Plugins common include file
4* 4 *
5* License: GPL 5 * License: GPL
6* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) 6 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
7* Copyright (c) 2003-2007 Monitoring Plugins Development Team 7 * Copyright (c) 2003-2007 Monitoring Plugins Development Team
8* 8 *
9* Description: 9 * Description:
10* 10 *
11* This file contains common include files and defines used in many of 11 * This file contains common include files and defines used in many of
12* the plugins. 12 * the plugins.
13* 13 *
14* 14 *
15* This program is free software: you can redistribute it and/or modify 15 * This program is free software: you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by 16 * it under the terms of the GNU General Public License as published by
17* the Free Software Foundation, either version 3 of the License, or 17 * the Free Software Foundation, either version 3 of the License, or
18* (at your option) any later version. 18 * (at your option) any later version.
19* 19 *
20* This program is distributed in the hope that it will be useful, 20 * This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details. 23 * GNU General Public License for more details.
24* 24 *
25* You should have received a copy of the GNU General Public License 25 * You should have received a copy of the GNU General Public License
26* along with this program. If not, see <http://www.gnu.org/licenses/>. 26 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27* 27 *
28* 28 *
29*****************************************************************************/ 29 *****************************************************************************/
30 30
31#ifndef _COMMON_H_ 31#ifndef _COMMON_H_
32#define _COMMON_H_ 32#define _COMMON_H_
33 33
34#include "config.h" 34#include "../config.h"
35#include "../lib/monitoringplug.h"
35 36
36#ifdef HAVE_FEATURES_H 37#ifdef HAVE_FEATURES_H
37#include <features.h> 38# include <features.h>
38#endif 39#endif
39 40
40#include <stdio.h> /* obligatory includes */ 41#include <stdio.h> /* obligatory includes */
41#include <stdlib.h> 42#include <stdlib.h>
42#include <errno.h> 43#include <errno.h>
43 44
44/* This block provides uintmax_t - should be reported to coreutils that this should be added to fsuage.h */ 45/* This block provides uintmax_t - should be reported to coreutils that this should be added to
46 * fsuage.h */
45#if HAVE_INTTYPES_H 47#if HAVE_INTTYPES_H
46# include <inttypes.h> 48# include <inttypes.h>
47#endif 49#endif
48#if HAVE_STDINT_H 50#if HAVE_STDINT_H
49# include <stdint.h> 51# include <stdint.h>
50#endif 52#endif
51#include <unistd.h> 53#include <unistd.h>
52#ifndef UINTMAX_MAX 54#ifndef UINTMAX_MAX
53# define UINTMAX_MAX ((uintmax_t) -1) 55# define UINTMAX_MAX ((uintmax_t) - 1)
54#endif 56#endif
55 57
56#include <limits.h> /* This is assumed true, because coreutils assume it too */ 58#include <limits.h> /* This is assumed true, because coreutils assume it too */
57 59
58#ifdef HAVE_MATH_H 60#ifdef HAVE_MATH_H
59#include <math.h> 61# include <math.h>
60#endif 62#endif
61 63
62#ifdef _AIX 64#ifdef _AIX
63#ifdef HAVE_MP_H 65# ifdef HAVE_MP_H
64#include <mp.h> 66# include <mp.h>
65#endif 67# endif
66#endif 68#endif
67 69
68#ifdef HAVE_STRINGS_H 70#ifdef HAVE_STRINGS_H
69#include <strings.h> 71# include <strings.h>
70#endif 72#endif
71#ifdef HAVE_STRING_H 73#ifdef HAVE_STRING_H
72#include <string.h> 74# include <string.h>
73#endif 75#endif
74 76
75#ifdef HAVE_UNISTD_H 77#ifdef HAVE_UNISTD_H
76#include <unistd.h> 78# include <unistd.h>
77#endif 79#endif
78 80
79/* GET_NUMBER_OF_CPUS is a macro to return 81/* GET_NUMBER_OF_CPUS is a macro to return
80 number of CPUs, if we can get that data. 82 number of CPUs, if we can get that data.
81 Use configure.in to test for various OS ways of 83 Use configure.in to test for various OS ways of
82 getting that data 84 getting that data
83 Will return -1 if cannot get data 85 Will return -1 if cannot get data
84*/ 86*/
85#if defined(HAVE_SYSCONF__SC_NPROCESSORS_ONLN) 87#if defined(HAVE_SYSCONF__SC_NPROCESSORS_ONLN)
86# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_ONLN) 88# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_ONLN)
87#elif defined (HAVE_SYSCONF__SC_NPROCESSORS_CONF) 89#elif defined(HAVE_SYSCONF__SC_NPROCESSORS_CONF)
88# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF) 90# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF)
89#else 91#else
90# define GET_NUMBER_OF_CPUS() -1 92# define GET_NUMBER_OF_CPUS() -1
91#endif 93#endif
92 94
93#ifdef TIME_WITH_SYS_TIME 95#ifdef HAVE_SYS_TIME_H
94# include <sys/time.h> 96# include <sys/time.h>
95# include <time.h>
96#else
97# ifdef HAVE_SYS_TIME_H
98# include <sys/time.h>
99# else
100# include <time.h>
101# endif
102#endif 97#endif
98#include <time.h>
103 99
104#ifdef HAVE_SYS_TYPES_H 100#ifdef HAVE_SYS_TYPES_H
105#include <sys/types.h> 101# include <sys/types.h>
106#endif 102#endif
107 103
108#ifdef HAVE_SYS_SOCKET_H 104#ifdef HAVE_SYS_SOCKET_H
109#include <sys/socket.h> 105# include <sys/socket.h>
110#endif 106#endif
111 107
112#ifdef HAVE_SIGNAL_H 108#ifdef HAVE_SIGNAL_H
113#include <signal.h> 109# include <signal.h>
114#endif 110#endif
115 111
116/* GNU Libraries */ 112/* GNU Libraries */
117#include <getopt.h> 113#include <getopt.h>
118#include "dirname.h" 114#include "../gl/dirname.h"
119 115
120#include <locale.h> 116#include <locale.h>
121 117
122#ifdef HAVE_SYS_POLL_H 118#ifdef HAVE_SYS_POLL_H
123# include "sys/poll.h" 119# include "sys/poll.h"
124#endif 120#endif
125 121
126/* 122/*
@@ -130,42 +126,42 @@
130 */ 126 */
131 127
132#ifndef HAVE_STRTOL 128#ifndef HAVE_STRTOL
133# define strtol(a,b,c) atol((a)) 129# define strtol(a, b, c) atol((a))
134#endif 130#endif
135 131
136#ifndef HAVE_STRTOUL 132#ifndef HAVE_STRTOUL
137# define strtoul(a,b,c) (unsigned long)atol((a)) 133# define strtoul(a, b, c) (unsigned long)atol((a))
138#endif 134#endif
139 135
140/* SSL implementations */ 136/* SSL implementations */
141#ifdef HAVE_GNUTLS_OPENSSL_H 137#ifdef HAVE_GNUTLS_OPENSSL_H
142# include <gnutls/openssl.h> 138# include <gnutls/openssl.h>
143#else 139#else
144# define OPENSSL_LOAD_CONF /* See the OPENSSL_config(3) man page. */ 140# define OPENSSL_LOAD_CONF /* See the OPENSSL_config(3) man page. */
145# ifdef HAVE_SSL_H 141# ifdef HAVE_SSL_H
146# include <rsa.h> 142# include <rsa.h>
147# include <crypto.h> 143# include <crypto.h>
148# include <x509.h> 144# include <x509.h>
149# include <pem.h> 145# include <pem.h>
150# include <ssl.h> 146# include <ssl.h>
151# include <err.h> 147# include <err.h>
152# else 148# else
153# ifdef HAVE_OPENSSL_SSL_H 149# ifdef HAVE_OPENSSL_SSL_H
154# include <openssl/rsa.h> 150# include <openssl/rsa.h>
155# include <openssl/crypto.h> 151# include <openssl/crypto.h>
156# include <openssl/x509.h> 152# include <openssl/x509.h>
157# include <openssl/pem.h> 153# include <openssl/pem.h>
158# include <openssl/ssl.h> 154# include <openssl/ssl.h>
159# include <openssl/err.h> 155# include <openssl/err.h>
160# endif 156# endif
161# endif 157# endif
162#endif 158#endif
163 159
164/* openssl 1.1 does not set OPENSSL_NO_SSL2 by default but ships without ssl2 */ 160/* openssl 1.1 does not set OPENSSL_NO_SSL2 by default but ships without ssl2 */
165#ifdef OPENSSL_VERSION_NUMBER 161#ifdef OPENSSL_VERSION_NUMBER
166# if OPENSSL_VERSION_NUMBER >= 0x10100000 162# if OPENSSL_VERSION_NUMBER >= 0x10100000
167# define OPENSSL_NO_SSL2 163# define OPENSSL_NO_SSL2
168# endif 164# endif
169#endif 165#endif
170 166
171/* 167/*
@@ -176,7 +172,7 @@
176 172
177/* MariaDB 10.2 client does not set MYSQL_PORT */ 173/* MariaDB 10.2 client does not set MYSQL_PORT */
178#ifndef MYSQL_PORT 174#ifndef MYSQL_PORT
179# define MYSQL_PORT 3306 175# define MYSQL_PORT 3306
180#endif 176#endif
181 177
182enum { 178enum {
@@ -185,17 +181,9 @@ enum {
185}; 181};
186 182
187enum { 183enum {
188 STATE_OK, 184 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
189 STATE_WARNING, 185 MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */
190 STATE_CRITICAL, 186 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
191 STATE_UNKNOWN,
192 STATE_DEPENDENT
193};
194
195enum {
196 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
197 MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */
198 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
199}; 187};
200 188
201/* 189/*
@@ -203,18 +191,18 @@ enum {
203 * Internationalization 191 * Internationalization
204 * 192 *
205 */ 193 */
206#include "gettext.h" 194#include "../gl/gettext.h"
207#define _(String) gettext (String) 195#define _(String) gettext(String)
208#if ! ENABLE_NLS 196#if !ENABLE_NLS
209# undef textdomain 197# undef textdomain
210# define textdomain(Domainname) /* empty */ 198# define textdomain(Domainname) /* empty */
211# undef bindtextdomain 199# undef bindtextdomain
212# define bindtextdomain(Domainname, Dirname) /* empty */ 200# define bindtextdomain(Domainname, Dirname) /* empty */
213#endif 201#endif
214 202
215/* For non-GNU compilers to ignore __attribute__ */ 203/* For non-GNU compilers to ignore __attribute__ */
216#ifndef __GNUC__ 204#ifndef __GNUC__
217# define __attribute__(x) /* do nothing */ 205# define __attribute__(x) /* do nothing */
218#endif 206#endif
219 207
220#endif /* _COMMON_H_ */ 208#endif /* _COMMON_H_ */