summaryrefslogtreecommitdiffstats
path: root/plugins/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/common.h')
-rw-r--r--plugins/common.h181
1 files changed, 91 insertions, 90 deletions
diff --git a/plugins/common.h b/plugins/common.h
index 603bae55..ef888d08 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -1,121 +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#include "../lib/monitoringplug.h"
36 36
37#ifdef HAVE_FEATURES_H 37#ifdef HAVE_FEATURES_H
38#include <features.h> 38# include <features.h>
39#endif 39#endif
40 40
41#include <stdio.h> /* obligatory includes */ 41#include <stdio.h> /* obligatory includes */
42#include <stdlib.h> 42#include <stdlib.h>
43#include <errno.h> 43#include <errno.h>
44 44
45/* 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 */
46#if HAVE_INTTYPES_H 47#if HAVE_INTTYPES_H
47# include <inttypes.h> 48# include <inttypes.h>
48#endif 49#endif
49#if HAVE_STDINT_H 50#if HAVE_STDINT_H
50# include <stdint.h> 51# include <stdint.h>
51#endif 52#endif
52#include <unistd.h> 53#include <unistd.h>
53#ifndef UINTMAX_MAX 54#ifndef UINTMAX_MAX
54# define UINTMAX_MAX ((uintmax_t) -1) 55# define UINTMAX_MAX ((uintmax_t) - 1)
55#endif 56#endif
56 57
57#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 */
58 59
59#ifdef HAVE_MATH_H 60#ifdef HAVE_MATH_H
60#include <math.h> 61# include <math.h>
61#endif 62#endif
62 63
63#ifdef _AIX 64#ifdef _AIX
64#ifdef HAVE_MP_H 65# ifdef HAVE_MP_H
65#include <mp.h> 66# include <mp.h>
66#endif 67# endif
67#endif 68#endif
68 69
69#ifdef HAVE_STRINGS_H 70#ifdef HAVE_STRINGS_H
70#include <strings.h> 71# include <strings.h>
71#endif 72#endif
72#ifdef HAVE_STRING_H 73#ifdef HAVE_STRING_H
73#include <string.h> 74# include <string.h>
74#endif 75#endif
75 76
76#ifdef HAVE_UNISTD_H 77#ifdef HAVE_UNISTD_H
77#include <unistd.h> 78# include <unistd.h>
78#endif 79#endif
79 80
80/* GET_NUMBER_OF_CPUS is a macro to return 81/* GET_NUMBER_OF_CPUS is a macro to return
81 number of CPUs, if we can get that data. 82 number of CPUs, if we can get that data.
82 Use configure.in to test for various OS ways of 83 Use configure.in to test for various OS ways of
83 getting that data 84 getting that data
84 Will return -1 if cannot get data 85 Will return -1 if cannot get data
85*/ 86*/
86#if defined(HAVE_SYSCONF__SC_NPROCESSORS_ONLN) 87#if defined(HAVE_SYSCONF__SC_NPROCESSORS_ONLN)
87# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_ONLN) 88# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_ONLN)
88#elif defined (HAVE_SYSCONF__SC_NPROCESSORS_CONF) 89#elif defined(HAVE_SYSCONF__SC_NPROCESSORS_CONF)
89# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF) 90# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF)
90#else 91#else
91# define GET_NUMBER_OF_CPUS() -1 92# define GET_NUMBER_OF_CPUS() -1
92#endif 93#endif
93 94
94#ifdef HAVE_SYS_TIME_H 95#ifdef HAVE_SYS_TIME_H
95# include <sys/time.h> 96# include <sys/time.h>
96#endif 97#endif
97#include <time.h> 98#include <time.h>
98 99
99#ifdef HAVE_SYS_TYPES_H 100#ifdef HAVE_SYS_TYPES_H
100#include <sys/types.h> 101# include <sys/types.h>
101#endif 102#endif
102 103
103#ifdef HAVE_SYS_SOCKET_H 104#ifdef HAVE_SYS_SOCKET_H
104#include <sys/socket.h> 105# include <sys/socket.h>
105#endif 106#endif
106 107
107#ifdef HAVE_SIGNAL_H 108#ifdef HAVE_SIGNAL_H
108#include <signal.h> 109# include <signal.h>
109#endif 110#endif
110 111
111/* GNU Libraries */ 112/* GNU Libraries */
112#include <getopt.h> 113#include <getopt.h>
113#include "dirname.h" 114#include "../gl/dirname.h"
114 115
115#include <locale.h> 116#include <locale.h>
116 117
117#ifdef HAVE_SYS_POLL_H 118#ifdef HAVE_SYS_POLL_H
118# include "sys/poll.h" 119# include "sys/poll.h"
119#endif 120#endif
120 121
121/* 122/*
@@ -125,42 +126,42 @@
125 */ 126 */
126 127
127#ifndef HAVE_STRTOL 128#ifndef HAVE_STRTOL
128# define strtol(a,b,c) atol((a)) 129# define strtol(a, b, c) atol((a))
129#endif 130#endif
130 131
131#ifndef HAVE_STRTOUL 132#ifndef HAVE_STRTOUL
132# define strtoul(a,b,c) (unsigned long)atol((a)) 133# define strtoul(a, b, c) (unsigned long)atol((a))
133#endif 134#endif
134 135
135/* SSL implementations */ 136/* SSL implementations */
136#ifdef HAVE_GNUTLS_OPENSSL_H 137#ifdef HAVE_GNUTLS_OPENSSL_H
137# include <gnutls/openssl.h> 138# include <gnutls/openssl.h>
138#else 139#else
139# define OPENSSL_LOAD_CONF /* See the OPENSSL_config(3) man page. */ 140# define OPENSSL_LOAD_CONF /* See the OPENSSL_config(3) man page. */
140# ifdef HAVE_SSL_H 141# ifdef HAVE_SSL_H
141# include <rsa.h> 142# include <rsa.h>
142# include <crypto.h> 143# include <crypto.h>
143# include <x509.h> 144# include <x509.h>
144# include <pem.h> 145# include <pem.h>
145# include <ssl.h> 146# include <ssl.h>
146# include <err.h> 147# include <err.h>
147# else 148# else
148# ifdef HAVE_OPENSSL_SSL_H 149# ifdef HAVE_OPENSSL_SSL_H
149# include <openssl/rsa.h> 150# include <openssl/rsa.h>
150# include <openssl/crypto.h> 151# include <openssl/crypto.h>
151# include <openssl/x509.h> 152# include <openssl/x509.h>
152# include <openssl/pem.h> 153# include <openssl/pem.h>
153# include <openssl/ssl.h> 154# include <openssl/ssl.h>
154# include <openssl/err.h> 155# include <openssl/err.h>
155# endif 156# endif
156# endif 157# endif
157#endif 158#endif
158 159
159/* 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 */
160#ifdef OPENSSL_VERSION_NUMBER 161#ifdef OPENSSL_VERSION_NUMBER
161# if OPENSSL_VERSION_NUMBER >= 0x10100000 162# if OPENSSL_VERSION_NUMBER >= 0x10100000
162# define OPENSSL_NO_SSL2 163# define OPENSSL_NO_SSL2
163# endif 164# endif
164#endif 165#endif
165 166
166/* 167/*
@@ -171,7 +172,7 @@
171 172
172/* MariaDB 10.2 client does not set MYSQL_PORT */ 173/* MariaDB 10.2 client does not set MYSQL_PORT */
173#ifndef MYSQL_PORT 174#ifndef MYSQL_PORT
174# define MYSQL_PORT 3306 175# define MYSQL_PORT 3306
175#endif 176#endif
176 177
177enum { 178enum {
@@ -180,9 +181,9 @@ enum {
180}; 181};
181 182
182enum { 183enum {
183 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */ 184 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
184 MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */ 185 MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */
185 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */ 186 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
186}; 187};
187 188
188/* 189/*
@@ -190,18 +191,18 @@ enum {
190 * Internationalization 191 * Internationalization
191 * 192 *
192 */ 193 */
193#include "gettext.h" 194#include "../gl/gettext.h"
194#define _(String) gettext (String) 195#define _(String) gettext(String)
195#if ! ENABLE_NLS 196#if !ENABLE_NLS
196# undef textdomain 197# undef textdomain
197# define textdomain(Domainname) /* empty */ 198# define textdomain(Domainname) /* empty */
198# undef bindtextdomain 199# undef bindtextdomain
199# define bindtextdomain(Domainname, Dirname) /* empty */ 200# define bindtextdomain(Domainname, Dirname) /* empty */
200#endif 201#endif
201 202
202/* For non-GNU compilers to ignore __attribute__ */ 203/* For non-GNU compilers to ignore __attribute__ */
203#ifndef __GNUC__ 204#ifndef __GNUC__
204# define __attribute__(x) /* do nothing */ 205# define __attribute__(x) /* do nothing */
205#endif 206#endif
206 207
207#endif /* _COMMON_H_ */ 208#endif /* _COMMON_H_ */