Projects
openEuler:24.03
rsyslog
_service:tar_scm:bugfix-rsyslog-7.4.7-imjournal...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:bugfix-rsyslog-7.4.7-imjournal-add-monotonic-timestamp.patch of Package rsyslog
From cb6b411b6d9ca7520b7971c1e3de776dbebe497f Mon Sep 17 00:00:00 2001 From: wangshouping <wangshouping@huawei.com> Date: Wed, 15 Apr 2020 02:57:21 -0400 Subject: [PATCH] bugfix-rsyslog-7.4.7-imjournal-add-monotonic-timestamp Signed-off-by: wangshouping <wangshouping@huawei.com> --- plugins/imjournal/imjournal.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c index cda9b4b..2268018 100644 --- a/plugins/imjournal/imjournal.c +++ b/plugins/imjournal/imjournal.c @@ -447,6 +447,7 @@ readjournal(struct journalContext_s *journalContext, ruleset_t *pBindRuleset) struct timeval tv; uint64_t timestamp; + uint64_t monotonic_timestamp; struct fjson_object *json = NULL; int r; @@ -456,6 +457,9 @@ readjournal(struct journalContext_s *journalContext, ruleset_t *pBindRuleset) char *sys_iden; char *sys_iden_help = NULL; + char *t; + char *tpmessage; + const void *get; const void *pidget; size_t length; @@ -564,8 +568,19 @@ readjournal(struct journalContext_s *journalContext, ruleset_t *pBindRuleset) iRet = updateJournalCursor(journalContext); - /* submit message */ - enqMsg((uchar *)message, (uchar *) sys_iden_help, facility, severity, &tv, json, 0, pBindRuleset); + if (journalGetData(journalContext, "_SOURCE_MONOTONIC_TIMESTAMP", &get, &length) >= 0) + { + t = strndup(get+28, length-28); + monotonic_timestamp = atoll(t); + free(t); + tpmessage = (char *)malloc(strlen(message)+30); + int ret = sprintf(tpmessage,"[%5lu.%06lu] ",monotonic_timestamp/1000000, monotonic_timestamp%1000000); + memcpy(tpmessage+(ret > 30 ? 0 :(ret < 0 ? 0:ret)),message,strlen(message)+1); + enqMsg((uchar *)tpmessage, (uchar *) sys_iden_help, facility, severity, &tv, json, 0, pBindRuleset); + free(tpmessage); + }else + /* submit message */ + enqMsg((uchar *)message, (uchar *) sys_iden_help, facility, severity, &tv, json, 0, pBindRuleset); finalize_it: free(sys_iden_help); -- 2.19.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2