-
Notifications
You must be signed in to change notification settings - Fork 0
/
result_path_client.h
53 lines (40 loc) · 1.51 KB
/
result_path_client.h
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
//
// Created by macskas on 4/16/21.
//
#ifndef NSCA_RESULT_PATH_CLIENT_H
#define NSCA_RESULT_PATH_CLIENT_H
extern "C" {
#include <event2/util.h>
#include <sys/inotify.h>
}
#include <string>
#include "network.h"
// 16 should be NAME_MAX, but we dont need that
#define INOTIFY_BUF_LEN (128 * (sizeof(struct inotify_event) + 16 + 1))
class result_path_client {
private:
int inotifyFd = -1;
int wd = -1;
struct bufferevent *client_bev = nullptr;
uint64_t dir_inode = 0;
int64_t files_in_directory = 0;
class network *parent = nullptr;
bool dir_watched = false;
bool write_enabled = true;
int check_result_path_max_files = 0;
public:
result_path_client(class network *network);
~result_path_client();
void readcb(bufferevent *bev);
static void readcb_proxy(bufferevent *, void *);
void watch_directory();
void init();
void uninit();
void unwatch_directory();
void count_files();
void check();
int write_result(const std::string& check_result_path, time_t now, const std::string& cnow, const std::string& hostname, const std::string& service, int return_code, const std::string& plugin_output) const;
private:
void event_received(struct inotify_event *);
};
#endif //NSCA_RESULT_PATH_CLIENT_H