diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-17 10:46:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-17 10:46:15 +0000 |
commit | 0d479e33a8ebe206dc5b62135f90880e54b6c117 (patch) | |
tree | 272c5ddc92ae1e568e6df554e94894ee66a2dfd1 /collectors/systemd-journal.plugin/systemd-journal.c | |
parent | Releasing debian version 1.42.0-1. (diff) | |
download | netdata-0d479e33a8ebe206dc5b62135f90880e54b6c117.tar.xz netdata-0d479e33a8ebe206dc5b62135f90880e54b6c117.zip |
Merging upstream version 1.42.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/systemd-journal.plugin/systemd-journal.c')
-rw-r--r-- | collectors/systemd-journal.plugin/systemd-journal.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/collectors/systemd-journal.plugin/systemd-journal.c b/collectors/systemd-journal.plugin/systemd-journal.c index 08a1891e5..0aaa36044 100644 --- a/collectors/systemd-journal.plugin/systemd-journal.c +++ b/collectors/systemd-journal.plugin/systemd-journal.c @@ -305,14 +305,23 @@ static void systemd_journal_transform_gid(FACETS *facets __maybe_unused, BUFFER } static void systemd_journal_dynamic_row_id(FACETS *facets __maybe_unused, BUFFER *json_array, FACET_ROW_KEY_VALUE *rkv, FACET_ROW *row, void *data __maybe_unused) { - FACET_ROW_KEY_VALUE *syslog_identifier_rkv = dictionary_get(row->dict, "SYSLOG_IDENTIFIER"); FACET_ROW_KEY_VALUE *pid_rkv = dictionary_get(row->dict, "_PID"); + const char *pid = pid_rkv ? buffer_tostring(pid_rkv->wb) : FACET_VALUE_UNSET; + + FACET_ROW_KEY_VALUE *syslog_identifier_rkv = dictionary_get(row->dict, "SYSLOG_IDENTIFIER"); + const char *identifier = syslog_identifier_rkv ? buffer_tostring(syslog_identifier_rkv->wb) : FACET_VALUE_UNSET; - const char *identifier = syslog_identifier_rkv ? buffer_tostring(syslog_identifier_rkv->wb) : "UNKNOWN"; - const char *pid = pid_rkv ? buffer_tostring(pid_rkv->wb) : "UNKNOWN"; + if(strcmp(identifier, FACET_VALUE_UNSET) == 0) { + FACET_ROW_KEY_VALUE *comm_rkv = dictionary_get(row->dict, "_COMM"); + identifier = comm_rkv ? buffer_tostring(comm_rkv->wb) : FACET_VALUE_UNSET; + } buffer_flush(rkv->wb); - buffer_sprintf(rkv->wb, "%s[%s]", identifier, pid); + + if(strcmp(pid, FACET_VALUE_UNSET) == 0) + buffer_strcat(rkv->wb, identifier); + else + buffer_sprintf(rkv->wb, "%s[%s]", identifier, pid); buffer_json_add_array_item_string(json_array, buffer_tostring(rkv->wb)); } @@ -557,7 +566,7 @@ int main(int argc __maybe_unused, char **argv __maybe_unused) { bool tty = isatty(fileno(stderr)) == 1; netdata_mutex_lock(&mutex); - fprintf(stdout, PLUGINSD_KEYWORD_FUNCTION " \"%s\" %d \"%s\"\n", + fprintf(stdout, PLUGINSD_KEYWORD_FUNCTION " GLOBAL \"%s\" %d \"%s\"\n", SYSTEMD_JOURNAL_FUNCTION_NAME, SYSTEMD_JOURNAL_DEFAULT_TIMEOUT, SYSTEMD_JOURNAL_FUNCTION_DESCRIPTION); heartbeat_t hb; |