-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathne.h
More file actions
300 lines (255 loc) · 10.4 KB
/
Copy pathne.h
File metadata and controls
300 lines (255 loc) · 10.4 KB
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
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Fluent Bit
* ==========
* Copyright (C) 2015-2026 The Fluent Bit Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLB_NODE_EXPORTER_H
#define FLB_NODE_EXPORTER_H
/* utils: scan content type expected */
#define NE_SCAN_FILE 1
#define NE_SCAN_DIR 2
#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_input_plugin.h>
#include <fluent-bit/flb_regex.h>
#include <fluent-bit/flb_hash_table.h>
#include <fluent-bit/flb_metrics.h>
/* Default enabled metrics */
#ifdef __linux__
#define NE_DEFAULT_ENABLED_METRICS "cpu,cpufreq,meminfo,diskstats,filesystem,uname,stat,time,loadavg,vmstat,netdev,netstat,sockstat,filefd,systemd,nvme,thermal_zone,hwmon,powersupplyclass"
#elif __APPLE__
#define NE_DEFAULT_ENABLED_METRICS "cpu,loadavg,meminfo,diskstats,filesystem,uname,netdev,powersupplyclass"
#endif
/* filesystem: regex for ignoring mount points and filesystem types */
#define IGNORED_MOUNT_POINTS "^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+|var/lib/containers/storage/.+)($|/)"
#define IGNORED_FS_TYPES "^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
/* diskstats: regex for ignoring devices */
#define IGNORED_DEVICES "^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$"
struct flb_ne {
/* configuration */
flb_sds_t path_rootfs;
flb_sds_t path_procfs;
flb_sds_t path_sysfs;
flb_sds_t path_textfile;
int scrape_interval;
int coll_fd; /* collector fd */
struct cmt *cmt; /* cmetrics context */
struct flb_input_instance *ins; /* input instance */
struct mk_list *metrics; /* enabled metrics */
struct mk_list collectors;
/*
* Metrics Contexts
* ----------------
*/
/* cpu_linux */
struct cmt_counter *cpu_core_throttles;
struct cmt_counter *cpu_package_throttles;
/* cpufreq_linux */
struct cmt_gauge *cpu_freq_hertz;
struct cmt_gauge *cpu_freq_min_hertz;
struct cmt_gauge *cpu_freq_max_hertz;
/* cpufreq scaling linux */
struct cmt_gauge *cpu_scaling_freq_hertz;
struct cmt_gauge *cpu_scaling_freq_max_hertz;
struct cmt_gauge *cpu_scaling_freq_min_hertz;
/* cpu seconds & guest seconds */
struct cmt_counter *cpu_seconds;
struct cmt_counter *cpu_guest_seconds;
/* meminfo hash table */
struct flb_hash_table *meminfo_ht;
#ifdef FLB_SYSTEM_MACOS
/* meminfo_darwin */
struct cmt_gauge *darwin_free_bytes;
struct cmt_gauge *darwin_active_bytes;
struct cmt_gauge *darwin_compressed_bytes;
struct cmt_gauge *darwin_inactive_bytes;
struct cmt_gauge *darwin_wired_bytes;
struct cmt_gauge *darwin_internal_bytes;
struct cmt_gauge *darwin_purgeable_bytes;
struct cmt_counter *darwin_pageins_bytes;
struct cmt_counter *darwin_pageouts_bytes;
struct cmt_gauge *darwin_swap_used_bytes;
struct cmt_gauge *darwin_swap_total_bytes;
struct cmt_counter *darwin_total_bytes;
/* powersupply_darwin */
struct cmt_gauge *darwin_ps_current_capacity;
struct cmt_gauge *darwin_ps_max_capacity;
struct cmt_gauge *darwin_ps_design_capacity;
struct cmt_gauge *darwin_ps_nominal_capacity;
struct cmt_gauge *darwin_ps_time_to_empty;
struct cmt_gauge *darwin_ps_time_to_full;
struct cmt_gauge *darwin_ps_voltage;
struct cmt_gauge *darwin_ps_current;
struct cmt_gauge *darwin_ps_temperature;
struct cmt_gauge *darwin_ps_present;
struct cmt_gauge *darwin_ps_charging;
struct cmt_gauge *darwin_ps_charged;
struct cmt_gauge *darwin_ps_internal_failure;
struct cmt_gauge *darwin_ps_battery_health;
#endif
/* diskstats: abbreviation 'dt' */
void *dt_metrics;
struct flb_regex *dt_regex_skip_devices;
flb_sds_t dt_regex_skip_devices_text;
/* uname */
struct cmt_gauge *uname;
/* stat_linux */
struct cmt_counter *st_intr;
struct cmt_counter *st_context_switches;
struct cmt_gauge *st_boot_time;
struct cmt_counter *st_forks;
struct cmt_gauge *st_procs_running;
struct cmt_gauge *st_procs_blocked;
/* vmstat_linux */
struct flb_hash_table *vml_ht;
struct flb_regex *vml_regex_fields;
/* netdev */
struct flb_hash_table *netdev_ht;
#ifdef FLB_SYSTEM_MACOS
/* netdev_darwin */
struct cmt_gauge *darwin_receive_packets;
struct cmt_gauge *darwin_transmit_packets;
struct cmt_gauge *darwin_receive_bytes;
struct cmt_gauge *darwin_transmit_bytes;
struct cmt_gauge *darwin_receive_errors;
struct cmt_gauge *darwin_transmit_errors;
struct cmt_gauge *darwin_receive_dropped;
struct cmt_gauge *darwin_receive_multicast;
struct cmt_gauge *darwin_transmit_multicast;
struct cmt_gauge *darwin_collisions;
struct cmt_gauge *darwin_noproto;
#endif
/* powersupply_linux */
struct cmt_gauge *powersupply_info;
struct mk_list powersupply_dynamic_metrics;
/* sockstat_linux */
struct cmt_gauge *sockstat_sockets_used;
struct cmt_gauge *sockstat_TCP_alloc;
struct cmt_gauge *sockstat_TCP_inuse;
struct cmt_gauge *sockstat_TCP_mem;
struct cmt_gauge *sockstat_TCP_mem_bytes;
struct cmt_gauge *sockstat_TCP_orphan;
struct cmt_gauge *sockstat_TCP_tw;
struct cmt_gauge *sockstat_UDP_inuse;
struct cmt_gauge *sockstat_UDP_mem;
struct cmt_gauge *sockstat_UDP_mem_bytes;
struct cmt_gauge *sockstat_UDPLITE_inuse;
struct cmt_gauge *sockstat_RAW_inuse;
struct cmt_gauge *sockstat_FRAG_inuse;
struct cmt_gauge *sockstat_FRAG_memory;
struct cmt_gauge *sockstat_TCP6_inuse;
struct cmt_gauge *sockstat_UDP6_inuse;
struct cmt_gauge *sockstat_UDPLITE6_inuse;
struct cmt_gauge *sockstat_RAW6_inuse;
struct cmt_gauge *sockstat_FRAG6_inuse;
struct cmt_gauge *sockstat_FRAG6_memory;
/* netstat_linux */
struct cmt_gauge *netstat_Tcp_CurrEstab;
struct cmt_counter *netstat_Tcp_ActiveOpens;
struct cmt_counter *netstat_Tcp_PassiveOpens;
struct cmt_counter *netstat_Tcp_RetransSegs;
struct cmt_counter *netstat_Udp_InDatagrams;
struct cmt_counter *netstat_Udp_InErrors;
struct cmt_counter *netstat_Udp_OutDatagrams;
struct cmt_counter *netstat_Udp_NoPorts;
struct mk_list netstat_dynamic_metrics;
/* time */
struct cmt_gauge *time;
/* loadavg */
struct cmt_gauge *lavg_1;
struct cmt_gauge *lavg_5;
struct cmt_gauge *lavg_15;
/* filefd_linux */
struct cmt_gauge *filefd_allocated;
struct cmt_gauge *filefd_maximum;
/* filesystem: abbreviation 'fs' */
struct cmt_gauge *fs_avail_bytes;
struct cmt_gauge *fs_device_error;
struct cmt_gauge *fs_files;
struct cmt_gauge *fs_files_free;
struct cmt_gauge *fs_free_bytes;
struct cmt_gauge *fs_readonly;
struct cmt_gauge *fs_size_bytes;
flb_sds_t fs_regex_ingore_mount_point_text;
flb_sds_t fs_regex_ingore_filesystem_type_text;
struct flb_regex *fs_regex_read_only;
struct flb_regex *fs_regex_skip_mount;
struct flb_regex *fs_regex_skip_fs_types;
/* testfile */
struct cmt_counter *load_errors;
/* systemd */
struct cmt_gauge *systemd_socket_accepted_connections;
struct cmt_gauge *systemd_socket_active_connections;
struct cmt_gauge *systemd_socket_refused_connections;
struct cmt_counter *systemd_service_restarts;
struct cmt_gauge *systemd_unit_start_times;
struct cmt_gauge *systemd_system_running;
struct cmt_gauge *systemd_timer_last_trigger_seconds;
struct cmt_gauge *systemd_unit_state;
struct cmt_gauge *systemd_unit_tasks;
struct cmt_gauge *systemd_unit_tasks_max;
struct cmt_gauge *systemd_units;
struct cmt_gauge *systemd_version;
void *systemd_dbus_handle;
int systemd_initialization_flag;
int systemd_include_unit_start_times;
int systemd_include_service_restarts;
int systemd_include_service_task_metrics;
flb_sds_t systemd_regex_include_list_text;
flb_sds_t systemd_regex_exclude_list_text;
struct flb_regex *systemd_regex_include_list;
struct flb_regex *systemd_regex_exclude_list;
double libsystemd_version;
char *libsystemd_version_text;
/* processes */
struct cmt_gauge *processes_thread_alloc;
struct cmt_gauge *processes_threads_limit;
struct cmt_gauge *processes_threads_state;
struct cmt_gauge *processes_procs_state;
struct cmt_gauge *processes_pid_used;
struct cmt_gauge *processes_pid_max;
/* nvme */
struct cmt_gauge *nvme_info;
/* thermal zone */
struct cmt_gauge *thermalzone_temp;
struct cmt_gauge *cooling_device_cur_state;
struct cmt_gauge *cooling_device_max_state;
/* hwmon */
struct cmt_gauge *hwmon_temp_celsius;
struct cmt_gauge *hwmon_temp_max_celsius;
struct cmt_gauge *hwmon_temp_crit_celsius;
struct cmt_gauge *hwmon_in_volts;
struct cmt_gauge *hwmon_fan_rpm;
struct cmt_gauge *hwmon_power_watts;
flb_sds_t hwmon_chip_regex_include_text;
flb_sds_t hwmon_chip_regex_exclude_text;
flb_sds_t hwmon_sensor_regex_include_text;
flb_sds_t hwmon_sensor_regex_exclude_text;
struct flb_regex *hwmon_chip_regex_include;
struct flb_regex *hwmon_chip_regex_exclude;
struct flb_regex *hwmon_sensor_regex_include;
struct flb_regex *hwmon_sensor_regex_exclude;
};
struct flb_ne_collector {
const char *name;
int coll_fd;
int interval;
int activated;
/* callbacks */
int (*cb_init) (struct flb_ne *ctx);
int (*cb_update) (struct flb_input_instance *ins, struct flb_config *conf, void *in_context);
int (*cb_exit) (struct flb_ne *ctx);
struct mk_list _head;
};
#endif