Reverted check_procs for solaris back to using pst3 due to truncation
[monitoring-plugins.git] / plugins / common.h
blob39a28a9d08f79f9d66cb10d2c97c4d87f9c8e3eb
1 /*****************************************************************************
2 *
3 * Nagios plugins common include file
4 *
5 * License: GPL
6 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
7 * Copyright (c) 2003-2007 Nagios Plugins Development Team
8 *
9 * Last Modified: $Date$
11 * Description:
13 * This file contains common include files and defines used in many of
14 * the plugins.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 * $Id$
32 *****************************************************************************/
34 #ifndef _COMMON_H_
35 #define _COMMON_H_
37 #include "config.h"
38 /* This needs to be removed for Solaris servers, where 64 bit files, but 32 bit architecture
39 This needs to be done early on because subsequent system includes use _FILE_OFFSET_BITS
40 Cannot remove from config.h because is included by regex.c from lib/ */
41 #if __sun__ && !defined(_LP64) && _FILE_OFFSET_BITS == 64
42 #undef _FILE_OFFSET_BITS
43 #endif
45 #ifdef HAVE_FEATURES_H
46 #include <features.h>
47 #endif
49 #include <stdio.h> /* obligatory includes */
50 #include <stdlib.h>
51 #include <errno.h>
53 /* This block provides uintmax_t - should be reported to coreutils that this should be added to fsuage.h */
54 #if HAVE_INTTYPES_H
55 # include <inttypes.h>
56 #endif
57 #if HAVE_STDINT_H
58 # include <stdint.h>
59 #endif
60 #include <unistd.h>
61 #ifndef UINTMAX_MAX
62 # define UINTMAX_MAX ((uintmax_t) -1)
63 #endif
65 #include <limits.h> /* This is assumed true, because coreutils assume it too */
67 #ifdef HAVE_MATH_H
68 #include <math.h>
69 #endif
71 #ifdef HAVE_STRINGS_H
72 #include <strings.h>
73 #endif
74 #ifdef HAVE_STRING_H
75 #include <string.h>
76 #endif
78 #ifdef HAVE_UNISTD_H
79 #include <unistd.h>
80 #endif
82 /* GET_NUMBER_OF_CPUS is a macro to return
83 number of CPUs, if we can get that data.
84 Use configure.in to test for various OS ways of
85 getting that data
86 Will return -1 if cannot get data
88 #ifdef HAVE_SYSCONF__SC_NPROCESSORS_CONF
89 #define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF)
90 #else
91 #define GET_NUMBER_OF_CPUS() -1
92 #endif
94 #ifdef TIME_WITH_SYS_TIME
95 # include <sys/time.h>
96 # include <time.h>
97 #else
98 # ifdef HAVE_SYS_TIME_H
99 # include <sys/time.h>
100 # else
101 # include <time.h>
102 # endif
103 #endif
105 #ifdef HAVE_SYS_TYPES_H
106 #include <sys/types.h>
107 #endif
109 #ifdef HAVE_SYS_SOCKET_H
110 #include <sys/socket.h>
111 #endif
113 #ifdef HAVE_SIGNAL_H
114 #include <signal.h>
115 #endif
117 /* GNU Libraries */
118 #include <getopt.h>
119 #include "dirname.h"
121 #ifdef HAVE_LOCALE_H
122 #include <locale.h>
123 #endif
125 #ifdef HAVE_SYS_POLL_H
126 # include "sys/poll.h"
127 #endif
131 * Missing Functions
135 #ifndef HAVE_STRTOL
136 # define strtol(a,b,c) atol((a))
137 #endif
139 #ifndef HAVE_STRTOUL
140 # define strtoul(a,b,c) (unsigned long)atol((a))
141 #endif
143 /* SSL implementations */
144 #ifdef HAVE_GNUTLS_OPENSSL_H
145 # include <gnutls/openssl.h>
146 #else
147 # ifdef HAVE_SSL_H
148 # include <rsa.h>
149 # include <crypto.h>
150 # include <x509.h>
151 # include <pem.h>
152 # include <ssl.h>
153 # include <err.h>
154 # else
155 # ifdef HAVE_OPENSSL_SSL_H
156 # include <openssl/rsa.h>
157 # include <openssl/crypto.h>
158 # include <openssl/x509.h>
159 # include <openssl/pem.h>
160 # include <openssl/ssl.h>
161 # include <openssl/err.h>
162 # endif
163 # endif
164 #endif
168 * Standard Values
172 enum {
173 OK = 0,
174 ERROR = -1
177 /* AIX seems to have this defined somewhere else */
178 #ifndef FALSE
179 enum {
180 FALSE,
181 TRUE
183 #endif
185 enum {
186 STATE_OK,
187 STATE_WARNING,
188 STATE_CRITICAL,
189 STATE_UNKNOWN,
190 STATE_DEPENDENT
193 enum {
194 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
195 MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */
196 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
201 * Internationalization
204 #include "gettext.h"
205 #define _(String) gettext (String)
206 #if ! ENABLE_NLS
207 # undef textdomain
208 # define textdomain(Domainname) /* empty */
209 # undef bindtextdomain
210 # define bindtextdomain(Domainname, Dirname) /* empty */
211 #endif
213 /* For non-GNU compilers to ignore __attribute__ */
214 #ifndef __GNUC__
215 # define __attribute__(x) /* do nothing */
216 #endif
218 #endif /* _COMMON_H_ */