]> arthur.barton.de Git - netdata.git/blob - src/registry_internals.h
added more fping alarms; added the ability to have alarms that never send CLEAR notif...
[netdata.git] / src / registry_internals.h
1 #include "common.h"
2
3 #ifndef NETDATA_REGISTRY_INTERNALS_H_H
4 #define NETDATA_REGISTRY_INTERNALS_H_H
5
6 #define REGISTRY_URL_FLAGS_DEFAULT 0x00
7 #define REGISTRY_URL_FLAGS_EXPIRED 0x01
8
9 #define DICTIONARY_FLAGS DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE | DICTIONARY_FLAG_NAME_LINK_DONT_CLONE | DICTIONARY_FLAG_SINGLE_THREADED
10
11 // ----------------------------------------------------------------------------
12 // COMMON structures
13
14 struct registry {
15     int enabled;
16
17     char machine_guid[GUID_LEN + 1];
18
19     // entries counters / statistics
20     unsigned long long persons_count;
21     unsigned long long machines_count;
22     unsigned long long usages_count;
23     unsigned long long urls_count;
24     unsigned long long persons_urls_count;
25     unsigned long long machines_urls_count;
26     unsigned long long log_count;
27
28     // memory counters / statistics
29     unsigned long long persons_memory;
30     unsigned long long machines_memory;
31     unsigned long long urls_memory;
32     unsigned long long persons_urls_memory;
33     unsigned long long machines_urls_memory;
34
35     // configuration
36     unsigned long long save_registry_every_entries;
37     char *registry_domain;
38     char *hostname;
39     char *registry_to_announce;
40     time_t persons_expiration; // seconds to expire idle persons
41     int verify_cookies_redirects;
42
43     size_t max_url_length;
44     size_t max_name_length;
45
46     // file/path names
47     char *pathname;
48     char *db_filename;
49     char *log_filename;
50     char *machine_guid_filename;
51
52     // open files
53     FILE *log_fp;
54
55     // the database
56     DICTIONARY *persons;    // dictionary of REGISTRY_PERSON *,  with key the REGISTRY_PERSON.guid
57     DICTIONARY *machines;   // dictionary of REGISTRY_MACHINE *, with key the REGISTRY_MACHINE.guid
58
59     avl_tree registry_urls_root_index;
60
61     pthread_mutex_t lock;
62 };
63
64 extern int registry_regenerate_guid(const char *guid, char *result);
65
66 #include "registry_url.h"
67 #include "registry_machine.h"
68 #include "registry_person.h"
69 #include "registry.h"
70
71 extern struct registry registry;
72
73 extern char *registry_get_this_machine_guid(void);
74
75 // REGISTRY LOW-LEVEL REQUESTS (in registry-internals.c)
76 extern REGISTRY_PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url, char *name, time_t when);
77 extern REGISTRY_PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
78 extern REGISTRY_MACHINE *registry_request_machine(char *person_guid, char *machine_guid, char *url, char *request_machine, time_t when);
79
80 // REGISTRY LOG (in registry_log.c)
81 extern void registry_log(const char action, REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name);
82 extern int registry_log_open(void);
83 extern void registry_log_close(void);
84 extern void registry_log_recreate(void);
85 extern ssize_t registry_log_load(void);
86
87 // REGISTRY DB (in registry_db.c)
88 extern int registry_db_save(void);
89 extern size_t registry_db_load(void);
90 extern int registry_db_should_be_saved(void);
91
92 #endif //NETDATA_REGISTRY_INTERNALS_H_H