summaryrefslogtreecommitdiffstats
path: root/src/collectors/systemd-journal.plugin/systemd-journal-annotations.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 17:33:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 17:34:10 +0000
commit83ba6762cc43d9db581b979bb5e3445669e46cc2 (patch)
tree2e69833b43f791ed253a7a20318b767ebe56cdb8 /src/collectors/systemd-journal.plugin/systemd-journal-annotations.c
parentReleasing debian version 1.47.5-1. (diff)
downloadnetdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.tar.xz
netdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.zip
Merging upstream version 2.0.3+dfsg (Closes: #923993, #1042533, #1045145).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/collectors/systemd-journal.plugin/systemd-journal-annotations.c')
-rw-r--r--src/collectors/systemd-journal.plugin/systemd-journal-annotations.c30
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();
}