summaryrefslogtreecommitdiffstats
path: root/plugins/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/common.h')
-rw-r--r--plugins/common.h190
1 files changed, 92 insertions, 98 deletions
diff --git a/plugins/common.h b/plugins/common.h
index b7a7d59b..ef888d08 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -1,120 +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 HAVE_SYS_TIME_H 95#ifdef HAVE_SYS_TIME_H
94# include <sys/time.h> 96# include <sys/time.h>
95#endif 97#endif
96#include <time.h> 98#include <time.h>
97 99
98#ifdef HAVE_SYS_TYPES_H 100#ifdef HAVE_SYS_TYPES_H
99#include <sys/types.h> 101# include <sys/types.h>
100#endif 102#endif
101 103
102#ifdef HAVE_SYS_SOCKET_H 104#ifdef HAVE_SYS_SOCKET_H
103#include <sys/socket.h> 105# include <sys/socket.h>
104#endif 106#endif
105 107
106#ifdef HAVE_SIGNAL_H 108#ifdef HAVE_SIGNAL_H
107#include <signal.h> 109# include <signal.h>
108#endif 110#endif
109 111
110/* GNU Libraries */ 112/* GNU Libraries */
111#include <getopt.h> 113#include <getopt.h>
112#include "dirname.h" 114#include "../gl/dirname.h"
113 115
114#include <locale.h> 116#include <locale.h>
115 117
116#ifdef HAVE_SYS_POLL_H 118#ifdef HAVE_SYS_POLL_H
117# include "sys/poll.h" 119# include "sys/poll.h"
118#endif 120#endif
119 121
120/* 122/*
@@ -124,42 +126,42 @@
124 */ 126 */
125 127
126#ifndef HAVE_STRTOL 128#ifndef HAVE_STRTOL
127# define strtol(a,b,c) atol((a)) 129# define strtol(a, b, c) atol((a))
128#endif 130#endif
129 131
130#ifndef HAVE_STRTOUL 132#ifndef HAVE_STRTOUL
131# define strtoul(a,b,c) (unsigned long)atol((a)) 133# define strtoul(a, b, c) (unsigned long)atol((a))
132#endif 134#endif
133 135
134/* SSL implementations */ 136/* SSL implementations */
135#ifdef HAVE_GNUTLS_OPENSSL_H 137#ifdef HAVE_GNUTLS_OPENSSL_H
136# include <gnutls/openssl.h> 138# include <gnutls/openssl.h>
137#else 139#else
138# define OPENSSL_LOAD_CONF /* See the OPENSSL_config(3) man page. */ 140# define OPENSSL_LOAD_CONF /* See the OPENSSL_config(3) man page. */
139# ifdef HAVE_SSL_H 141# ifdef HAVE_SSL_H
140# include <rsa.h> 142# include <rsa.h>
141# include <crypto.h> 143# include <crypto.h>
142# include <x509.h> 144# include <x509.h>
143# include <pem.h> 145# include <pem.h>
144# include <ssl.h> 146# include <ssl.h>
145# include <err.h> 147# include <err.h>
146# else 148# else
147# ifdef HAVE_OPENSSL_SSL_H 149# ifdef HAVE_OPENSSL_SSL_H
148# include <openssl/rsa.h> 150# include <openssl/rsa.h>
149# include <openssl/crypto.h> 151# include <openssl/crypto.h>
150# include <openssl/x509.h> 152# include <openssl/x509.h>
151# include <openssl/pem.h> 153# include <openssl/pem.h>
152# include <openssl/ssl.h> 154# include <openssl/ssl.h>
153# include <openssl/err.h> 155# include <openssl/err.h>
154# endif 156# endif
155# endif 157# endif
156#endif 158#endif
157 159
158/* 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 */
159#ifdef OPENSSL_VERSION_NUMBER 161#ifdef OPENSSL_VERSION_NUMBER
160# if OPENSSL_VERSION_NUMBER >= 0x10100000 162# if OPENSSL_VERSION_NUMBER >= 0x10100000
161# define OPENSSL_NO_SSL2 163# define OPENSSL_NO_SSL2
162# endif 164# endif
163#endif 165#endif
164 166
165/* 167/*
@@ -170,7 +172,7 @@
170 172
171/* MariaDB 10.2 client does not set MYSQL_PORT */ 173/* MariaDB 10.2 client does not set MYSQL_PORT */
172#ifndef MYSQL_PORT 174#ifndef MYSQL_PORT
173# define MYSQL_PORT 3306 175# define MYSQL_PORT 3306
174#endif 176#endif
175 177
176enum { 178enum {
@@ -179,17 +181,9 @@ enum {
179}; 181};
180 182
181enum { 183enum {
182 STATE_OK, 184 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
183 STATE_WARNING, 185 MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */
184 STATE_CRITICAL, 186 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
185 STATE_UNKNOWN,
186 STATE_DEPENDENT
187};
188
189enum {
190 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
191 MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */
192 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
193}; 187};
194 188
195/* 189/*
@@ -197,18 +191,18 @@ enum {
197 * Internationalization 191 * Internationalization
198 * 192 *
199 */ 193 */
200#include "gettext.h" 194#include "../gl/gettext.h"
201#define _(String) gettext (String) 195#define _(String) gettext(String)
202#if ! ENABLE_NLS 196#if !ENABLE_NLS
203# undef textdomain 197# undef textdomain
204# define textdomain(Domainname) /* empty */ 198# define textdomain(Domainname) /* empty */
205# undef bindtextdomain 199# undef bindtextdomain
206# define bindtextdomain(Domainname, Dirname) /* empty */ 200# define bindtextdomain(Domainname, Dirname) /* empty */
207#endif 201#endif
208 202
209/* For non-GNU compilers to ignore __attribute__ */ 203/* For non-GNU compilers to ignore __attribute__ */
210#ifndef __GNUC__ 204#ifndef __GNUC__
211# define __attribute__(x) /* do nothing */ 205# define __attribute__(x) /* do nothing */
212#endif 206#endif
213 207
214#endif /* _COMMON_H_ */ 208#endif /* _COMMON_H_ */