]> arthur.barton.de Git - netdata.git/blob - src/common.h
all required system headers in common.h; some progress on health variables
[netdata.git] / src / common.h
1 #ifndef NETDATA_COMMON_H
2 #define NETDATA_COMMON_H 1
3
4 #ifdef HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7
8 #include <pthread.h>
9 #include <errno.h>
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stdarg.h>
14 #include <stddef.h>
15
16 #include <ctype.h>
17 #include <string.h>
18 #include <strings.h>
19
20 #include <arpa/inet.h>
21 #include <netinet/in.h>
22 #include <netinet/tcp.h>
23
24 #include <dirent.h>
25 #include <fcntl.h>
26 #include <getopt.h>
27 #include <grp.h>
28 #include <pwd.h>
29 #include <locale.h>
30 #include <malloc.h>
31 #include <netdb.h>
32 #include <poll.h>
33 #include <signal.h>
34 #include <syslog.h>
35 #include <sys/mman.h>
36 #include <sys/resource.h>
37 #include <sys/socket.h>
38 #include <sys/stat.h>
39 #include <sys/statvfs.h>
40 #include <sys/syscall.h>
41 #include <sys/time.h>
42 #include <sys/types.h>
43 #include <sys/wait.h>
44 #include <time.h>
45 #include <unistd.h>
46 #include <uuid/uuid.h>
47
48 #ifdef STORAGE_WITH_MATH
49 #include <math.h>
50 #endif
51
52 #if defined(HAVE_INTTYPES_H)
53 #include <inttypes.h>
54 #elif defined(HAVE_STDINT_H)
55 #include <stdint.h>
56 #endif
57
58 #ifdef NETDATA_INTERNAL_CHECKS
59 #include <sys/prctl.h>
60 #endif
61
62 #ifdef NETDATA_WITH_ZLIB
63 #include <zlib.h>
64 #endif
65
66 #include "avl.h"
67 #include "log.h"
68 #include "global_statistics.h"
69 #include "storage_number.h"
70 #include "web_buffer.h"
71 #include "web_buffer_svg.h"
72 #include "url.h"
73 #include "popen.h"
74
75 #include "procfile.h"
76 #include "appconfig.h"
77 #include "dictionary.h"
78 #include "proc_self_mountinfo.h"
79 #include "plugin_checks.h"
80 #include "plugin_idlejitter.h"
81 #include "plugin_nfacct.h"
82 #include "plugin_proc.h"
83 #include "plugin_tc.h"
84 #include "plugins_d.h"
85
86 #include "health.h"
87
88 #include "rrd.h"
89 #include "rrd2json.h"
90
91 #include "web_client.h"
92 #include "web_server.h"
93
94 #include "registry.h"
95 #include "daemon.h"
96 #include "main.h"
97 #include "unit_test.h"
98
99 #if __GNUC__
100 #if __x86_64__ || __ppc64__
101 #define ENVIRONMENT64
102 #else
103 #define ENVIRONMENT32
104 #endif
105 #endif
106
107 #ifdef abs
108 #undef abs
109 #endif
110 #define abs(x) ((x < 0)? -x : x)
111
112 #define usecdiff(now, last) (((((now)->tv_sec * 1000000ULL) + (now)->tv_usec) - (((last)->tv_sec * 1000000ULL) + (last)->tv_usec)))
113
114 extern void netdata_fix_chart_id(char *s);
115 extern void netdata_fix_chart_name(char *s);
116
117 extern uint32_t simple_hash(const char *name);
118 extern uint32_t simple_uhash(const char *name);
119
120 extern void strreverse(char* begin, char* end);
121 extern char *mystrsep(char **ptr, char *s);
122 extern char *trim(char *s);
123
124 extern char *strncpyz(char *dst, const char *src, size_t n);
125 extern int  vsnprintfz(char *dst, size_t n, const char *fmt, va_list args);
126 extern int  snprintfz(char *dst, size_t n, const char *fmt, ...) __attribute__ (( format (printf, 3, 4)));
127
128 extern void *mymmap(const char *filename, size_t size, int flags, int ksm);
129 extern int savememory(const char *filename, void *mem, size_t size);
130
131 extern int fd_is_valid(int fd);
132
133 extern char *global_host_prefix;
134 extern int enable_ksm;
135
136 /* Number of ticks per second */
137 extern unsigned int hz;
138 extern void get_HZ(void);
139
140 extern pid_t gettid(void);
141
142 extern unsigned long long timems(void);
143 extern int usecsleep(unsigned long long usec);
144
145 extern char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len);
146
147 /* fix for alpine linux */
148 #ifndef RUSAGE_THREAD
149 #ifdef RUSAGE_CHILDREN
150 #define RUSAGE_THREAD RUSAGE_CHILDREN
151 #endif
152 #endif
153
154 #endif /* NETDATA_COMMON_H */