diff options
Diffstat (limited to 'src/collectors/systemd-journal.plugin/systemd-journal-annotations.c')
-rw-r--r-- | src/collectors/systemd-journal.plugin/systemd-journal-annotations.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/collectors/systemd-journal.plugin/systemd-journal-annotations.c b/src/collectors/systemd-journal.plugin/systemd-journal-annotations.c index c5b708714..c9ade0a33 100644 --- a/src/collectors/systemd-journal.plugin/systemd-journal-annotations.c +++ b/src/collectors/systemd-journal.plugin/systemd-journal-annotations.c @@ -3,18 +3,6 @@ #include "systemd-internals.h" // ---------------------------------------------------------------------------- -#include "libnetdata/maps/system-users.h" -#include "libnetdata/maps/system-groups.h" - -static struct { - USERNAMES_CACHE *uc; - GROUPNAMES_CACHE *gc; -} systemd_annotations_globals = { - .uc = NULL, - .gc = NULL, -}; - -// ---------------------------------------------------------------------------- const char *errno_map[] = { [1] = "1 (EPERM)", // "Operation not permitted", @@ -369,9 +357,9 @@ void netdata_systemd_journal_transform_uid(FACETS *facets __maybe_unused, BUFFER const char *v = buffer_tostring(wb); if(*v && isdigit(*v)) { uid_t uid = str2i(buffer_tostring(wb)); - STRING *u = system_usernames_cache_lookup_uid(systemd_annotations_globals.uc, uid); - buffer_contents_replace(wb, string2str(u), string_strlen(u)); - string_freez(u); + CACHED_USERNAME cu = cached_username_get_by_uid(uid); + buffer_contents_replace(wb, string2str(cu.username), string_strlen(cu.username)); + cached_username_release(cu); } } @@ -382,9 +370,9 @@ void netdata_systemd_journal_transform_gid(FACETS *facets __maybe_unused, BUFFER const char *v = buffer_tostring(wb); if(*v && isdigit(*v)) { gid_t gid = str2i(buffer_tostring(wb)); - STRING *g = system_groupnames_cache_lookup_gid(systemd_annotations_globals.gc, gid); - buffer_contents_replace(wb, string2str(g), string_strlen(g)); - string_freez(g); + CACHED_GROUPNAME cg = cached_groupname_get_by_gid(gid); + buffer_contents_replace(wb, string2str(cg.groupname), string_strlen(cg.groupname)); + cached_groupname_release(cg); } } @@ -650,8 +638,10 @@ void netdata_systemd_journal_transform_message_id(FACETS *facets __maybe_unused, // ---------------------------------------------------------------------------- void netdata_systemd_journal_annotations_init(void) { - systemd_annotations_globals.uc = system_usernames_cache_init(); - systemd_annotations_globals.gc = system_groupnames_cache_init(); + cached_usernames_init(); + cached_groupnames_init(); + update_cached_host_users(); + update_cached_host_groups(); netdata_systemd_journal_message_ids_init(); } |