summaryrefslogtreecommitdiffstats
path: root/collectors/ebpf.plugin/ebpf.h
blob: 5f05389e0262aae23f01f6bcfd3bca497390400f (plain)
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
#ifndef _NETDATA_VFS_EBPF_H_
# define _NETDATA_VFS_EBPF_H_ 1

# include <stdint.h>

#ifndef __FreeBSD__
#   include <linux/perf_event.h>
# endif
# include <stdint.h>
# include <errno.h>
# include <signal.h>
# include <stdio.h>
# include <stdint.h>
# include <stdlib.h>
# include <string.h>
# include <unistd.h>
# include <dlfcn.h>

# define NETDATA_GLOBAL_VECTOR 24
# define NETDATA_MAX_MONITOR_VECTOR 9
# define NETDATA_VFS_ERRORS 3
# define NETDATA_PROCESS_ERRORS 4

# define NETDATA_DEL_START 2
# define NETDATA_IN_START_BYTE 3
# define NETDATA_EXIT_START 5
# define NETDATA_PROCESS_START 7
# define NETDATA_PROCESS_RUNNING_COUNT 9

# define NETDATA_EBPF_PROCESS_THREADS (uint32_t)3

# include <fcntl.h>
# include <ctype.h>
# include <dirent.h>

//From libnetdata.h
# include "../../libnetdata/threads/threads.h"
# include "../../libnetdata/locks/locks.h"
# include "../../libnetdata/avl/avl.h"
# include "../../libnetdata/clocks/clocks.h"
# include "../../libnetdata/config/appconfig.h"
# include "../../libnetdata/ebpf/ebpf.h"

typedef enum {
    MODE_RETURN = 0,    //This attaches kprobe when the function returns
    MODE_DEVMODE,       //This stores log given description about the errors raised
    MODE_ENTRY          //This attaches kprobe when the function is called
} netdata_run_mode_t;

typedef struct netdata_syscall_stat {
    unsigned long bytes;                //total number of bytes
    uint64_t call;                      //total number of calls
    uint64_t ecall;                     //number of calls that returned error
    struct netdata_syscall_stat  *next; //Link list
}netdata_syscall_stat_t;

typedef uint64_t netdata_idx_t;

typedef struct netdata_publish_syscall {
    char *dimension;
    char *name;
    unsigned long nbyte;
    unsigned long pbyte;
    uint64_t ncall;
    uint64_t pcall;
    uint64_t nerr;
    uint64_t perr;
    struct netdata_publish_syscall *next;
}netdata_publish_syscall_t;

typedef struct netdata_publish_vfs_common {
    long write;
    long read;

    long running;
    long zombie;
}netdata_publish_vfs_common_t;

typedef struct netdata_error_report {
    char comm[16];
    __u32 pid;

    int type;
    int err;
}netdata_error_report_t;

//Chart defintions
# define NETDATA_EBPF_FAMILY "ebpf"
# define NETDATA_FILE_GROUP "File"
# define NETDATA_VFS_GROUP "VFS"
# define NETDATA_PROCESS_GROUP "Process"

# define NETDATA_FILE_OPEN_CLOSE_COUNT "file_descriptor"
# define NETDATA_FILE_OPEN_ERR_COUNT "file_error"
# define NETDATA_VFS_FILE_CLEAN_COUNT "deleted_objects"
# define NETDATA_VFS_FILE_IO_COUNT "io"
# define NETDATA_VFS_FILE_ERR_COUNT "io_error"

# define NETDATA_EXIT_SYSCALL "exit"
# define NETDATA_PROCESS_SYSCALL "process_thread"
# define NETDATA_PROCESS_ERROR_NAME "task_error"
# define NETDATA_PROCESS_STATUS_NAME "process_status"

# define NETDATA_VFS_IO_FILE_BYTES "io_bytes"
# define NETDATA_VFS_DIM_IN_FILE_BYTES "write"
# define NETDATA_VFS_DIM_OUT_FILE_BYTES "read"

//Log file
# define NETDATA_DEVELOPER_LOG_FILE "developer.log"

//Maximum number of processors monitored on perf events
# define NETDATA_MAX_PROCESSOR 512

//Kernel versions calculated with the formula:
//   R = MAJOR*65536 + MINOR*256 + PATCH
# define NETDATA_KERNEL_V5_3 328448
# define NETDATA_KERNEL_V4_15 265984

//Index from kernel
# define NETDATA_KEY_CALLS_DO_SYS_OPEN 0
# define NETDATA_KEY_ERROR_DO_SYS_OPEN 1

# define NETDATA_KEY_CALLS_VFS_WRITE 2
# define NETDATA_KEY_ERROR_VFS_WRITE 3
# define NETDATA_KEY_BYTES_VFS_WRITE 4

# define NETDATA_KEY_CALLS_VFS_READ 5
# define NETDATA_KEY_ERROR_VFS_READ 6
# define NETDATA_KEY_BYTES_VFS_READ 7

# define NETDATA_KEY_CALLS_VFS_UNLINK 8
# define NETDATA_KEY_ERROR_VFS_UNLINK 9

# define NETDATA_KEY_CALLS_DO_EXIT 10

# define NETDATA_KEY_CALLS_RELEASE_TASK 11

# define NETDATA_KEY_CALLS_DO_FORK 12
# define NETDATA_KEY_ERROR_DO_FORK 13

# define NETDATA_KEY_CALLS_CLOSE_FD 14
# define NETDATA_KEY_ERROR_CLOSE_FD 15

# define NETDATA_KEY_CALLS_SYS_CLONE 16
# define NETDATA_KEY_ERROR_SYS_CLONE 17

# define NETDATA_KEY_CALLS_VFS_WRITEV 18
# define NETDATA_KEY_ERROR_VFS_WRITEV 19
# define NETDATA_KEY_BYTES_VFS_WRITEV 20

# define NETDATA_KEY_CALLS_VFS_READV 21
# define NETDATA_KEY_ERROR_VFS_READV 22
# define NETDATA_KEY_BYTES_VFS_READV 23

#endif