1 Star 0 Fork 38

pengyi37/rsyslog

forked from src-openEuler/rsyslog 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
bugfix-rsyslog-7.4.7-imjournal-add-monotonic-timestamp.patch 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
chengquan 提交于 2020-05-11 15:20 . upgrade software to v8.2002.0
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 29dcec1..3a93b37 100644
--- a/plugins/imjournal/imjournal.c
+++ b/plugins/imjournal/imjournal.c
@@ -386,6 +386,7 @@ readjournal(void)
struct timeval tv;
uint64_t timestamp;
+ uint64_t monotonic_timestamp;
struct fjson_object *json = NULL;
int r;
@@ -395,6 +396,9 @@ readjournal(void)
char *sys_iden;
char *sys_iden_help = NULL;
+ char *t;
+ char *tpmessage;
+
const void *get;
const void *pidget;
size_t length;
@@ -501,8 +505,19 @@ readjournal(void)
iRet = updateJournalCursor();
- /* submit message */
- enqMsg((uchar *)message, (uchar *) sys_iden_help, facility, severity, &tv, json, 0);
+ if (journalGetData("_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);
+ free(tpmessage);
+ }else
+ /* submit message */
+ enqMsg((uchar *)message, (uchar *) sys_iden_help, facility, severity, &tv, json, 0);
finalize_it:
free(sys_iden_help);
--
2.19.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pengyi37/rsyslog.git
git@gitee.com:pengyi37/rsyslog.git
pengyi37
rsyslog
rsyslog
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385