change patch and update timezone when restart rsyslog
This commit is contained in:
parent
0ce02fadb4
commit
34bbbd2e9e
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
umask 0077
|
||||
LOCK_FILE=/var/lock/os_check_timezone_change.lock
|
||||
exec 200<>$LOCK_FILE
|
||||
flock -nx 200
|
||||
|
||||
77
print-main-queue-info-to-journal-when-queue-full.patch
Normal file
77
print-main-queue-info-to-journal-when-queue-full.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From 27ee1b988a465e5f89e8a9234f4a01c34cab4387 Mon Sep 17 00:00:00 2001
|
||||
From: wangshouping <wangshouping@huawei.com>
|
||||
Date: Mon, 27 Apr 2020 08:53:18 -0400
|
||||
Subject: [PATCH] print main queue info to journal when queue full
|
||||
Signed-off-by: wangshouping <wangshouping@huawei.com>
|
||||
---
|
||||
runtime/queue.c | 27 +++++++++++++++++++++++++++
|
||||
1 files changed, 45 insertions(+), 1 deletion(-)
|
||||
diff --git a/runtime/queue.c b/runtime/queue.c
|
||||
index e988e44..9faf5aa 100644
|
||||
--- a/runtime/queue.c
|
||||
+++ b/runtime/queue.c
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/vfs.h>
|
||||
+#include <systemd/sd-journal.h>
|
||||
|
||||
#include "rsyslog.h"
|
||||
#include "queue.h"
|
||||
@@ -116,6 +117,14 @@ rsRetVal qqueueSetSpoolDir(qqueue_t *pThis, uchar *pszSpoolDir, int lenSpoolDir)
|
||||
/* some constants for queuePersist () */
|
||||
#define QUEUE_CHECKPOINT 1
|
||||
#define QUEUE_NO_CHECKPOINT 0
|
||||
+#define TIME_OUT 300
|
||||
+#define TIMEOUT_ENQUEUE_ZERO 1
|
||||
+#define TIMEOUT_ENQUEUE_NONZERO 2
|
||||
+
|
||||
+struct timespec g_lastTime = {
|
||||
+ .tv_sec = 0,
|
||||
+ .tv_nsec = 0,
|
||||
+};
|
||||
|
||||
/* tables for interfacing with the v6 config system */
|
||||
static struct cnfparamdescr cnfpdescr[] = {
|
||||
@@ -2985,6 +2992,24 @@ finalize_it:
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
+void PrintQueueFullLog(qqueue_t *pThis, int flag)
|
||||
+{
|
||||
+ struct timespec timeNow;
|
||||
+
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &timeNow);
|
||||
+ if (timeNow.tv_sec - g_lastTime.tv_sec > TIME_OUT) {
|
||||
+ if (flag == TIMEOUT_ENQUEUE_ZERO) {
|
||||
+ sd_journal_print(LOG_NOTICE, "doEnqSingleObject: queue FULL - configured for immediate "
|
||||
+ "discarding QueueSize=%d MaxQueueSize=%d sizeOnDisk=%lld "
|
||||
+ "sizeOnDiskMax=%lld\n", pThis->iQueueSize, pThis->iMaxQueueSize,
|
||||
+ pThis->tVars.disk.sizeOnDisk, pThis->sizeOnDiskMax);
|
||||
+ } else if (flag == TIMEOUT_ENQUEUE_NONZERO) {
|
||||
+ sd_journal_print(LOG_NOTICE, "doEnqSingleObject: queue FULL, iQueueSize=%d MaxQueueSize=%d - waiting %dms to drain.\n",
|
||||
+ pThis->iQueueSize, pThis->iMaxQueueSize, pThis->toEnq);
|
||||
+ }
|
||||
+ g_lastTime.tv_sec = timeNow.tv_sec;
|
||||
+ }
|
||||
+}
|
||||
|
||||
/* enqueue a single data object.
|
||||
* Note that the queue mutex MUST already be locked when this function is called.
|
||||
@@ -3082,12 +3107,14 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, smsg_t *pMsg)
|
||||
"discarding QueueSize=%d MaxQueueSize=%d sizeOnDisk=%lld "
|
||||
"sizeOnDiskMax=%lld\n", pThis->iQueueSize, pThis->iMaxQueueSize,
|
||||
pThis->tVars.disk.sizeOnDisk, pThis->sizeOnDiskMax);
|
||||
+ PrintQueueFullLog(pThis, TIMEOUT_ENQUEUE_ZERO);
|
||||
STATSCOUNTER_INC(pThis->ctrFDscrd, pThis->mutCtrFDscrd);
|
||||
msgDestruct(&pMsg);
|
||||
ABORT_FINALIZE(RS_RET_QUEUE_FULL);
|
||||
} else {
|
||||
DBGOPRINT((obj_t*) pThis, "doEnqSingleObject: queue FULL - waiting %dms to drain.\n",
|
||||
pThis->toEnq);
|
||||
+ PrintQueueFullLog(pThis, TIMEOUT_ENQUEUE_NONZERO);
|
||||
if(glbl.GetGlobalInputTermState()) {
|
||||
DBGOPRINT((obj_t*) pThis, "doEnqSingleObject: queue FULL, discard due to "
|
||||
"FORCE_TERM.\n");
|
||||
--
|
||||
2.19.1
|
||||
@ -0,0 +1,77 @@
|
||||
From 27ee1b988a465e5f89e8a9234f4a01c34cab4387 Mon Sep 17 00:00:00 2001
|
||||
From: wangshouping <wangshouping@huawei.com>
|
||||
Date: Mon, 27 Apr 2020 08:53:18 -0400
|
||||
Subject: [PATCH] print main queue info to journal when receive USR1 signal
|
||||
Signed-off-by: wangshouping <wangshouping@huawei.com>
|
||||
---
|
||||
tools/rsyslogd.c | 19 ++++++++++++++++++-
|
||||
1 files changed, 45 insertions(+), 1 deletion(-)
|
||||
diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c
|
||||
index 7832693..ad92b20 100644
|
||||
--- a/tools/rsyslogd.c
|
||||
+++ b/tools/rsyslogd.c
|
||||
@@ -38,6 +38,7 @@
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
# include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
+#include <systemd/sd-journal.h>
|
||||
|
||||
#include "rsyslog.h"
|
||||
#include "wti.h"
|
||||
@@ -181,6 +182,7 @@ void rsyslogdDoDie(int sig);
|
||||
/* global data items */
|
||||
static int bChildDied;
|
||||
static int bHadHUP;
|
||||
+static int g_bRecordQueue;
|
||||
static int doFork = 1; /* fork - run in daemon mode - read-only after startup */
|
||||
int bFinished = 0; /* used by termination signal handler, read-only except there
|
||||
* is either 0 or the number of the signal that requested the
|
||||
@@ -1267,8 +1269,13 @@ rsyslogdDebugSwitch(void)
|
||||
dbgprintf("\n");
|
||||
debugging_on = 0;
|
||||
}
|
||||
+
|
||||
}
|
||||
|
||||
+static void RsyslogdDebugQueue(void)
|
||||
+{
|
||||
+ g_bRecordQueue = 1;
|
||||
+}
|
||||
|
||||
/* This is the main entry point into rsyslogd. Over time, we should try to
|
||||
* modularize it a bit more...
|
||||
@@ -1616,7 +1623,7 @@ initAll(int argc, char **argv)
|
||||
hdlr_enable(SIGINT, rsyslogdDoDie);
|
||||
hdlr_enable(SIGQUIT, rsyslogdDoDie);
|
||||
} else {
|
||||
- hdlr_enable(SIGUSR1, SIG_IGN);
|
||||
+ hdlr_enable(SIGUSR1, RsyslogdDebugQueue);
|
||||
hdlr_enable(SIGINT, SIG_IGN);
|
||||
hdlr_enable(SIGQUIT, SIG_IGN);
|
||||
}
|
||||
@@ -1953,6 +1960,7 @@ mainloop(void)
|
||||
sigaddset(&sigblockset, SIGTERM);
|
||||
sigaddset(&sigblockset, SIGCHLD);
|
||||
sigaddset(&sigblockset, SIGHUP);
|
||||
+ sigaddset(&sigblockset, SIGUSR1);
|
||||
|
||||
do {
|
||||
processImInternal();
|
||||
@@ -1967,6 +1975,15 @@ mainloop(void)
|
||||
doHUP();
|
||||
bHadHUP = 0;
|
||||
}
|
||||
+ if (g_bRecordQueue) {
|
||||
+ if (pMsgQueue != NULL) {
|
||||
+ sd_journal_print(LOG_NOTICE, "main queue size information: current QueueSize=%d MaxQueueSize=%d\n",
|
||||
+ pMsgQueue->iQueueSize, pMsgQueue->iMaxQueueSize);
|
||||
+ } else {
|
||||
+ sd_journal_print(LOG_NOTICE, "main queue size information: pMsgQueue is NULL!\n");
|
||||
+ }
|
||||
+ g_bRecordQueue = 0;
|
||||
+ }
|
||||
|
||||
if(bFinished)
|
||||
break; /* exit as quickly as possible */
|
||||
--
|
||||
2.19.1
|
||||
@ -1,4 +1,4 @@
|
||||
From 9a137580322bd863a48479755aee9c30d0a084e9 Mon Sep 17 00:00:00 2001
|
||||
From 5ce33ba295e9e210aff7cb137998d8490583d516 Mon Sep 17 00:00:00 2001
|
||||
From: wangshouping <wangshouping@huawei.com>
|
||||
Date: Wed, 15 Apr 2020 03:07:55 -0400
|
||||
Subject: [PATCH] rsyslog-8.37.0-initialize-variables-and-check-return-value
|
||||
@ -6,11 +6,10 @@ Subject: [PATCH] rsyslog-8.37.0-initialize-variables-and-check-return-value
|
||||
Signed-off-by: wangshouping <wangshouping@huawei.com>
|
||||
---
|
||||
plugins/imjournal/imjournal.c | 22 +++++++++++++---------
|
||||
tools/rsyslogd.c | 2 +-
|
||||
2 files changed, 14 insertions(+), 10 deletions(-)
|
||||
1 file changed, 13 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c
|
||||
index 3a93b37..1656de7 100644
|
||||
index aa27fe7..c5d3d25 100644
|
||||
--- a/plugins/imjournal/imjournal.c
|
||||
+++ b/plugins/imjournal/imjournal.c
|
||||
@@ -386,7 +386,7 @@ readjournal(void)
|
||||
@ -57,19 +56,5 @@ index 3a93b37..1656de7 100644
|
||||
}else
|
||||
/* submit message */
|
||||
enqMsg((uchar *)message, (uchar *) sys_iden_help, facility, severity, &tv, json, 0);
|
||||
diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c
|
||||
index 6b531b1..7832693 100644
|
||||
--- a/tools/rsyslogd.c
|
||||
+++ b/tools/rsyslogd.c
|
||||
@@ -266,7 +266,7 @@ static rsRetVal
|
||||
writePidFile(void)
|
||||
{
|
||||
FILE *fp;
|
||||
- int fd;
|
||||
+ int fd = -1;
|
||||
DEFiRet;
|
||||
|
||||
const char *tmpPidFile;
|
||||
--
|
||||
2.19.1
|
||||
|
||||
2.27.0
|
||||
|
||||
@ -10,6 +10,7 @@ Documentation=https://www.rsyslog.com/doc/
|
||||
Type=notify
|
||||
EnvironmentFile=-/etc/sysconfig/rsyslog
|
||||
ExecStart=/usr/sbin/rsyslogd -n -i/var/run/rsyslogd.pid $SYSLOGD_OPTIONS
|
||||
ExecStartPost=/bin/bash /usr/bin/timezone_update.sh
|
||||
UMask=0066
|
||||
StandardOutput=null
|
||||
Restart=on-failure
|
||||
|
||||
13
rsyslog.spec
13
rsyslog.spec
@ -4,7 +4,7 @@
|
||||
|
||||
Name: rsyslog
|
||||
Version: 8.2110.0
|
||||
Release: 1
|
||||
Release: 2
|
||||
Summary: The rocket-fast system for log processing
|
||||
License: (GPLv3+ and ASL 2.0)
|
||||
URL: http://www.rsyslog.com/
|
||||
@ -17,12 +17,14 @@ Source5: os_rotate_and_save_log.sh
|
||||
Source6: os_check_timezone_for_rsyslog.sh
|
||||
Source7: timezone.cron
|
||||
Source8: rsyslog.service
|
||||
Source9: timezone_update.sh
|
||||
|
||||
Patch9000: rsyslog-8.24.0-ensure-parent-dir-exists-when-writting-log-file.patch
|
||||
Patch9001: bugfix-rsyslog-7.4.7-imjournal-add-monotonic-timestamp.patch
|
||||
Patch9002: bugfix-rsyslog-7.4.7-add-configuration-to-avoid-memory-leak.patch
|
||||
Patch9003: rsyslog-8.24.0-set-permission-of-syslogd-dot-pid-to-0644.patch
|
||||
Patch9004: rsyslog-8.37.0-initialize-variables-and-check-return-value.patch
|
||||
Patch9003: rsyslog-8.37.0-initialize-variables-and-check-return-value.patch
|
||||
Patch9004: print-main-queue-info-to-journal-when-queue-full.patch
|
||||
Patch9005: print-main-queue-info-to-journal-when-receive-USR1-signal.patch
|
||||
|
||||
BuildRequires: gcc autoconf automake bison dos2unix flex pkgconfig python3-docutils libtool
|
||||
BuildRequires: libgcrypt-devel libuuid-devel zlib-devel krb5-devel libnet-devel gnutls-devel
|
||||
@ -322,6 +324,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/cron.d/
|
||||
install -m 0600 %{_sourcedir}/timezone.cron $RPM_BUILD_ROOT/etc/cron.d/
|
||||
install -m 0500 %{SOURCE5} $RPM_BUILD_ROOT%{_bindir}/os_rotate_and_save_log.sh
|
||||
install -m 0500 %{SOURCE6} $RPM_BUILD_ROOT%{_bindir}/os_check_timezone_for_rsyslog.sh
|
||||
install -m 0500 %{SOURCE8} $RPM_BUILD_ROOT%{_bindir}/timezone_update.sh
|
||||
|
||||
cp -r doc/* $RPM_BUILD_ROOT%{rsyslog_docdir}/html
|
||||
|
||||
@ -357,6 +360,7 @@ done
|
||||
%{_sbindir}/rsyslogd
|
||||
%attr(500,root,root) %{_bindir}/os_rotate_and_save_log.sh
|
||||
%attr(500,root,root) %{_bindir}/os_check_timezone_for_rsyslog.sh
|
||||
%attr(500,root,root) %{_bindir}/timezone_update.sh
|
||||
/etc/cron.d/timezone.cron
|
||||
%{_unitdir}/rsyslog.service
|
||||
%config(noreplace) %{_sysconfdir}/rsyslog.conf
|
||||
@ -472,6 +476,9 @@ done
|
||||
%{_mandir}/man1/rscryutil.1.gz
|
||||
|
||||
%changelog
|
||||
* Thu Feb 17 2022 wuchaochao <cyanrose@yeah.net> - 8.2110.0-2
|
||||
- change patch and update timezone when restart rsyslog
|
||||
|
||||
* Wed Feb 09 2022 wuchaochao <cyanrose@yeah.net> - 8.2110.0-1
|
||||
- update version to 8.2110.0 and move rsyslog-crypto rsyslog-doc rsyslog-elasticsearch rsyslog-mmjsonparse syslog-mm
|
||||
audit rsyslog-mmsnmptrapd rsyslog-mysql syslog-gssapi rsyslog-gnutls rsyslog-updspoof
|
||||
|
||||
4
timezone_update.sh
Normal file
4
timezone_update.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
umask 0066
|
||||
/usr/bin/date +%Z%z > /etc/localtime_tmp
|
||||
Loading…
x
Reference in New Issue
Block a user