diff options
author | vkalintiris <vasilis@netdata.cloud> | 2023-07-26 15:30:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 15:30:49 +0300 |
commit | 440bd51e08fdfa2a4daa191fb68643456028a753 (patch) | |
tree | 1d2cc2b0afc24b6b77f95f2cf3a1bdbaa544e278 /collectors/plugins.d | |
parent | 3829b4c48ade535aa2d0a1153d45b49184b27a4b (diff) |
Refactor RRD code. (#15423)
* Storage engine.
* Host indexes to rrdb
* Move globals to rrdb
* Move storage_tiers_backfill to rrdb
* default_rrd_update_every to rrdb
* default_rrd_history_entries to rrdb
* gap_when_lost_iterations_above to rrdb
* rrdset_free_obsolete_time_s to rrdb
* libuv_worker_threads to rrdb
* ieee754_doubles to rrdb
* rrdhost_free_orphan_time_s to rrdb
* rrd_rwlock to rrdb
* localhost to rrdb
* rm extern from func decls
* mv rrd macro under rrd.h
* default_rrdeng_page_cache_mb to rrdb
* default_rrdeng_extent_cache_mb to rrdb
* db_engine_journal_check to rrdb
* default_rrdeng_disk_quota_mb to rrdb
* default_multidb_disk_quota_mb to rrdb
* multidb_ctx to rrdb
* page_type_size to rrdb
* tier_page_size to rrdb
* No storage_engine_id in rrdim functions
* storage_engine_id is provided by st
* Update to fix merge conflict.
* Update field name
* Remove unnecessary macros from rrd.h
* Rm unused type decls
* Rm duplicate func decls
* make internal function static
* Make the rest of public dbengine funcs accept a storage_instance.
* No more rrdengine_instance :)
* rm rrdset_debug from rrd.h
* Use rrdb to access globals in ML and ACLK
Missed due to not having the submodules in the
worktree.
* rm total_number
* rm RRDVAR_TYPE_TOTAL
* rm unused inline
* Rm names from typedef'd enums
* rm unused header include
* Move include
* Rm unused header include
* s/rrdhost_find_or_create/rrdhost_get_or_create/g
* s/find_host_by_node_id/rrdhost_find_by_node_id/
Also, remove duplicate definition in rrdcontext.c
* rm macro used only once
* rm macro used only once
* Reduce rrd.h api by moving funcs into a collector specific utils header
* Remove unused func
* Move parser specific function out of rrd.h
* return storage_number instead of void pointer
* move code related to rrd initialization out of rrdhost.c
* Remove tier_grouping from rrdim_tier
Saves 8 * storage_tiers bytes per dimension.
* Fix rebase
* s/rrd_update_every/update_every/
* Mark functions as static and constify args
* Add license notes and file to build systems.
* Remove remaining non-log/config mentions of memory mode
* Move rrdlabels api to separate file.
Also, move localhost functions that loads
labels outside of database/ and into daemon/
* Remove function decl in rrd.h
* merge rrdhost_cache_dir_for_rrdset_alloc into rrdset_cache_dir
* Do not expose internal function from rrd.h
* Rm NETDATA_RRD_INTERNALS
Only one function decl is covered. We have more
database internal functions that we currently
expose for no good reason. These will be placed
in a separate internal header in follow up PRs.
* Add license note
* Include libnetdata.h instead of aral.h
* Use rrdb to access localhost
* Fix builds without dbengine
* Add header to build system files
* Add rrdlabels.h to build systems
* Move func def from rrd.h to rrdhost.c
* Fix macos build
* Rm non-existing function
* Rebase master
* Define buffer length macro in ad_charts.
* Fix FreeBSD builds.
* Mark functions static
* Rm func decls without definitions
* Rebase master
* Rebase master
* Properly initialize value of storage tiers.
* Fix build after rebase.
Diffstat (limited to 'collectors/plugins.d')
-rw-r--r-- | collectors/plugins.d/local_listeners.c | 2 | ||||
-rw-r--r-- | collectors/plugins.d/plugins_d.c | 4 | ||||
-rw-r--r-- | collectors/plugins.d/pluginsd_parser.c | 41 |
3 files changed, 38 insertions, 9 deletions
diff --git a/collectors/plugins.d/local_listeners.c b/collectors/plugins.d/local_listeners.c index a39de79748..159b25f8a4 100644 --- a/collectors/plugins.d/local_listeners.c +++ b/collectors/plugins.d/local_listeners.c @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + #include "libnetdata/libnetdata.h" #include "libnetdata/required_dummies.h" diff --git a/collectors/plugins.d/plugins_d.c b/collectors/plugins.d/plugins_d.c index 6a235b4e62..1e9d71ee1a 100644 --- a/collectors/plugins.d/plugins_d.c +++ b/collectors/plugins.d/plugins_d.c @@ -288,11 +288,11 @@ void *pluginsd_main(void *ptr) strncpyz(cd->filename, file->d_name, FILENAME_MAX); snprintfz(cd->fullfilename, FILENAME_MAX, "%s/%s", directory_name, cd->filename); - cd->host = localhost; + cd->host = rrdb.localhost; cd->unsafe.enabled = enabled; cd->unsafe.running = false; - cd->update_every = (int)config_get_number(cd->id, "update every", localhost->rrd_update_every); + cd->update_every = (int)config_get_number(cd->id, "update every", rrdb.localhost->update_every); cd->started_t = now_realtime_sec(); char *def = ""; diff --git a/collectors/plugins.d/pluginsd_parser.c b/collectors/plugins.d/pluginsd_parser.c index cda17710c5..e8189d67e2 100644 --- a/collectors/plugins.d/pluginsd_parser.c +++ b/collectors/plugins.d/pluginsd_parser.c @@ -204,7 +204,7 @@ static inline RRDSET *pluginsd_find_chart(RRDHOST *host, const char *chart, cons return NULL; } - RRDSET *st = rrdset_find(host, chart); + RRDSET *st = rrdset_find_by_id(host, chart); if (unlikely(!st)) netdata_log_error("PLUGINSD: 'host:%s/chart:%s' got a %s but chart does not exist.", rrdhost_hostname(host), chart, cmd); @@ -375,11 +375,38 @@ static inline PARSER_RC pluginsd_host_labels(char **words, size_t num_words, PAR PLUGINSD_KEYWORD_HOST_LABEL); } +static struct rrdhost_system_info *labels_to_system_info(DICTIONARY *labels) { + struct rrdhost_system_info *info = callocz(1, sizeof(struct rrdhost_system_info)); + info->hops = 1; + + rrdlabels_get_value_strdup_or_null(labels, &info->cloud_provider_type, "_cloud_provider_type"); + rrdlabels_get_value_strdup_or_null(labels, &info->cloud_instance_type, "_cloud_instance_type"); + rrdlabels_get_value_strdup_or_null(labels, &info->cloud_instance_region, "_cloud_instance_region"); + rrdlabels_get_value_strdup_or_null(labels, &info->host_os_name, "_os_name"); + rrdlabels_get_value_strdup_or_null(labels, &info->host_os_version, "_os_version"); + rrdlabels_get_value_strdup_or_null(labels, &info->kernel_version, "_kernel_version"); + rrdlabels_get_value_strdup_or_null(labels, &info->host_cores, "_system_cores"); + rrdlabels_get_value_strdup_or_null(labels, &info->host_cpu_freq, "_system_cpu_freq"); + rrdlabels_get_value_strdup_or_null(labels, &info->host_ram_total, "_system_ram_total"); + rrdlabels_get_value_strdup_or_null(labels, &info->host_disk_space, "_system_disk_space"); + rrdlabels_get_value_strdup_or_null(labels, &info->architecture, "_architecture"); + rrdlabels_get_value_strdup_or_null(labels, &info->virtualization, "_virtualization"); + rrdlabels_get_value_strdup_or_null(labels, &info->container, "_container"); + rrdlabels_get_value_strdup_or_null(labels, &info->container_detection, "_container_detection"); + rrdlabels_get_value_strdup_or_null(labels, &info->virt_detection, "_virt_detection"); + rrdlabels_get_value_strdup_or_null(labels, &info->is_k8s_node, "_is_k8s_node"); + rrdlabels_get_value_strdup_or_null(labels, &info->install_type, "_install_type"); + rrdlabels_get_value_strdup_or_null(labels, &info->prebuilt_arch, "_prebuilt_arch"); + rrdlabels_get_value_strdup_or_null(labels, &info->prebuilt_dist, "_prebuilt_dist"); + + return info; +} + static inline PARSER_RC pluginsd_host_define_end(char **words __maybe_unused, size_t num_words __maybe_unused, PARSER *parser) { if(!parser->user.host_define.parsing_host) return PLUGINSD_DISABLE_PLUGIN(parser, PLUGINSD_KEYWORD_HOST_DEFINE_END, "missing initialization, send " PLUGINSD_KEYWORD_HOST_DEFINE " before this"); - RRDHOST *host = rrdhost_find_or_create( + RRDHOST *host = rrdhost_get_or_create( string2str(parser->user.host_define.hostname), string2str(parser->user.host_define.hostname), parser->user.host_define.machine_guid_str, @@ -390,9 +417,9 @@ static inline PARSER_RC pluginsd_host_define_end(char **words __maybe_unused, si NULL, program_name, program_version, - default_rrd_update_every, - default_rrd_history_entries, - default_rrd_memory_mode, + rrdb.default_update_every, + rrdb.default_rrd_history_entries, + default_storage_engine_id, default_health_enabled, default_rrdpush_enabled, default_rrdpush_destination, @@ -401,7 +428,7 @@ static inline PARSER_RC pluginsd_host_define_end(char **words __maybe_unused, si default_rrdpush_enable_replication, default_rrdpush_seconds_to_replicate, default_rrdpush_replication_step, - rrdhost_labels_to_system_info(parser->user.host_define.rrdlabels), + labels_to_system_info(parser->user.host_define.rrdlabels), false ); @@ -431,7 +458,7 @@ static inline PARSER_RC pluginsd_host(char **words, size_t num_words, PARSER *pa char *guid = get_word(words, num_words, 1); if(!guid || !*guid || strcmp(guid, "localhost") == 0) { - parser->user.host = localhost; + parser->user.host = rrdb.localhost; return PARSER_RC_OK; } |