build: migrate to autotools
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Alon Bar-Lev committed
Nov 15, 2015 at 18:40 UTC
6372ed837298a34f6d16e0cde929822879863195
56 files changed
+914
-309
.gitignore
+24
-4
@@ -1,7 +1,27 @@
1
-conf.d/*
2
-log/*
3
-cache/*
1
+.deps
2
+.libs
3
+
4
*.o
5
-*.old
5
+*.in
6
+*~
7
+
8
+Makefile
9
+aclocal.m4
10
+autom4te.cache
11
+compile
12
+config.guess
13
+config.h
14
+config.log
15
+config.status
16
+config.sub
17
+configure
18
+depcomp
19
+install-sh
20
+libtool
21
+ltmain.sh
22
+missing
23
+stamp-h1
24
+
25
netdata
26
apps.plugin
27
+netdata.spec
Makefile
deleted
-45
@@ -1,45 +0,0 @@
1
-ifndef BIN_DIR
2
-BIN_DIR = "$(PWD)"
3
-endif
4
-
5
-ifndef CONFIG_DIR
6
-CONFIG_DIR = "$(PWD)/conf.d"
7
-endif
8
-
9
-ifndef LOG_DIR
10
-LOG_DIR = "$(PWD)/log"
11
-endif
12
-
13
-ifndef PLUGINS_DIR
14
-PLUGINS_DIR = "$(PWD)/plugins.d"
15
-endif
16
-
17
-COMMON_FLAGS = BIN_DIR='$(BIN_DIR)' CONFIG_DIR='$(CONFIG_DIR)' LOG_DIR='$(LOG_DIR)' PLUGINS_DIR='$(PLUGINS_DIR)'
18
-
19
-ifdef debug
20
-COMMON_FLAGS += debug=1
21
-endif
22
-
23
-ifdef nozlib
24
-COMMON_FLAGS += nozlib=1
25
-endif
26
-
27
-all:
28
- $(MAKE) -C src $(COMMON_FLAGS) all
29
-
30
-clean:
31
- $(MAKE) -C src clean
32
- -rm -f netdata netdata.old plugins.d/apps.plugin plugins.d/apps.plugin.old
33
-
34
-install:
35
- $(MAKE) -C src $(COMMON_FLAGS) install
36
-
37
-getconf:
38
- @wget -O conf.d/netdata.conf.new "http://localhost:19999/netdata.conf"; \
39
- if [ $$? -eq 0 -a -s conf.d/netdata.conf.new ]; \
40
- then \
41
- mv conf.d/netdata.conf conf.d/netdata.conf.old; \
42
- mv conf.d/netdata.conf.new conf.d/netdata.conf; \
43
- fi
44
-
45
-.PHONY: all clean install getconf
Makefile.am
new
+29
@@ -0,0 +1,29 @@
1
+#
2
+# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
3
+#
4
+AUTOMAKE_OPTIONS=foreign dist-bzip2 1.10
5
+ACLOCAL_AMFLAGS = -I m4
6
+
7
+MAINTAINERCLEANFILES= \
8
+ config.log config.status \
9
+ $(srcdir)/Makefile.in \
10
+ $(srcdir)/config.h.in $(srcdir)/config.h.in~ $(srcdir)/configure \
11
+ $(srcdir)/install-sh $(srcdir)/ltmain.sh $(srcdir)/missing \
12
+ $(srcdir)/compile $(srcdir)/depcomp $(srcdir)/aclocal.m4 \
13
+ $(srcdir)/config.guess $(srcdir)/config.sub \
14
+ $(srcdir)/m4/ltsugar.m4 $(srcdir)/m4/libtool.m4 \
15
+ $(srcdir)/m4/ltversion.m4 $(srcdir)/m4/lt~obsolete.m4 \
16
+ $(srcdir)/m4/ltoptions.m4 \
17
+ $(srcdir)/pkcs11-helper.spec $(srcdir)/config-w32-vc.h
18
+
19
+EXTRA_DIST = README.md
20
+
21
+SUBDIRS = \
22
+ charts.d \
23
+ conf.d \
24
+ plugins.d \
25
+ src \
26
+ web \
27
+ $(NULL)
28
+
29
+dist_noinst_DATA = netdata.spec
autogen.sh
new
+2
@@ -0,0 +1,2 @@
1
+#!/bin/sh
2
+autoreconf -ivf
charts.d/Makefile.am
new
+20
@@ -0,0 +1,20 @@
1
+#
2
+# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
3
+#
4
+MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
5
+
6
+dist_charts_SCRIPTS = \
7
+ airsearches.chart.sh \
8
+ cpu_apps.chart.sh \
9
+ cpufreq.chart.sh \
10
+ crsproxy.chart.sh \
11
+ example.chart.sh \
12
+ load_average.chart.sh \
13
+ mem_apps.chart.sh \
14
+ mysql.chart.sh \
15
+ nut.chart.sh \
16
+ opensips.chart.sh \
17
+ postfix.chart.sh \
18
+ sensors.chart.sh \
19
+ squid.chart.sh \
20
+ $(NULL)
conf.d/Makefile.am
new
+8
@@ -0,0 +1,8 @@
1
+#
2
+# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
3
+#
4
+MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
5
+
6
+dist_config_DATA = \
7
+ apps_groups.conf \
8
+ $(NULL)
configure.ac
new
+163
@@ -0,0 +1,163 @@
1
+#
2
+# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
3
+#
4
+AC_PREREQ(2.60)
5
+
6
+define([VERSION_MAJOR], [1])
7
+define([VERSION_MINOR], [0])
8
+define([VERSION_FIX], [0])
9
+define([VERSION_NUMBER], VERSION_MAJOR[.]VERSION_MINOR[.]VERSION_FIX)
10
+define([VERSION_SUFFIX], [_master])
11
+
12
+AC_INIT([netdata], VERSION_NUMBER[]VERSION_SUFFIX)
13
+PACKAGE_RPM_VERSION="VERSION_NUMBER"
14
+PACKAGE_RPM_RELEASE="0.0.$(echo VERSION_SUFFIX | sed 's/^_//')"
15
+AC_SUBST([PACKAGE_RPM_VERSION])
16
+AC_SUBST([PACKAGE_RPM_RELEASE])
17
+
18
+AC_CONFIG_AUX_DIR([.])
19
+AC_CONFIG_HEADERS([config.h])
20
+AC_CONFIG_MACRO_DIR([m4])
21
+AC_CONFIG_SRCDIR([src/main.c])
22
+AM_INIT_AUTOMAKE
23
+AC_CANONICAL_HOST
24
+AC_PROG_CC
25
+AC_PROG_INSTALL
26
+PKG_PROG_PKG_CONFIG
27
+AC_USE_SYSTEM_EXTENSIONS
28
+
29
+AC_ARG_ENABLE(
30
+ [daemon],
31
+ [AS_HELP_STRING([--disable-daemon], [disable daemon])],
32
+ ,
33
+ [enable_daemon="yes"]
34
+)
35
+AC_ARG_ENABLE(
36
+ [plugin-plugin-nfacct],
37
+ [AS_HELP_STRING([--enable-plugin-plugin-nfacct], [enable nfacct plugin, requires root])],
38
+ ,
39
+ [enable_plugin_plugin_nfacct="no"]
40
+)
41
+AC_ARG_ENABLE(
42
+ [pedantic],
43
+ [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings])],
44
+ ,
45
+ [enable_pedantic="no"]
46
+)
47
+AC_ARG_WITH(
48
+ [webdir],
49
+ [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
50
+ [webdir="${withval}"],
51
+ [webdir="\$(pkgdatadir)/web"]
52
+)
53
+AC_ARG_WITH(
54
+ [zlib],
55
+ [AS_HELP_STRING([--with-zlib], [build with zlib])],
56
+ ,
57
+ [with_zlib="yes"]
58
+)
59
+AC_ARG_WITH(
60
+ [math],
61
+ [AS_HELP_STRING([--with-math], [build with math])],
62
+ ,
63
+ [with_math="yes"]
64
+)
65
+AC_ARG_WITH(
66
+ [user],
67
+ [AS_HELP_STRING([--with-user], [use this user to drop privilege])],
68
+ ,
69
+ [with_user="nobody"]
70
+)
71
+
72
+ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
73
+LIBS="${PTHREAD_LIBS} ${LIBS}"
74
+CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
75
+CC="${PTHREAD_CC}"
76
+
77
+AC_TYPE_UINT8_T
78
+AC_TYPE_UINT16_T
79
+AC_TYPE_UINT32_T
80
+AC_C_INLINE
81
+
82
+PKG_CHECK_MODULES(
83
+ [NFACCT],
84
+ [libnetfilter_acct],
85
+)
86
+PKG_CHECK_MODULES(
87
+ [LIBMNL],
88
+ [libmnl],
89
+)
90
+PKG_CHECK_MODULES(
91
+ [ZLIB],
92
+ [zlib],
93
+)
94
+AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
95
+AC_ARG_VAR([MATH_LIBS], [linker flags for math])
96
+if test -z "${MATH_LIBS}"; then
97
+ AC_CHECK_LIB(
98
+ [m],
99
+ [sin],
100
+ [MATH_LIBS="-lm"]
101
+ )
102
+fi
103
+
104
+test "${enable_daemon}" = "yes" && AC_DEFINE([NETDATA_DAEMON], [1], [daemon settings])
105
+if test "${enable_plugin_plugin_nfacct}" = "yes"; then
106
+ test -z "${NFACCT_LIBS}" && AC_MSG_ERROR([netfilter_acct required but not found])
107
+ test -z "${LIBMNL_LIBS}" && AC_MSG_ERROR([libmnl required but not found])
108
+ AC_DEFINE([INTERNAL_PLUGIN_NFACCT], [1], [nfacct plugin settings])
109
+ OPTIONAL_NFACCT_CLFAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
110
+ OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
111
+fi
112
+if test "${with_zlib}" = "yes"; then
113
+ test -z "${ZLIB_LIBS}" && AC_MSG_ERROR([zlib required but not found])
114
+ AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib settings])
115
+ OPTIONAL_ZLIB_CLFAGS="${ZLIB_CFLAGS}"
116
+ OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
117
+fi
118
+if test "${with_math}" = "yes"; then
119
+ test -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
120
+ AC_DEFINE([STORAGE_WITH_MATH], [1], [math settings])
121
+ OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
122
+ OPTIONAL_MATH_LIBS="${MATH_LIBS}"
123
+fi
124
+
125
+if test "${GCC}" = "yes"; then
126
+ AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
127
+ AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
128
+else
129
+ AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
130
+ AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
131
+fi
132
+
133
+if test "${enable_pedantic}" = "yes"; then
134
+ enable_strict="yes"
135
+ CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
136
+fi
137
+
138
+AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
139
+
140
+AC_SUBST([cachedir], ["\$(localstatedir)/cache/netdata"])
141
+AC_SUBST([chartsdir], ["\$(libexecdir)/netdata/charts.d"])
142
+AC_SUBST([configdir], ["\$(sysconfdir)/netdata"])
143
+AC_SUBST([logdir], ["\$(localstatedir)/log/netdata"])
144
+AC_SUBST([pluginsdir], ["\$(libexecdir)/netdata/plugins.d"])
145
+AC_SUBST([webdir])
146
+
147
+AC_SUBST([OPTIONAL_MATH_CLFAGS])
148
+AC_SUBST([OPTIONAL_MATH_LIBS])
149
+AC_SUBST([OPTIONAL_NFACCT_CLFAGS])
150
+AC_SUBST([OPTIONAL_NFACCT_LIBS])
151
+AC_SUBST([OPTIONAL_ZLIB_CLFAGS])
152
+AC_SUBST([OPTIONAL_ZLIB_LIBS])
153
+
154
+AC_CONFIG_FILES([
155
+ Makefile
156
+ charts.d/Makefile
157
+ conf.d/Makefile
158
+ netdata.spec
159
+ plugins.d/Makefile
160
+ src/Makefile
161
+ web/Makefile
162
+])
163
+AC_OUTPUT
m4/ax_pthread.m4
new
+332
@@ -0,0 +1,332 @@
1
+# ===========================================================================
2
+# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
3
+# ===========================================================================
4
+#
5
+# SYNOPSIS
6
+#
7
+# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
8
+#
9
+# DESCRIPTION
10
+#
11
+# This macro figures out how to build C programs using POSIX threads. It
12
+# sets the PTHREAD_LIBS output variable to the threads library and linker
13
+# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
14
+# flags that are needed. (The user can also force certain compiler
15
+# flags/libs to be tested by setting these environment variables.)
16
+#
17
+# Also sets PTHREAD_CC to any special C compiler that is needed for
18
+# multi-threaded programs (defaults to the value of CC otherwise). (This
19
+# is necessary on AIX to use the special cc_r compiler alias.)
20
+#
21
+# NOTE: You are assumed to not only compile your program with these flags,
22
+# but also link it with them as well. e.g. you should link with
23
+# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
24
+#
25
+# If you are only building threads programs, you may wish to use these
26
+# variables in your default LIBS, CFLAGS, and CC:
27
+#
28
+# LIBS="$PTHREAD_LIBS $LIBS"
29
+# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
30
+# CC="$PTHREAD_CC"
31
+#
32
+# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
33
+# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
34
+# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
35
+#
36
+# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
37
+# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
38
+# PTHREAD_CFLAGS.
39
+#
40
+# ACTION-IF-FOUND is a list of shell commands to run if a threads library
41
+# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
42
+# is not found. If ACTION-IF-FOUND is not specified, the default action
43
+# will define HAVE_PTHREAD.
44
+#
45
+# Please let the authors know if this macro fails on any platform, or if
46
+# you have any other suggestions or comments. This macro was based on work
47
+# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
48
+# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
49
+# Alejandro Forero Cuervo to the autoconf macro repository. We are also
50
+# grateful for the helpful feedback of numerous users.
51
+#
52
+# Updated for Autoconf 2.68 by Daniel Richard G.
53
+#
54
+# LICENSE
55
+#
56
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
57
+# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
58
+#
59
+# This program is free software: you can redistribute it and/or modify it
60
+# under the terms of the GNU General Public License as published by the
61
+# Free Software Foundation, either version 3 of the License, or (at your
62
+# option) any later version.
63
+#
64
+# This program is distributed in the hope that it will be useful, but
65
+# WITHOUT ANY WARRANTY; without even the implied warranty of
66
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
67
+# Public License for more details.
68
+#
69
+# You should have received a copy of the GNU General Public License along
70
+# with this program. If not, see <http://www.gnu.org/licenses/>.
71
+#
72
+# As a special exception, the respective Autoconf Macro's copyright owner
73
+# gives unlimited permission to copy, distribute and modify the configure
74
+# scripts that are the output of Autoconf when processing the Macro. You
75
+# need not follow the terms of the GNU General Public License when using
76
+# or distributing such scripts, even though portions of the text of the
77
+# Macro appear in them. The GNU General Public License (GPL) does govern
78
+# all other use of the material that constitutes the Autoconf Macro.
79
+#
80
+# This special exception to the GPL applies to versions of the Autoconf
81
+# Macro released by the Autoconf Archive. When you make and distribute a
82
+# modified version of the Autoconf Macro, you may extend this special
83
+# exception to the GPL to apply to your modified version as well.
84
+
85
+#serial 21
86
+
87
+AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
88
+AC_DEFUN([AX_PTHREAD], [
89
+AC_REQUIRE([AC_CANONICAL_HOST])
90
+AC_LANG_PUSH([C])
91
+ax_pthread_ok=no
92
+
93
+# We used to check for pthread.h first, but this fails if pthread.h
94
+# requires special compiler flags (e.g. on True64 or Sequent).
95
+# It gets checked for in the link test anyway.
96
+
97
+# First of all, check if the user has set any of the PTHREAD_LIBS,
98
+# etcetera environment variables, and if threads linking works using
99
+# them:
100
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
101
+ save_CFLAGS="$CFLAGS"
102
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
103
+ save_LIBS="$LIBS"
104
+ LIBS="$PTHREAD_LIBS $LIBS"
105
+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
106
+ AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
107
+ AC_MSG_RESULT([$ax_pthread_ok])
108
+ if test x"$ax_pthread_ok" = xno; then
109
+ PTHREAD_LIBS=""
110
+ PTHREAD_CFLAGS=""
111
+ fi
112
+ LIBS="$save_LIBS"
113
+ CFLAGS="$save_CFLAGS"
114
+fi
115
+
116
+# We must check for the threads library under a number of different
117
+# names; the ordering is very important because some systems
118
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
119
+# libraries is broken (non-POSIX).
120
+
121
+# Create a list of thread flags to try. Items starting with a "-" are
122
+# C compiler flags, and other items are library names, except for "none"
123
+# which indicates that we try without any flags at all, and "pthread-config"
124
+# which is a program returning the flags for the Pth emulation library.
125
+
126
+ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
127
+
128
+# The ordering *is* (sometimes) important. Some notes on the
129
+# individual items follow:
130
+
131
+# pthreads: AIX (must check this before -lpthread)
132
+# none: in case threads are in libc; should be tried before -Kthread and
133
+# other compiler flags to prevent continual compiler warnings
134
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
135
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
136
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
137
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
138
+# -pthreads: Solaris/gcc
139
+# -mthreads: Mingw32/gcc, Lynx/gcc
140
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
141
+# doesn't hurt to check since this sometimes defines pthreads too;
142
+# also defines -D_REENTRANT)
143
+# ... -mt is also the pthreads flag for HP/aCC
144
+# pthread: Linux, etcetera
145
+# --thread-safe: KAI C++
146
+# pthread-config: use pthread-config program (for GNU Pth library)
147
+
148
+case ${host_os} in
149
+ solaris*)
150
+
151
+ # On Solaris (at least, for some versions), libc contains stubbed
152
+ # (non-functional) versions of the pthreads routines, so link-based
153
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
154
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
155
+ # a function called by this macro, so we could check for that, but
156
+ # who knows whether they'll stub that too in a future libc.) So,
157
+ # we'll just look for -pthreads and -lpthread first:
158
+
159
+ ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
160
+ ;;
161
+
162
+ darwin*)
163
+ ax_pthread_flags="-pthread $ax_pthread_flags"
164
+ ;;
165
+esac
166
+
167
+# Clang doesn't consider unrecognized options an error unless we specify
168
+# -Werror. We throw in some extra Clang-specific options to ensure that
169
+# this doesn't happen for GCC, which also accepts -Werror.
170
+
171
+AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
172
+save_CFLAGS="$CFLAGS"
173
+ax_pthread_extra_flags="-Werror"
174
+CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
175
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
176
+ [AC_MSG_RESULT([yes])],
177
+ [ax_pthread_extra_flags=
178
+ AC_MSG_RESULT([no])])
179
+CFLAGS="$save_CFLAGS"
180
+
181
+if test x"$ax_pthread_ok" = xno; then
182
+for flag in $ax_pthread_flags; do
183
+
184
+ case $flag in
185
+ none)
186
+ AC_MSG_CHECKING([whether pthreads work without any flags])
187
+ ;;
188
+
189
+ -*)
190
+ AC_MSG_CHECKING([whether pthreads work with $flag])
191
+ PTHREAD_CFLAGS="$flag"
192
+ ;;
193
+
194
+ pthread-config)
195
+ AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
196
+ if test x"$ax_pthread_config" = xno; then continue; fi
197
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
198
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
199
+ ;;
200
+
201
+ *)
202
+ AC_MSG_CHECKING([for the pthreads library -l$flag])
203
+ PTHREAD_LIBS="-l$flag"
204
+ ;;
205
+ esac
206
+
207
+ save_LIBS="$LIBS"
208
+ save_CFLAGS="$CFLAGS"
209
+ LIBS="$PTHREAD_LIBS $LIBS"
210
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
211
+
212
+ # Check for various functions. We must include pthread.h,
213
+ # since some functions may be macros. (On the Sequent, we
214
+ # need a special flag -Kthread to make this header compile.)
215
+ # We check for pthread_join because it is in -lpthread on IRIX
216
+ # while pthread_create is in libc. We check for pthread_attr_init
217
+ # due to DEC craziness with -lpthreads. We check for
218
+ # pthread_cleanup_push because it is one of the few pthread
219
+ # functions on Solaris that doesn't have a non-functional libc stub.
220
+ # We try pthread_create on general principles.
221
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
222
+ static void routine(void *a) { a = 0; }
223
+ static void *start_routine(void *a) { return a; }],
224
+ [pthread_t th; pthread_attr_t attr;
225
+ pthread_create(&th, 0, start_routine, 0);
226
+ pthread_join(th, 0);
227
+ pthread_attr_init(&attr);
228
+ pthread_cleanup_push(routine, 0);
229
+ pthread_cleanup_pop(0) /* ; */])],
230
+ [ax_pthread_ok=yes],
231
+ [])
232
+
233
+ LIBS="$save_LIBS"
234
+ CFLAGS="$save_CFLAGS"
235
+
236
+ AC_MSG_RESULT([$ax_pthread_ok])
237
+ if test "x$ax_pthread_ok" = xyes; then
238
+ break;
239
+ fi
240
+
241
+ PTHREAD_LIBS=""
242
+ PTHREAD_CFLAGS=""
243
+done
244
+fi
245
+
246
+# Various other checks:
247
+if test "x$ax_pthread_ok" = xyes; then
248
+ save_LIBS="$LIBS"
249
+ LIBS="$PTHREAD_LIBS $LIBS"
250
+ save_CFLAGS="$CFLAGS"
251
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
252
+
253
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
254
+ AC_MSG_CHECKING([for joinable pthread attribute])
255
+ attr_name=unknown
256
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
257
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
258
+ [int attr = $attr; return attr /* ; */])],
259
+ [attr_name=$attr; break],
260
+ [])
261
+ done
262
+ AC_MSG_RESULT([$attr_name])
263
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
264
+ AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
265
+ [Define to necessary symbol if this constant
266
+ uses a non-standard name on your system.])
267
+ fi
268
+
269
+ AC_MSG_CHECKING([if more special flags are required for pthreads])
270
+ flag=no
271
+ case ${host_os} in
272
+ aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
273
+ osf* | hpux*) flag="-D_REENTRANT";;
274
+ solaris*)
275
+ if test "$GCC" = "yes"; then
276
+ flag="-D_REENTRANT"
277
+ else
278
+ # TODO: What about Clang on Solaris?
279
+ flag="-mt -D_REENTRANT"
280
+ fi
281
+ ;;
282
+ esac
283
+ AC_MSG_RESULT([$flag])
284
+ if test "x$flag" != xno; then
285
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
286
+ fi
287
+
288
+ AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
289
+ [ax_cv_PTHREAD_PRIO_INHERIT], [
290
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
291
+ [[int i = PTHREAD_PRIO_INHERIT;]])],
292
+ [ax_cv_PTHREAD_PRIO_INHERIT=yes],
293
+ [ax_cv_PTHREAD_PRIO_INHERIT=no])
294
+ ])
295
+ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
296
+ [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
297
+
298
+ LIBS="$save_LIBS"
299
+ CFLAGS="$save_CFLAGS"
300
+
301
+ # More AIX lossage: compile with *_r variant
302
+ if test "x$GCC" != xyes; then
303
+ case $host_os in
304
+ aix*)
305
+ AS_CASE(["x/$CC"],
306
+ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
307
+ [#handle absolute path differently from PATH based program lookup
308
+ AS_CASE(["x$CC"],
309
+ [x/*],
310
+ [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
311
+ [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
312
+ ;;
313
+ esac
314
+ fi
315
+fi
316
+
317
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
318
+
319
+AC_SUBST([PTHREAD_LIBS])
320
+AC_SUBST([PTHREAD_CFLAGS])
321
+AC_SUBST([PTHREAD_CC])
322
+
323
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
324
+if test x"$ax_pthread_ok" = xyes; then
325
+ ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
326
+ :
327
+else
328
+ ax_pthread_ok=no
329
+ $2
330
+fi
331
+AC_LANG_POP
332
+])dnl AX_PTHREAD
netdata.spec.in
new
+58
@@ -0,0 +1,58 @@
1
+Summary: Linux real time system monitoring, over the web
2
+Name: @PACKAGE_NAME@
3
+Version: @PACKAGE_RPM_VERSION@
4
+Release: @PACKAGE_RPM_RELEASE@%{?release_suffix}%{?dist}
5
+License: GPLv2+
6
+URL: http://firehol.org
7
+Source: %{name}-@PACKAGE_VERSION@.tar.bz2
8
+
9
+BuildRequires: libmnl-devel
10
+BuildRequires: libnetfilter_acct-devel
11
+BuildRequires: zlib-devel
12
+Requires: libmnl
13
+Requires: libnetfilter_acct
14
+Requires: zlib
15
+
16
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
17
+
18
+%description
19
+Linux real time system monitoring, over the web!
20
+
21
+%pre
22
+getent group netdata > /dev/null || groupadd -r netdata
23
+getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
24
+
25
+%global ovirt_create_user_engine \
26
+%_ovirt_create_user %{engine_user} %{engine_uid} %{engine_group} %{engine_gid} "%{ovirt_user_description}" %{engine_state}
27
+
28
+
29
+%prep
30
+%setup -q -n %{name}-@PACKAGE_VERSION@
31
+
32
+%build
33
+%configure \
34
+ --docdir="%{_docdir}/%{name}-%{version}" \
35
+ --enable-plugin-plugin-nfacct \
36
+ --with-zlib \
37
+ --with-math \
38
+ --with-user=netdata \
39
+ %{?conf}
40
+make %{?_smp_mflags}
41
+
42
+%install
43
+rm -rf "%{buildroot}"
44
+make %{?_smp_mflags} install DESTDIR="%{buildroot}"
45
+find "%{buildroot}" -name .keep -exec rm {} \;
46
+
47
+%files
48
+%attr(4755, root, root) %{_libexecdir}/%{name}/plugins.d/apps.plugin
49
+%attr(-, netdata, netdata) %dir %{_localstatedir}/cache/%{name}/
50
+%attr(-, netdata, netdata) %dir %{_localstatedir}/log/%{name}/
51
+%{_bindir}/%{name}
52
+%{_datadir}/%{name}/
53
+%{_libexecdir}/%{name}/
54
+%{_sysconfdir}/%{name}/
55
+
56
+%changelog
57
+* Sun Nov 15 2015 Alon Bar-Lev <alonbl@redhat.com> - 1.0.0-1
58
+- Initial add.
plugins.d/Makefile.am
new
+15
@@ -0,0 +1,15 @@
1
+#
2
+# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
3
+#
4
+MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
5
+
6
+dist_plugins_DATA = \
7
+ README \
8
+ loopsleepms.sh.inc \
9
+ $(NULL)
10
+
11
+dist_plugins_SCRIPTS = \
12
+ charts.d.dryrun-helper.sh \
13
+ charts.d.plugin \
14
+ tc-qos-helper.sh \
15
+ $(NULL)
plugins.d/loopsleepms.sh.inc
-2
@@ -1,5 +1,3 @@
1
-#!/bin/sh
2
-
1
# this function is used to sleep a fraction of a second
2
# it calculates the difference between every time is called
3
# and tries to align the sleep time to give you exactly the
src/.keep
src/Makefile
deleted
-101
@@ -1,101 +0,0 @@
1
-ifndef BIN_DIR
2
-BIN_DIR = "."
3
-endif
4
-
5
-ifndef CONFIG_DIR
6
-CONFIG_DIR = "conf.d"
7
-endif
8
-
9
-ifndef LOG_DIR
10
-LOG_DIR = "log"
11
-endif
12
-
13
-ifndef PLUGINS_DIR
14
-PLUGINS_DIR = "plugins.d"
15
-endif
16
-
17
-ifndef nomath
18
-STORAGE_WITH_MATH = 1
19
-endif
20
-
21
-ifdef nofork
22
-NETDATA_NO_DAEMON = 1
23
-endif
24
-
25
-ifdef nozlib
26
-NETDATA_WITHOUT_ZLIB = 1
27
-endif
28
-
29
-COMMON_FLAGS = BIN_DIR='$(BIN_DIR)' CONFIG_DIR='$(CONFIG_DIR)' LOG_DIR='$(LOG_DIR)' PLUGINS_DIR='$(PLUGINS_DIR)'
30
-
31
-proc_sources = proc_net_dev.c proc_net_ip_vs_stats.c proc_diskstats.c proc_meminfo.c proc_net_netstat.c proc_net_snmp.c proc_net_stat_conntrack.c proc_stat.c proc_vmstat.c proc_net_rpc_nfsd.c proc_sys_kernel_random_entropy_avail.c proc_interrupts.c
32
-sources = rrd.c rrd2json.c avl.c dictionary.c procfile.c common.c log.c popen.c url.c config.c web_buffer.c storage_number.c web_client.c global_statistics.c web_server.c plugins_d.c daemon.c plugin_tc.c plugin_checks.c plugin_idlejitter.c plugin_proc.c unit_test.c main.c
33
-libs = -pthread
34
-
35
-ifdef debug
36
-COMMON_FLAGS += debug=1
37
-CFLAGS = -Wall -Wextra -O -ggdb -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fno-omit-frame-pointer
38
-# CFLAGS := -Wall -Wextra -O -g -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fsanitize=thread -fno-omit-frame-pointer -fPIE
39
-# libs += -pie -ltsan
40
-libs += -rdynamic
41
-else
42
-CFLAGS := -Wall -Wextra -O3 -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fomit-frame-pointer
43
-endif
44
-
45
-CC = gcc
46
-
47
-ifdef STORAGE_WITH_MATH
48
-CFLAGS += -DSTORAGE_WITH_MATH=1
49
-libs += -lm
50
-endif
51
-
52
-ifdef NETDATA_NO_DAEMON
53
-CFLAGS += -DNETDATA_NO_DAEMON=1
54
-endif
55
-
56
-ifdef NETDATA_WITHOUT_ZLIB
57
-CFLAGS += -DNETDATA_WITHOUT_ZLIB=1
58
-else
59
-libs += -lz
60
-endif
61
-
62
-# nfacct requires root access, so we prefer it as a plugin.d external plugin
63
-ifdef INTERNAL_PLUGIN_NFACCT
64
-CFLAGS += -DINTERNAL_PLUGIN_NFACCT=1
65
-sources += plugin_nfacct.c
66
-libs += -lmnl -lnetfilter_acct
67
-endif
68
-
69
-headers = $(patsubst %.c,%.h,$(sources))
70
-objects = $(patsubst %.c,%.o,$(sources) $(proc_sources))
71
-
72
-all: show_options netdata plugins
73
-
74
-%.o: %.c ${headers}
75
- $(CC) $(CFLAGS) -c $< -o $@
76
-
77
-netdata: $(objects)
78
- $(CC) -o netdata $(objects) $(libs)
79
-
80
-show_options:
81
- @echo " COMPILING WITH OPTIONS: $(CFLAGS)"
82
-
83
-plugins:
84
- $(MAKE) -C plugins.d $(COMMON_FLAGS) all
85
-
86
-clean:
87
- $(MAKE) -C plugins.d clean
88
- rm -f *.o netdata core
89
-
90
-install: all
91
- $(MAKE) -C plugins.d $(COMMON_FLAGS) install
92
- @echo; \
93
- echo " INSTALLING netdata to $(BIN_DIR)"; \
94
- if [ -f $(BIN_DIR)/netdata ]; \
95
- then \
96
- mv -f $(BIN_DIR)/netdata $(BIN_DIR)/netdata.old; \
97
- fi; \
98
- cp -f netdata $(BIN_DIR)/; \
99
- echo
100
-
101
-.PHONY: all show_options plugins clean install
src/Makefile.am
new
+82
@@ -0,0 +1,82 @@
1
+#
2
+# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
3
+#
4
+MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
5
+
6
+AM_CPPFLAGS = \
7
+ -DCACHE_DIR="\"$(cachedir)\"" \
8
+ -DCONFIG_DIR="\"$(configdir)\"" \
9
+ -DLOG_DIR="\"$(logdir)\"" \
10
+ -DPLUGINS_DIR="\"$(pluginsdir)\"" \
11
+ -DWEB_DIR="\"$(webdir)\"" \
12
+ $(NULL)
13
+AM_CFLAGS = \
14
+ $(OPTIONAL_MATH_CFLAGS) \
15
+ $(OPTIONAL_NFACCT_CLFAGS) \
16
+ $(OPTIONAL_ZLIB_CFLAGS) \
17
+ $(NULL)
18
+
19
+bin_PROGRAMS = netdata
20
+dist_cache_DATA = .keep
21
+dist_log_DATA = .keep
22
+plugins_PROGRAMS = apps.plugin
23
+
24
+netdata_SOURCES = \
25
+ appconfig.c appconfig.h \
26
+ avl.c avl.h \
27
+ common.c common.h \
28
+ daemon.c daemon.h \
29
+ dictionary.c dictionary.h \
30
+ global_statistics.c global_statistics.h \
31
+ log.c log.h \
32
+ main.c main.h \
33
+ plugin_checks.c plugin_checks.h \
34
+ plugin_idlejitter.c plugin_idlejitter.h \
35
+ plugin_nfacct.c plugin_nfacct.h \
36
+ plugin_proc.c plugin_proc.h \
37
+ plugin_tc.c plugin_tc.h \
38
+ plugins_d.c plugins_d.h \
39
+ popen.c popen.h \
40
+ proc_diskstats.c \
41
+ proc_interrupts.c \
42
+ proc_meminfo.c \
43
+ proc_net_dev.c \
44
+ proc_net_ip_vs_stats.c \
45
+ proc_net_netstat.c \
46
+ proc_net_rpc_nfsd.c \
47
+ proc_net_snmp.c \
48
+ proc_net_stat_conntrack.c \
49
+ proc_stat.c \
50
+ proc_sys_kernel_random_entropy_avail.c \
51
+ proc_vmstat.c \
52
+ procfile.c procfile.h \
53
+ rrd.c rrd.h \
54
+ rrd2json.c rrd2json.h \
55
+ storage_number.c storage_number.h \
56
+ unit_test.c unit_test.h \
57
+ url.c url.h \
58
+ web_buffer.c web_buffer.h \
59
+ web_client.c web_client.h \
60
+ web_server.c web_server.h \
61
+ $(NULL)
62
+netdata_LDADD = \
63
+ $(OPTIONAL_MATH_LIBS) \
64
+ $(OPTIONAL_NFACCT_LIBS) \
65
+ $(OPTIONAL_ZLIB_LIBS) \
66
+ $(NULL)
67
+
68
+apps_plugin_SOURCES = \
69
+ apps_plugin.c \
70
+ avl.c avl.h \
71
+ common.c common.h \
72
+ log.c log.h \
73
+ procfile.c procfile.h \
74
+ $(NULL)
75
+
76
+install-data-hook:
77
+ @echo
78
+ @echo "ATTENTION"
79
+ @echo
80
+ @echo "setuid bit of $(pluginsdir)/apps.plugin must be set, please execute as root:"
81
+ @echo "chown root '$(pluginsdir)/apps.plugin' && chmod 4755 '$(pluginsdir)/apps.plugin'"
82
+ @echo
src/appconfig.c
renamed
+4
-2
@@ -1,11 +1,13 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <pthread.h>
5
#include <stdlib.h>
6
#include <string.h>
4
-#include <inttypes.h>
7
8
#include "avl.h"
9
#include "common.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "log.h"
12
13
#define CONFIG_FILE_LINE_MAX ((CONFIG_MAX_NAME + CONFIG_MAX_VALUE + 1024) * 2)
src/appconfig.h
renamed
src/apps_plugin.c
renamed
+7
-9
@@ -3,10 +3,9 @@
3
// 1. support -ch option to set global /proc and /sys prefix
4
// 2. disable RESET_OR_OVERFLOW check in charts
5
6
-
7
-#define __STDC_FORMAT_MACROS
8
-#include <inttypes.h>
9
-
6
+#ifdef HAVE_CONFIG_H
7
+#include <config.h>
8
+#endif
9
#include <stdio.h>
10
#include <stdlib.h>
11
#include <string.h>
@@ -26,14 +25,13 @@
25
#include <fcntl.h>
26
27
#include <malloc.h>
29
-#include <inttypes.h>
28
#include <dirent.h>
29
#include <arpa/inet.h>
30
33
-#include "../common.h"
34
-#include "../log.h"
35
-#include "../avl.h"
36
-#include "../procfile.h"
31
+#include "common.h"
32
+#include "log.h"
33
+#include "avl.h"
34
+#include "procfile.h"
35
36
#define MAX_COMPARE_NAME 15
37
#define MAX_NAME 100
src/avl.c
+3
@@ -13,6 +13,9 @@
13
*
14
*/
15
16
+#ifdef HAVE_CONFIG_H
17
+#include <config.h>
18
+#endif
19
#include "avl.h"
20
21
/* Private methods */
src/common.c
+3
-2
@@ -1,5 +1,6 @@
1
-// enable O_NOATIME
2
-#define _GNU_SOURCE
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <sys/syscall.h>
5
#include <string.h>
6
#include <ctype.h>
src/common.h
+7
-14
@@ -1,10 +1,14 @@
1
+#ifndef NETDATA_COMMON_H
2
+#define NETDATA_COMMON_H 1
3
+
4
+#if defined(HAVE_INTTYPES_H)
5
#include <inttypes.h>
6
+#elif defined(HAVE_STDINT_H)
7
+#include <stdint.h>
8
+#endif
9
#include <sys/types.h>
10
#include <unistd.h>
11
5
-#ifndef NETDATA_COMMON_H
6
-#define NETDATA_COMMON_H 1
7
-
12
#define abs(x) ((x < 0)? -x : x)
13
#define usecdiff(now, last) (((((now)->tv_sec * 1000000ULL) + (now)->tv_usec) - (((last)->tv_sec * 1000000ULL) + (last)->tv_usec)))
14
@@ -20,17 +24,6 @@ extern int fd_is_valid(int fd);
24
25
extern char *global_host_prefix;
26
23
-#ifdef __GNUC__
24
-// gcc branch optimization
25
-// #warning "Using GCC branch optimizations"
26
-#define likely(x) __builtin_expect(!!(x), 1)
27
-#define unlikely(x) __builtin_expect(!!(x), 0)
28
-#else
29
-#define likely(x) (x)
30
-#define unlikely(x) (x)
31
-#endif
32
-
33
-
27
/* Number of ticks per second */
28
#define HZ hz
29
extern unsigned int hz;
src/daemon.c
+7
-2
@@ -1,3 +1,7 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
+#ifdef NETDATA_DAEMON
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <unistd.h>
@@ -12,9 +16,9 @@
16
#include <sys/stat.h>
17
#include <execinfo.h>
18
15
-#include "config.h"
16
-#include "log.h"
19
#include "common.h"
20
+#include "appconfig.h"
21
+#include "log.h"
22
#include "web_client.h"
23
#include "plugins_d.h"
24
#include "rrd.h"
@@ -314,3 +318,4 @@ int become_daemon(int dont_fork, int close_all_files, const char *input, const c
318
319
return(0);
320
}
321
+#endif
src/dictionary.c
+3
-1
@@ -1,7 +1,9 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <pthread.h>
5
#include <stdlib.h>
6
#include <string.h>
4
-#include <inttypes.h>
7
8
#include "avl.h"
9
#include "common.h"
src/global_statistics.c
+3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <pthread.h>
5
6
#include "common.h"
src/log.c
+3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <time.h>
5
#include <syslog.h>
6
#include <errno.h>
src/main.c
+6
-3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <unistd.h>
@@ -16,7 +19,7 @@
19
#include "daemon.h"
20
#include "web_server.h"
21
#include "popen.h"
19
-#include "config.h"
22
+#include "appconfig.h"
23
#include "web_client.h"
24
#include "rrd.h"
25
#include "rrd2json.h"
@@ -340,7 +343,7 @@ int main(int argc, char **argv)
343
// --------------------------------------------------------------------
344
345
prepare_rundir();
343
- char *user = config_get("global", "run as user", (getuid() == 0)?"nobody":"");
346
+ char *user = config_get("global", "run as user", (getuid() == 0)?NETDATA_USER:"");
347
if(*user) {
348
if(become_user(user) != 0) {
349
fprintf(stderr, "Cannot become user %s.\n", user);
@@ -379,7 +382,7 @@ int main(int argc, char **argv)
382
// never become a problem
383
if(nice(20) == -1) fprintf(stderr, "Cannot lower my CPU priority. Error: %s.\n", strerror(errno));
384
382
-#ifndef NETDATA_NO_DAEMON
385
+#ifdef NETDATA_DAEMON
386
if(become_daemon(dont_fork, 0, input_log_file, output_log_file, error_log_file, access_log_file, &access_fd, &stdaccess) == -1) {
387
fprintf(stderr, "Cannot demonize myself (%s).", strerror(errno));
388
exit(1);
src/plugin_checks.c
+4
-1
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <pthread.h>
5
#include <sys/time.h>
6
#include <sys/resource.h>
@@ -5,7 +8,7 @@
8
#include <unistd.h>
9
10
#include "common.h"
8
-#include "config.h"
11
+#include "appconfig.h"
12
#include "log.h"
13
#include "rrd.h"
14
#include "plugin_checks.h"
src/plugin_idlejitter.c
+4
-1
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <pthread.h>
5
#include <sys/time.h>
6
#include <sys/resource.h>
@@ -6,7 +9,7 @@
9
10
#include "global_statistics.h"
11
#include "common.h"
9
-#include "config.h"
12
+#include "appconfig.h"
13
#include "log.h"
14
#include "rrd.h"
15
#include "plugin_idlejitter.h"
src/plugin_nfacct.c
+6
-1
@@ -1,3 +1,7 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
+#ifdef INTERNAL_PLUGIN_NFACCT
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <string.h>
@@ -14,7 +18,7 @@
18
19
#include "global_statistics.h"
20
#include "common.h"
17
-#include "config.h"
21
+#include "appconfig.h"
22
#include "log.h"
23
#include "rrd.h"
24
#include "plugin_proc.h"
@@ -206,3 +210,4 @@ void *nfacct_main(void *ptr) {
210
mnl_socket_close(nl);
211
return NULL;
212
}
213
+#endif
src/plugin_proc.c
+4
-1
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <pthread.h>
5
#include <sys/time.h>
6
#include <sys/resource.h>
@@ -6,7 +9,7 @@
9
10
#include "global_statistics.h"
11
#include "common.h"
9
-#include "config.h"
12
+#include "appconfig.h"
13
#include "log.h"
14
#include "rrd.h"
15
#include "plugin_proc.h"
src/plugin_tc.c
+4
-1
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
@@ -6,7 +9,7 @@
9
#include "avl.h"
10
#include "log.h"
11
#include "common.h"
9
-#include "config.h"
12
+#include "appconfig.h"
13
#include "rrd.h"
14
#include "popen.h"
15
#include "plugin_tc.h"
src/plugins.d/Makefile
deleted
-66
@@ -1,66 +0,0 @@
1
-ifndef BIN_DIR
2
-BIN_DIR = "."
3
-endif
4
-
5
-ifndef CONFIG_DIR
6
-CONFIG_DIR = "conf.d"
7
-endif
8
-
9
-ifndef LOG_DIR
10
-LOG_DIR = "log"
11
-endif
12
-
13
-ifndef PLUGINS_DIR
14
-PLUGINS_DIR = "plugins.d"
15
-endif
16
-
17
-COMMON_FLAGS = BIN_DIR='$(BIN_DIR)' CONFIG_DIR='$(CONFIG_DIR)' LOG_DIR='$(LOG_DIR)' PLUGINS_DIR='$(PLUGINS_DIR)'
18
-
19
-CC := gcc
20
-libs :=
21
-
22
-ifdef debug
23
-COMMON_FLAGS += debug=1
24
-# CFLAGS = -Wall -Wextra -ggdb -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fsanitize=address -fno-omit-frame-pointer
25
-CFLAGS := -Wall -Wextra -O3 -ggdb -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fsanitize=address -fno-omit-frame-pointer
26
-#libs += -ltsan -lpie
27
-else
28
-CFLAGS := -Wall -Wextra -O3 -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fomit-frame-pointer
29
-endif
30
-
31
-all: options plugins
32
-
33
-options:
34
- @echo " COMPILING WITH OPTIONS: $(CFLAGS)"
35
-
36
-plugins: apps.plugin
37
-
38
-apps.plugin: apps_plugin.c
39
- $(CC) $(CFLAGS) -o $@ apps_plugin.c ../avl.o ../common.o ../log.o ../procfile.o $(libs)
40
-
41
-clean:
42
- -rm -f *.o apps.plugin core
43
-
44
-install: all
45
- @echo; \
46
- echo " INSTALLING apps.plugin to $(PLUGINS_DIR)"; \
47
- if [ -f $(PLUGINS_DIR)/apps.plugin ]; \
48
- then \
49
- mv -f $(PLUGINS_DIR)/apps.plugin $(PLUGINS_DIR)/apps.plugin.old; \
50
- fi; \
51
- cp apps.plugin $(PLUGINS_DIR)/; \
52
- if [ ! "$$USER" = "root" ]; \
53
- then \
54
- echo; \
55
- echo " >>> apps.plugin requires root access to access files in /proc"; \
56
- echo " >>> Please authorize it!"; \
57
- echo; \
58
- sudo chown root $(PLUGINS_DIR)/apps.plugin; \
59
- sudo chmod 4775 $(PLUGINS_DIR)/apps.plugin; \
60
- else \
61
- chown root $(PLUGINS_DIR)/apps.plugin; \
62
- chmod 4775 $(PLUGINS_DIR)/apps.plugin; \
63
- fi; \
64
- echo;
65
-
66
-.PHONY: options all plugins clean install
src/plugins_d.c
+4
-1
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <sys/types.h>
5
#include <dirent.h>
6
#include <pthread.h>
@@ -8,7 +11,7 @@
11
12
#include "main.h"
13
#include "common.h"
11
-#include "config.h"
14
+#include "appconfig.h"
15
#include "log.h"
16
#include "rrd.h"
17
#include "popen.h"
src/popen.c
+3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <signal.h>
5
#include <unistd.h>
6
#include <stdlib.h>
src/proc_diskstats.c
+4
-2
@@ -1,11 +1,13 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
8
#include "common.h"
9
#include "log.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "procfile.h"
12
#include "rrd.h"
13
#include "plugin_proc.h"
src/proc_interrupts.c
+4
-2
@@ -1,11 +1,13 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
#include <ctype.h>
8
9
#include "common.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "procfile.h"
12
#include "rrd.h"
13
#include "plugin_proc.h"
src/proc_meminfo.c
+4
-2
@@ -1,11 +1,13 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
8
#include "common.h"
9
#include "log.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "procfile.h"
12
#include "rrd.h"
13
#include "plugin_proc.h"
src/proc_net_dev.c
+4
-2
@@ -1,9 +1,11 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
7
#include "common.h"
6
-#include "config.h"
8
+#include "appconfig.h"
9
#include "procfile.h"
10
#include "rrd.h"
11
#include "plugin_proc.h"
src/proc_net_ip_vs_stats.c
+4
-2
@@ -1,9 +1,11 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
7
#include "common.h"
6
-#include "config.h"
8
+#include "appconfig.h"
9
#include "procfile.h"
10
#include "rrd.h"
11
#include "plugin_proc.h"
src/proc_net_netstat.c
+4
-2
@@ -1,11 +1,13 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
8
#include "common.h"
9
#include "log.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "procfile.h"
12
#include "rrd.h"
13
#include "plugin_proc.h"
src/proc_net_rpc_nfsd.c
+4
-2
@@ -1,11 +1,13 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
8
#include "common.h"
9
#include "log.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "procfile.h"
12
#include "rrd.h"
13
#include "plugin_proc.h"
src/proc_net_snmp.c
+4
-2
@@ -1,11 +1,13 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
8
#include "common.h"
9
#include "log.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "procfile.h"
12
#include "rrd.h"
13
#include "plugin_proc.h"
src/proc_net_stat_conntrack.c
+4
-2
@@ -1,11 +1,13 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
8
#include "common.h"
9
#include "log.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "procfile.h"
12
#include "rrd.h"
13
#include "plugin_proc.h"
src/proc_stat.c
+4
-2
@@ -1,11 +1,13 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
8
#include "common.h"
9
#include "log.h"
8
-#include "config.h"
10
+#include "appconfig.h"
11
#include "procfile.h"
12
#include "rrd.h"
13
#include "plugin_proc.h"
src/proc_sys_kernel_random_entropy_avail.c
+4
-2
@@ -1,9 +1,11 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
7
#include "common.h"
6
-#include "config.h"
8
+#include "appconfig.h"
9
#include "procfile.h"
10
#include "rrd.h"
11
#include "plugin_proc.h"
src/proc_vmstat.c
+4
-2
@@ -1,4 +1,6 @@
1
-#include <inttypes.h>
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
@@ -6,7 +8,7 @@
8
9
#include "common.h"
10
#include "log.h"
9
-#include "config.h"
11
+#include "appconfig.h"
12
#include "procfile.h"
13
#include "rrd.h"
14
#include "plugin_proc.h"
src/procfile.c
+3
-1
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <unistd.h>
@@ -5,7 +8,6 @@
8
#include <fcntl.h>
9
#include <string.h>
10
#include <malloc.h>
8
-#include <inttypes.h>
11
#include <ctype.h>
12
#include <time.h>
13
#include <sys/time.h>
src/rrd.c
+6
-3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stddef.h>
5
#include <string.h>
6
#include <unistd.h>
@@ -11,9 +14,9 @@
14
#include <sys/types.h>
15
#include <stdlib.h>
16
14
-#include "log.h"
15
-#include "config.h"
17
#include "common.h"
18
+#include "log.h"
19
+#include "appconfig.h"
20
21
#include "rrd.h"
22
@@ -278,7 +281,7 @@ char *rrdset_cache_dir(const char *id)
281
char *ret = NULL;
282
283
static char *cache_dir = NULL;
281
- if(!cache_dir) cache_dir = config_get("global", "database directory", "cache");
284
+ if(!cache_dir) cache_dir = config_get("global", "database directory", CACHE_DIR);
285
286
char b[FILENAME_MAX + 1];
287
char n[FILENAME_MAX + 1];
src/rrd2json.c
+3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <pthread.h>
5
#include <sys/time.h>
6
#include <stdlib.h>
src/storage_number.c
+3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#ifdef STORAGE_WITH_MATH
5
#include <math.h>
6
#endif
src/storage_number.h
-2
@@ -1,5 +1,3 @@
1
-#include <inttypes.h>
2
-
1
#ifndef NETDATA_STORAGE_NUMBER_H
2
#define NETDATA_STORAGE_NUMBER_H
3
src/unit_test.c
+3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
src/url.c
+3
@@ -1,3 +1,6 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdlib.h>
5
#include <string.h>
6
#include <ctype.h>
src/web_buffer.c
+4
-2
@@ -1,12 +1,14 @@
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <stdlib.h>
5
6
#ifdef STORAGE_WITH_MATH
7
#include <math.h>
8
#endif
9
7
-#include "web_buffer.h"
8
-
10
#include "common.h"
11
+#include "web_buffer.h"
12
#include "log.h"
13
14
void web_buffer_strcpy(struct web_buffer *wb, const char *txt)
src/web_client.c
+16
-16
@@ -1,6 +1,6 @@
1
-// enable strcasestr()
2
-#define _GNU_SOURCE
3
-
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <unistd.h>
5
#include <stdlib.h>
6
#include <sys/types.h>
@@ -16,7 +16,7 @@
16
17
#include "common.h"
18
#include "log.h"
19
-#include "config.h"
19
+#include "appconfig.h"
20
#include "url.h"
21
#include "web_buffer.h"
22
#include "web_server.h"
@@ -136,7 +136,7 @@ struct web_client *web_client_free(struct web_client *w)
136
int mysendfile(struct web_client *w, char *filename)
137
{
138
static char *web_dir = NULL;
139
- if(!web_dir) web_dir = config_get("global", "web files directory", "web");
139
+ if(!web_dir) web_dir = config_get("global", "web files directory", WEB_DIR);
140
141
debug(D_WEB_CLIENT, "%llu: Looking for file '%s'...", w->id, filename);
142
@@ -227,7 +227,7 @@ void web_client_reset(struct web_client *w)
227
228
long sent = (w->mode == WEB_CLIENT_MODE_FILECOPY)?w->data->rbytes:w->data->bytes;
229
230
-#ifndef NETDATA_WITHOUT_ZLIB
230
+#ifdef NETDATA_WITH_ZLIB
231
if(likely(w->zoutput)) sent = (long)w->zstream.total_out;
232
#endif
233
@@ -270,7 +270,7 @@ void web_client_reset(struct web_client *w)
270
w->zoutput = 0;
271
272
// if we had enabled compression, release it
273
-#ifndef NETDATA_WITHOUT_ZLIB
273
+#ifdef NETDATA_WITH_ZLIB
274
if(w->zinitialized) {
275
debug(D_DEFLATE, "%llu: Reseting compression.", w->id);
276
deflateEnd(&w->zstream);
@@ -282,10 +282,10 @@ void web_client_reset(struct web_client *w)
282
w->zstream.total_out = 0;
283
w->zinitialized = 0;
284
}
285
-#endif // NETDATA_WITHOUT_ZLIB
285
+#endif // NETDATA_WITH_ZLIB
286
}
287
288
-#ifndef NETDATA_WITHOUT_ZLIB
288
+#ifdef NETDATA_WITH_ZLIB
289
void web_client_enable_deflate(struct web_client *w) {
290
if(w->zinitialized == 1) {
291
error("%llu: Compression has already be initialized for this client.", w->id);
@@ -330,7 +330,7 @@ void web_client_enable_deflate(struct web_client *w) {
330
331
debug(D_DEFLATE, "%llu: Initialized compression.", w->id);
332
}
333
-#endif // NETDATA_WITHOUT_ZLIB
333
+#endif // NETDATA_WITH_ZLIB
334
335
int web_client_data_request(struct web_client *w, char *url, int datasource_type)
336
{
@@ -555,11 +555,11 @@ void web_client_process(struct web_client *w) {
555
if(strcasestr(w->data->buffer, "Connection: keep-alive")) w->keepalive = 1;
556
else w->keepalive = 0;
557
558
-#ifndef NETDATA_WITHOUT_ZLIB
558
+#ifdef NETDATA_WITH_ZLIB
559
// check if the client accepts deflate
560
if(web_enable_gzip && strstr(w->data->buffer, "gzip"))
561
web_client_enable_deflate(w);
562
-#endif // NETDATA_WITHOUT_ZLIB
562
+#endif // NETDATA_WITH_ZLIB
563
564
int datasource_type = DATASOURCE_GOOGLE_JSONP;
565
//if(strstr(w->data->buffer, "X-DataSource-Auth"))
@@ -988,7 +988,7 @@ long web_client_send_chunk_finalize(struct web_client *w)
988
return bytes;
989
}
990
991
-#ifndef NETDATA_WITHOUT_ZLIB
991
+#ifdef NETDATA_WITH_ZLIB
992
long web_client_send_deflate(struct web_client *w)
993
{
994
long bytes = 0, t = 0;
@@ -1089,13 +1089,13 @@ long web_client_send_deflate(struct web_client *w)
1089
1090
return(bytes);
1091
}
1092
-#endif // NETDATA_WITHOUT_ZLIB
1092
+#endif // NETDATA_WITH_ZLIB
1093
1094
long web_client_send(struct web_client *w)
1095
{
1096
-#ifndef NETDATA_WITHOUT_ZLIB
1096
+#ifdef NETDATA_WITH_ZLIB
1097
if(likely(w->zoutput)) return web_client_send_deflate(w);
1098
-#endif // NETDATA_WITHOUT_ZLIB
1098
+#endif // NETDATA_WITH_ZLIB
1099
1100
long bytes;
1101
src/web_server.c
+4
-4
@@ -1,6 +1,6 @@
1
-// enable strcasestr()
2
-#define _GNU_SOURCE
3
-
1
+#ifdef HAVE_CONFIG_H
2
+#include <config.h>
3
+#endif
4
#include <unistd.h>
5
#include <stdlib.h>
6
#include <sys/types.h>
@@ -16,7 +16,7 @@
16
17
#include "common.h"
18
#include "log.h"
19
-#include "config.h"
19
+#include "appconfig.h"
20
#include "url.h"
21
#include "web_buffer.h"
22
#include "web_client.h"
web/Makefile.am
new
+13
@@ -0,0 +1,13 @@
1
+#
2
+# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
3
+#
4
+MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
5
+
6
+dist_web_DATA = \
7
+ datasource.html \
8
+ index.html \
9
+ index.js \
10
+ netdata.js \
11
+ robots.txt \
12
+ theme.css \
13
+ $(NULL)