forked from tiwilliam/istatd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
368 lines (329 loc) · 9.66 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
AC_INIT([istatd], [0.5.9], [http://github.com/tiwilliam/istatd/issues])
AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE
AC_CANONICAL_HOST
AC_PROG_RANLIB
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AC_CHECK_TOOL(AR, ar, false)
AC_MSG_CHECKING([if the compiler supports -Wall])
oldcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -Wall"
AC_COMPILE_IFELSE([int main(void) { return 0; }],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
CPPFLAGS="$oldcppflags"
])
AC_MSG_CHECKING([if the linker supports -rdynamic])
oldldflags="$LDFLAGS"
LDFLAGS="$LDFLAGS -rdynamic"
AC_LINK_IFELSE([int main(void) { return 0; }],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
LDFLAGS="$oldldflags"
])
# Checks for libraries.
# AC_CHECK_LIB([dl], [dlopen],,[
# AC_CHECK_FUNC([dlopen],,[
# AC_MSG_ERROR([cannot find a suitable dlopen() implementation])
# ])
# ])
AC_CHECK_LIB([nsl],[inet_ntoa])
AC_CHECK_LIB([socket],[socket])
qnaptemp=yes
AC_ARG_WITH(qnaptemp,
[ --with-qnaptemp read temperature from procfs on qnap NAS products],
AC_DEFINE_UNQUOTED([HAVE_QNAPTEMP],1,[Define if compiling for a qnap NAS]),
qnaptemp=no)
if test $qnaptemp = no; then
AC_CHECK_LIB([sensors],[sensors_init],[
AC_DEFINE_UNQUOTED([HAVE_LIBSENSORS],1,[Define if libsensors is available])
LIBS="$LIBS -lsensors"
])
fi
AC_CHECK_PROG([XML2_CONFIG],[xml2-config],[xml2-config])
if test x"$XML2_CONFIG" = x"" ; then
AC_MSG_ERROR([cannot find xml2-config: depending on your operating system you may need to install a '-dev' package for libxml2])
fi
LIBS="$LIBS `$XML2_CONFIG --libs`"
CPPFLAGS="$CPPFLAGS `$XML2_CONFIG --cflags`"
AC_CHECK_HEADER([libxml/parser.h],,[
AC_MSG_ERROR([xml2-config was located, but the header files could not be found])
])
AC_CHECK_FUNC([xmlFileOpen],[
AC_DEFINE_UNQUOTED([HAVE_LIBXML2],[1],[Define to 1 if you have the 'xml2' library (-lxml2).])
],[
AC_MSG_ERROR([xml2-config was located, but a test program linking against -lxml2 could not be built])
])
case "${host_os}" in
linux|linux-*)
have_procfs=procfs
;;
*)
have_procfs=none
;;
esac
dnl Fall back to procfs, if available
use_cpu=$have_procfs
use_net=$have_procfs
use_uptime=$have_procfs
use_mem=$have_procfs
use_swap=$have_procfs
use_load=$have_procfs
use_disk=none
dnl Specific tests for probe types
AC_CHECK_LIB([kstat],[kstat_open],[
AC_DEFINE_UNQUOTED([HAVE_LIBKSTAT],1,[Define if libkstat is available])
have_kstat=yes
LIBS="$LIBS -lkstat"
use_cpu=kstat
use_net=kstat
use_uptime=kstat
use_mem=kstat
],[have_kstat=no])
if test x"$have_kstat" = x"no" ; then
AC_CHECK_LIB([kvm],[kvm_open],[
AC_DEFINE_UNQUOTED([HAVE_LIBKVM],1,[Define if libkvm is available])
LIBS="$LIBS -lkvm"
use_mem=kvm
use_swap=kvm
])
fi
AC_CHECK_LIB([perfstat],[perfstat_cpu_total],[
AC_DEFINE_UNQUOTED([HAVE_LIBPERFSTAT],1,[Define if libperfstat is available])
have_perfstat=yes
LIBS="$LIBS -lperfstat"
use_cpu=perfstat
use_net=perfstat
use_uptime=perfstat
use_mem=perfstat
use_load=perfstat
use_swap=perfstat
],[have_perfstat=no])
AC_CHECK_FUNC([getloadavg],[
use_load=getloadavg
])
AC_HEADER_TIME
AC_CHECK_FUNC([clock_gettime],[
AC_MSG_CHECKING([if CLOCK_UPTIME is available])
AC_COMPILE_IFELSE([
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
static clockid_t testuptime = CLOCK_UPTIME;
],[have_clock_uptime=yes ; use_uptime=gettime],[have_clock_uptime=no])
AC_MSG_RESULT([$have_clock_uptime])
])
dnl Use sysctl for cpu and net if procfs isn't available
AC_CHECK_FUNC([sysctl],[
AC_DEFINE_UNQUOTED([HAVE_SYSCTL],1,[Define if sysctl is available])
test x"$use_cpu" = x"none" && use_cpu=sysctl
test x"$use_net" = x"none" && use_net=sysctl
have_sysctl=yes
],[have_sysctl=no])
dnl Try to use sysctl on freebsd if there's no CLOCK_UPTIME
if test x"$use_uptime" = x"none" ; then
case "$host_os" in
freebsd*)
if test x"$have_sysctl" = x"yes" ; then
use_uptime=sysctl
fi
;;
esac
fi
dnl We only use swapctl if procfs isnt available
AC_CHECK_FUNC([swapctl],[
test x"$use_swap" = x"none" && use_swap=swapctl
])
AC_CHECK_FUNC([statvfs],[
use_disk=statvfs
],[
AC_CHECK_FUNC([statfs],[
use_disk=statfs
])
])
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h mntent.h netdb.h stdlib.h string.h paths.h sys/socket.h sys/statfs.h sys/statvfs.h sys/mnttab.h sys/loadavg.h kstat.h errno.h sys/sysinfo.h sys/processor.h sys/swap.h kvm.h alloca.h sys/resource.h netinet/in.h sys/sysctl.h sys/vmmeter.h sys/param.h sensors/sensors.h libperfstat.h])
# Mute warning in freebsd 6.0
AC_CHECK_HEADERS([sys/mount.h], [], [], [#include <sys/param.h>])
# check net/if.h seperately, as it requires other headers on atleast FreeBSD
AC_CHECK_HEADERS([net/if.h net/if_mib.h],[],[],
[[
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
]])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_GETMNTENT
AC_CHECK_FUNCS([gethostbyname getmntent getmntinfo inet_ntoa memset mkdir select socket strerror statvfs setmntent])
# Try to figure out which type of mntent structure we're dealing with
AC_CHECK_MEMBER([struct mnttab.mnt_special],[AC_DEFINE_UNQUOTED([USE_STRUCT_MNTTAB],[1],[define to use 'struct mnttab'])],,[
#include <stdio.h>
#include <sys/mnttab.h>
])
AC_CHECK_MEMBER([struct mntent.mnt_fsname],[AC_DEFINE_UNQUOTED([USE_STRUCT_MNTENT],[1],[define to use 'struct mntent'])],,[
#include <stdio.h>
#include <mntent.h>
])
AC_CHECK_MEMBER([struct statvfs.f_frsize],[AC_DEFINE_UNQUOTED([HAVE_STATVFS_FRSIZE],[1],[define if statvfs has the f_frsize member])],,[
#include <sys/types.h>
#include <sys/statvfs.h>
])
AC_MSG_CHECKING([for default location of configuration file])
test x"$prefix" = x"NONE" && prefix="$ac_default_prefix"
configpath=`eval echo "$sysconfdir"/istat.conf`
AC_MSG_RESULT([$configpath])
AC_DEFINE_UNQUOTED([CONFIG_FILE_PATH],["${configpath}"],[default location of the configuration file])
AC_MSG_CHECKING([CPU usage probe type])
case $use_cpu in
procfs)
AC_DEFINE_UNQUOTED([USE_CPU_PROCFS],1,[Use procfs to probe CPU usage])
;;
kstat)
AC_DEFINE_UNQUOTED([USE_CPU_KSTAT],1,[Use kstat(3) to probe CPU usage])
;;
perfstat)
AC_DEFINE_UNQUOTED([USE_CPU_PERFSTAT],1,[Use AIX perfstat to probe CPU usage])
;;
sysctl)
AC_DEFINE_UNQUOTED([USE_CPU_SYSCTL],1,[Use sysctl to probe CPU usage])
;;
*)
AC_MSG_ERROR([cannot determine CPU usage probe type for ${host_os}])
;;
esac
AC_MSG_RESULT($use_cpu)
AC_MSG_CHECKING([load average probe type])
case $use_load in
procfs)
AC_DEFINE_UNQUOTED([USE_LOAD_PROCFS],1,[Use procfs to probe load average])
;;
getloadavg)
AC_DEFINE_UNQUOTED([USE_LOAD_GETLOADAVG],1,[Use getloadavg(3) to probe load average])
;;
perfstat)
AC_DEFINE_UNQUOTED([USE_LOAD_PERFSTAT],1,[Use perfstat (AIX) to probe load average])
;;
*)
AC_MSG_ERROR([cannot determine load average probe type for ${host_os}])
;;
esac
AC_MSG_RESULT($use_load)
AC_MSG_CHECKING([memory usage probe type])
case $use_mem in
procfs)
AC_DEFINE_UNQUOTED([USE_MEM_PROCFS],1,[Use procfs to probe memory usage])
;;
kstat)
AC_DEFINE_UNQUOTED([USE_MEM_KSTAT],1,[Use kstat(3) to probe memory usage])
;;
perfstat)
AC_DEFINE_UNQUOTED([USE_MEM_PERFSTAT],1,[Use perfstat (AIX) to probe memory usage])
;;
kvm)
AC_DEFINE_UNQUOTED([USE_MEM_KVM],1,[Use kvm(3) to probe memory usage])
;;
*)
AC_MSG_ERROR([cannot determine memory usage probe type for ${host_os}])
;;
esac
AC_MSG_RESULT($use_mem)
AC_MSG_CHECKING([swap probe type])
case $use_swap in
procfs)
AC_DEFINE_UNQUOTED([USE_SWAP_PROCFS],1,[Use procfs to probe swap])
;;
swapctl)
AC_DEFINE_UNQUOTED([USE_SWAP_SWAPCTL],1,[Use swapctl(3) to probe swap])
;;
perfstat)
AC_DEFINE_UNQUOTED([USE_SWAP_PERFSTAT],1,[Use perfstat (AIX) to probe swap])
;;
kvm)
AC_DEFINE_UNQUOTED([USE_SWAP_KVM],1,[Use kvm(3) to probe swap])
;;
*)
AC_MSG_ERROR([cannot determine swap probe type for ${host_os}])
;;
esac
AC_MSG_RESULT($use_swap)
AC_MSG_CHECKING([uptime probe type])
case $use_uptime in
procfs)
AC_DEFINE_UNQUOTED([USE_UPTIME_PROCFS],1,[Use procfs to probe uptime])
;;
kstat)
AC_DEFINE_UNQUOTED([USE_UPTIME_KSTAT],1,[Use kstat(3) to probe uptime])
;;
perfstat)
AC_DEFINE_UNQUOTED([USE_UPTIME_PERFSTAT],1,[Use perfstat(3) to probe uptime])
;;
gettime)
AC_DEFINE_UNQUOTED([USE_UPTIME_GETTIME],1,[Use clock_gettime(2) to probe load uptime])
;;
sysctl)
AC_DEFINE_UNQUOTED([USE_UPTIME_SYSCTL],1,[Use sysctl(2) to probe uptime])
;;
*)
AC_MSG_ERROR([cannot determine uptime probe type for ${host_os}])
;;
esac
AC_MSG_RESULT($use_uptime)
AC_MSG_CHECKING([network activity probe type])
case $use_net in
procfs)
AC_DEFINE_UNQUOTED([USE_NET_PROCFS],1,[Use procfs to probe network activity])
;;
kstat)
AC_DEFINE_UNQUOTED([USE_NET_KSTAT],1,[Use kstat(3) to probe network activity])
;;
perfstat)
AC_DEFINE_UNQUOTED([USE_NET_PERFSTAT],1,[Use perfstat(3) to probe network activity])
;;
sysctl)
AC_DEFINE_UNQUOTED([USE_NET_SYSCTL],1,[Use sysctl to probe network activity])
;;
*)
AC_MSG_ERROR([cannot determine network activity probe type for ${host_os}])
;;
esac
AC_MSG_RESULT($use_net)
AC_MSG_CHECKING([disk space probe type])
case $use_disk in
statfs|statvfs)
AC_DEFINE_UNQUOTED([USE_DISK_STATFS],1,[Use statfs/statvfs(2) to probe disk space])
;;
*)
AC_MSG_ERROR([cannot determine disk usage probe type for ${host_os}])
;;
esac
AC_MSG_RESULT($use_disk)
AC_CONFIG_FILES([
Makefile
resource/Makefile
probes/Makefile
libfslabel/Makefile
])
AC_OUTPUT