summaryrefslogtreecommitdiffstats
path: root/registry
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-30 18:47:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-30 18:47:05 +0000
commit97e01009d69b8fbebfebf68f51e3d126d0ed43fc (patch)
tree02e8b836c3a9d89806f3e67d4a5fe9f52dbb0061 /registry
parentReleasing debian version 1.36.1-1. (diff)
downloadnetdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.tar.xz
netdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.zip
Merging upstream version 1.37.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'registry')
-rw-r--r--registry/registry.c17
-rw-r--r--registry/registry.h26
-rw-r--r--registry/registry_db.c11
-rw-r--r--registry/registry_init.c18
-rw-r--r--registry/registry_internals.h24
-rw-r--r--registry/registry_machine.c10
-rw-r--r--registry/registry_machine.h10
-rw-r--r--registry/registry_person.h20
-rw-r--r--registry/registry_url.h12
9 files changed, 66 insertions, 82 deletions
diff --git a/registry/registry.c b/registry/registry.c
index a4f9c6de3..e6c2172b0 100644
--- a/registry/registry.c
+++ b/registry/registry.c
@@ -61,7 +61,7 @@ static inline void registry_json_header(RRDHOST *host, struct web_client *w, con
buffer_flush(w->response.data);
w->response.data->contenttype = CT_APPLICATION_JSON;
buffer_sprintf(w->response.data, "{\n\t\"action\": \"%s\",\n\t\"status\": \"%s\",\n\t\"hostname\": \"%s\",\n\t\"machine_guid\": \"%s\"",
- action, status, host->registry_hostname, host->machine_guid);
+ action, status, rrdhost_registry_hostname(host), host->machine_guid);
}
static inline void registry_json_footer(struct web_client *w) {
@@ -108,9 +108,7 @@ static int registry_json_person_url_callback(void *entry, void *data) {
}
// callback for rendering MACHINE_URLs
-static int registry_json_machine_url_callback(const char *name, void *entry, void *data) {
- (void)name;
-
+static int registry_json_machine_url_callback(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *data) {
REGISTRY_MACHINE_URL *mu = (REGISTRY_MACHINE_URL *)entry;
struct registry_json_walk_person_urls_callback *c = (struct registry_json_walk_person_urls_callback *)data;
struct web_client *w = c->w;
@@ -166,10 +164,12 @@ void registry_update_cloud_base_url()
int registry_request_hello_json(RRDHOST *host, struct web_client *w) {
registry_json_header(host, w, "hello", REGISTRY_STATUS_OK);
+ const char *cloud_ui_url = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "cloud ui url", DEFAULT_CLOUD_UI_URL);
+
buffer_sprintf(w->response.data,
",\n\t\"registry\": \"%s\",\n\t\"cloud_base_url\": \"%s\",\n\t\"anonymous_statistics\": %s",
registry.registry_to_announce,
- registry.cloud_base_url, netdata_anonymous_statistics_enabled?"true":"false");
+ cloud_ui_url, netdata_anonymous_statistics_enabled?"true":"false");
registry_json_footer(w);
return 200;
@@ -379,7 +379,6 @@ void registry_statistics(void) {
rrddim_add(sts, "sessions", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
- else rrdset_next(sts);
rrddim_set(sts, "sessions", registry.usages_count);
rrdset_done(sts);
@@ -408,7 +407,6 @@ void registry_statistics(void) {
rrddim_add(stc, "persons_urls", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rrddim_add(stc, "machines_urls", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
- else rrdset_next(stc);
rrddim_set(stc, "persons", registry.persons_count);
rrddim_set(stc, "machines", registry.machines_count);
@@ -441,10 +439,9 @@ void registry_statistics(void) {
rrddim_add(stm, "persons_urls", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
rrddim_add(stm, "machines_urls", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
}
- else rrdset_next(stm);
- rrddim_set(stm, "persons", registry.persons_memory + dictionary_stats_allocated_memory(registry.persons));
- rrddim_set(stm, "machines", registry.machines_memory + dictionary_stats_allocated_memory(registry.machines));
+ rrddim_set(stm, "persons", registry.persons_memory + dictionary_stats_for_registry(registry.persons));
+ rrddim_set(stm, "machines", registry.machines_memory + dictionary_stats_for_registry(registry.machines));
rrddim_set(stm, "urls", registry.urls_memory);
rrddim_set(stm, "persons_urls", registry.persons_urls_memory);
rrddim_set(stm, "machines_urls", registry.machines_urls_memory);
diff --git a/registry/registry.h b/registry/registry.h
index 5e274487d..6aa3f0a11 100644
--- a/registry/registry.h
+++ b/registry/registry.h
@@ -55,29 +55,29 @@
// initialize the registry
// should only happen when netdata starts
-extern int registry_init(void);
+int registry_init(void);
// free all data held by the registry
// should only happen when netdata exits
-extern void registry_free(void);
+void registry_free(void);
// HTTP requests handled by the registry
-extern int registry_request_access_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *name, time_t when);
-extern int registry_request_delete_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
-extern int registry_request_search_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *request_machine, time_t when);
-extern int registry_request_switch_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *new_person_guid, time_t when);
-extern int registry_request_hello_json(RRDHOST *host, struct web_client *w);
+int registry_request_access_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *name, time_t when);
+int registry_request_delete_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
+int registry_request_search_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *request_machine, time_t when);
+int registry_request_switch_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *new_person_guid, time_t when);
+int registry_request_hello_json(RRDHOST *host, struct web_client *w);
// update the registry config
-extern void registry_update_cloud_base_url();
+void registry_update_cloud_base_url();
// update the registry monitoring charts
-extern void registry_statistics(void);
+void registry_statistics(void);
-extern char *registry_get_this_machine_guid(void);
-extern char *registry_get_mgmt_api_key(void);
-extern char *registry_get_this_machine_hostname(void);
+char *registry_get_this_machine_guid(void);
+char *registry_get_mgmt_api_key(void);
+char *registry_get_this_machine_hostname(void);
-extern int regenerate_guid(const char *guid, char *result);
+int regenerate_guid(const char *guid, char *result);
#endif /* NETDATA_REGISTRY_H */
diff --git a/registry/registry_db.c b/registry/registry_db.c
index db53ff7e0..ae74aa530 100644
--- a/registry/registry_db.c
+++ b/registry/registry_db.c
@@ -11,9 +11,7 @@ int registry_db_should_be_saved(void) {
// ----------------------------------------------------------------------------
// INTERNAL FUNCTIONS FOR SAVING REGISTRY OBJECTS
-static int registry_machine_save_url(const char *name, void *entry, void *file) {
- (void)name;
-
+static int registry_machine_save_url(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *file) {
REGISTRY_MACHINE_URL *mu = entry;
FILE *fp = file;
@@ -32,8 +30,7 @@ static int registry_machine_save_url(const char *name, void *entry, void *file)
return ret;
}
-static int registry_machine_save(const char *name, void *entry, void *file) {
- (void)name;
+static int registry_machine_save(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *file) {
REGISTRY_MACHINE *m = entry;
FILE *fp = file;
@@ -79,9 +76,7 @@ static inline int registry_person_save_url(void *entry, void *file) {
return ret;
}
-static inline int registry_person_save(const char *name, void *entry, void *file) {
- (void)name;
-
+static inline int registry_person_save(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *file) {
REGISTRY_PERSON *p = entry;
FILE *fp = file;
diff --git a/registry/registry_init.c b/registry/registry_init.c
index bae2ac5c5..ba4250ef3 100644
--- a/registry/registry_init.c
+++ b/registry/registry_init.c
@@ -76,8 +76,8 @@ int registry_init(void) {
netdata_mutex_init(&registry.lock);
// create dictionaries
- registry.persons = dictionary_create(REGISTRY_DICTIONARY_FLAGS);
- registry.machines = dictionary_create(REGISTRY_DICTIONARY_FLAGS);
+ registry.persons = dictionary_create(REGISTRY_DICTIONARY_OPTIONS);
+ registry.machines = dictionary_create(REGISTRY_DICTIONARY_OPTIONS);
avl_init(&registry.registry_urls_root_index, registry_url_compare);
// load the registry database
@@ -93,9 +93,7 @@ int registry_init(void) {
return 0;
}
-static int machine_urls_delete_callback(const char *name, void *entry, void *data) {
- (void)name;
-
+static int machine_urls_delete_callback(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *data) {
REGISTRY_MACHINE *m = (REGISTRY_MACHINE *)data;
(void)m;
@@ -110,10 +108,7 @@ static int machine_urls_delete_callback(const char *name, void *entry, void *dat
return 1;
}
-static int machine_delete_callback(const char *name, void *entry, void *data) {
- (void)name;
- (void)data;
-
+static int machine_delete_callback(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *data __maybe_unused) {
REGISTRY_MACHINE *m = (REGISTRY_MACHINE *)entry;
int ret = dictionary_walkthrough_read(m->machine_urls, machine_urls_delete_callback, m);
@@ -122,10 +117,7 @@ static int machine_delete_callback(const char *name, void *entry, void *data) {
return ret + 1;
}
-static int registry_person_del_callback(const char *name, void *entry, void *d) {
- (void)name;
- (void)d;
-
+static int registry_person_del_callback(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *d __maybe_unused) {
REGISTRY_PERSON *p = (REGISTRY_PERSON *)entry;
debug(D_REGISTRY, "Registry: registry_person_del('%s'): deleting person", p->guid);
diff --git a/registry/registry_internals.h b/registry/registry_internals.h
index 9e0f11477..3456d788d 100644
--- a/registry/registry_internals.h
+++ b/registry/registry_internals.h
@@ -8,7 +8,7 @@
#define REGISTRY_URL_FLAGS_DEFAULT 0x00
#define REGISTRY_URL_FLAGS_EXPIRED 0x01
-#define REGISTRY_DICTIONARY_FLAGS (DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE | DICTIONARY_FLAG_NAME_LINK_DONT_CLONE | DICTIONARY_FLAG_SINGLE_THREADED)
+#define REGISTRY_DICTIONARY_OPTIONS (DICT_OPTION_VALUE_LINK_DONT_CLONE | DICT_OPTION_NAME_LINK_DONT_CLONE | DICT_OPTION_SINGLE_THREADED)
// ----------------------------------------------------------------------------
// COMMON structures
@@ -71,20 +71,20 @@ struct registry {
extern struct registry registry;
// REGISTRY LOW-LEVEL REQUESTS (in registry-internals.c)
-extern REGISTRY_PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url, char *name, time_t when);
-extern REGISTRY_PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
-extern REGISTRY_MACHINE *registry_request_machine(char *person_guid, char *machine_guid, char *url, char *request_machine, time_t when);
+REGISTRY_PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url, char *name, time_t when);
+REGISTRY_PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
+REGISTRY_MACHINE *registry_request_machine(char *person_guid, char *machine_guid, char *url, char *request_machine, time_t when);
// REGISTRY LOG (in registry_log.c)
-extern void registry_log(char action, REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name);
-extern int registry_log_open(void);
-extern void registry_log_close(void);
-extern void registry_log_recreate(void);
-extern ssize_t registry_log_load(void);
+void registry_log(char action, REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name);
+int registry_log_open(void);
+void registry_log_close(void);
+void registry_log_recreate(void);
+ssize_t registry_log_load(void);
// REGISTRY DB (in registry_db.c)
-extern int registry_db_save(void);
-extern size_t registry_db_load(void);
-extern int registry_db_should_be_saved(void);
+int registry_db_save(void);
+size_t registry_db_load(void);
+int registry_db_should_be_saved(void);
#endif //NETDATA_REGISTRY_INTERNALS_H_H
diff --git a/registry/registry_machine.c b/registry/registry_machine.c
index fb345aea2..414cd16d9 100644
--- a/registry/registry_machine.c
+++ b/registry/registry_machine.c
@@ -25,9 +25,9 @@ REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, REGISTR
debug(D_REGISTRY, "registry_machine_url_allocate('%s', '%s'): indexing URL in machine", m->guid, u->url);
- registry.machines_urls_memory -= dictionary_stats_allocated_memory(m->machine_urls);
+ registry.machines_urls_memory -= dictionary_stats_for_registry(m->machine_urls);
dictionary_set(m->machine_urls, u->url, mu, sizeof(REGISTRY_MACHINE_URL));
- registry.machines_urls_memory += dictionary_stats_allocated_memory(m->machine_urls);
+ registry.machines_urls_memory += dictionary_stats_for_registry(m->machine_urls);
registry_url_link(u);
@@ -42,7 +42,7 @@ REGISTRY_MACHINE *registry_machine_allocate(const char *machine_guid, time_t whe
strncpyz(m->guid, machine_guid, GUID_LEN);
debug(D_REGISTRY, "Registry: registry_machine_allocate('%s'): creating dictionary of urls", machine_guid);
- m->machine_urls = dictionary_create(REGISTRY_DICTIONARY_FLAGS);
+ m->machine_urls = dictionary_create(REGISTRY_DICTIONARY_OPTIONS);
m->first_t = m->last_t = (uint32_t)when;
m->usages = 0;
@@ -50,9 +50,9 @@ REGISTRY_MACHINE *registry_machine_allocate(const char *machine_guid, time_t whe
registry.machines_memory += sizeof(REGISTRY_MACHINE);
registry.machines_count++;
- registry.machines_urls_memory -= dictionary_stats_allocated_memory(m->machine_urls);
+ registry.machines_urls_memory -= dictionary_stats_for_registry(m->machine_urls);
dictionary_set(registry.machines, m->guid, m, sizeof(REGISTRY_MACHINE));
- registry.machines_urls_memory += dictionary_stats_allocated_memory(m->machine_urls);
+ registry.machines_urls_memory += dictionary_stats_for_registry(m->machine_urls);
return m;
}
diff --git a/registry/registry_machine.h b/registry/registry_machine.h
index 77ab5aaf5..bc95ecf69 100644
--- a/registry/registry_machine.h
+++ b/registry/registry_machine.h
@@ -34,10 +34,10 @@ struct registry_machine {
};
typedef struct registry_machine REGISTRY_MACHINE;
-extern REGISTRY_MACHINE *registry_machine_find(const char *machine_guid);
-extern REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, REGISTRY_URL *u, time_t when);
-extern REGISTRY_MACHINE *registry_machine_allocate(const char *machine_guid, time_t when);
-extern REGISTRY_MACHINE *registry_machine_get(const char *machine_guid, time_t when);
-extern REGISTRY_MACHINE_URL *registry_machine_link_to_url(REGISTRY_MACHINE *m, REGISTRY_URL *u, time_t when);
+REGISTRY_MACHINE *registry_machine_find(const char *machine_guid);
+REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, REGISTRY_URL *u, time_t when);
+REGISTRY_MACHINE *registry_machine_allocate(const char *machine_guid, time_t when);
+REGISTRY_MACHINE *registry_machine_get(const char *machine_guid, time_t when);
+REGISTRY_MACHINE_URL *registry_machine_link_to_url(REGISTRY_MACHINE *m, REGISTRY_URL *u, time_t when);
#endif //NETDATA_REGISTRY_MACHINE_H
diff --git a/registry/registry_person.h b/registry/registry_person.h
index 556c426f7..674596be6 100644
--- a/registry/registry_person.h
+++ b/registry/registry_person.h
@@ -42,20 +42,20 @@ struct registry_person {
typedef struct registry_person REGISTRY_PERSON;
// PERSON_URL
-extern REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, const char *url);
-extern REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) NEVERNULL WARNUNUSED;
-extern REGISTRY_PERSON_URL *registry_person_url_index_del(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) WARNUNUSED;
+REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, const char *url);
+REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) NEVERNULL WARNUNUSED;
+REGISTRY_PERSON_URL *registry_person_url_index_del(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) WARNUNUSED;
-extern REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when);
-extern REGISTRY_PERSON_URL *registry_person_url_reallocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when, REGISTRY_PERSON_URL *pu);
+REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when);
+REGISTRY_PERSON_URL *registry_person_url_reallocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when, REGISTRY_PERSON_URL *pu);
// PERSON
-extern REGISTRY_PERSON *registry_person_find(const char *person_guid);
-extern REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when);
-extern REGISTRY_PERSON *registry_person_get(const char *person_guid, time_t when);
+REGISTRY_PERSON *registry_person_find(const char *person_guid);
+REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when);
+REGISTRY_PERSON *registry_person_get(const char *person_guid, time_t when);
// LINKING PERSON -> PERSON_URL
-extern REGISTRY_PERSON_URL *registry_person_link_to_url(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when);
-extern void registry_person_unlink_from_url(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu);
+REGISTRY_PERSON_URL *registry_person_link_to_url(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when);
+void registry_person_unlink_from_url(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu);
#endif //NETDATA_REGISTRY_PERSON_H
diff --git a/registry/registry_url.h b/registry/registry_url.h
index 0cc364fdf..8ba0391bc 100644
--- a/registry/registry_url.h
+++ b/registry/registry_url.h
@@ -23,13 +23,13 @@ struct registry_url {
typedef struct registry_url REGISTRY_URL;
// REGISTRY_URL INDEX
-extern int registry_url_compare(void *a, void *b);
-extern REGISTRY_URL *registry_url_index_del(REGISTRY_URL *u) WARNUNUSED;
-extern REGISTRY_URL *registry_url_index_add(REGISTRY_URL *u) NEVERNULL WARNUNUSED;
+int registry_url_compare(void *a, void *b);
+REGISTRY_URL *registry_url_index_del(REGISTRY_URL *u) WARNUNUSED;
+REGISTRY_URL *registry_url_index_add(REGISTRY_URL *u) NEVERNULL WARNUNUSED;
// REGISTRY_URL MANAGEMENT
-extern REGISTRY_URL *registry_url_get(const char *url, size_t urllen) NEVERNULL;
-extern void registry_url_link(REGISTRY_URL *u);
-extern void registry_url_unlink(REGISTRY_URL *u);
+REGISTRY_URL *registry_url_get(const char *url, size_t urllen) NEVERNULL;
+void registry_url_link(REGISTRY_URL *u);
+void registry_url_unlink(REGISTRY_URL *u);
#endif //NETDATA_REGISTRY_URL_H