Projects
openEuler:24.03
rsyslog
_service:tar_scm:print-main-queue-info-to-journ...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:print-main-queue-info-to-journal-when-receive-USR1-signal.patch of Package rsyslog
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 V-2: add macro control for systemd/sd-journal.h V-3: adapt pMsgQueue to runConf->pMsgQueue Signed-off-by: wangshouping <wangshouping@huawei.com> Signed-off-by: pengyi37 <pengyi37@huawei.com> --- tools/rsyslogd.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c index d27a2a7..6aa81b8 100644 --- a/tools/rsyslogd.c +++ b/tools/rsyslogd.c @@ -37,6 +37,7 @@ #endif #ifdef HAVE_LIBSYSTEMD # include <systemd/sd-daemon.h> +#include <systemd/sd-journal.h> #endif #ifdef ENABLE_LIBCAPNG #include <cap-ng.h> @@ -189,6 +190,9 @@ static pthread_mutex_t mutChildDied; static int bChildDied = 0; static pthread_mutex_t mutHadHUP; static int bHadHUP; +#ifdef HAVE_LIBSYSTEMD +static int g_bRecordQueue; +#endif 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 @@ -1377,6 +1381,12 @@ rsyslogdDebugSwitch(void) } } +#ifdef HAVE_LIBSYSTEMD +static void RsyslogdDebugQueue(void) +{ + g_bRecordQueue = 1; +} +#endif /* This is the main entry point into rsyslogd. Over time, we should try to * modularize it a bit more... @@ -1798,7 +1808,11 @@ initAll(int argc, char **argv) hdlr_enable(SIGINT, rsyslogdDoDie); hdlr_enable(SIGQUIT, rsyslogdDoDie); } else { +#ifdef HAVE_LIBSYSTEMD + hdlr_enable(SIGUSR1, RsyslogdDebugQueue); +#else hdlr_enable(SIGUSR1, SIG_IGN); +#endif hdlr_enable(SIGINT, SIG_IGN); hdlr_enable(SIGQUIT, SIG_IGN); } @@ -2143,6 +2157,9 @@ mainloop(void) sigaddset(&sigblockset, SIGTERM); sigaddset(&sigblockset, SIGCHLD); sigaddset(&sigblockset, SIGHUP); +#ifdef HAVE_LIBSYSTEMD + sigaddset(&sigblockset, SIGUSR1); +#endif do { pthread_sigmask(SIG_BLOCK, &sigblockset, &origmask); @@ -2174,6 +2191,18 @@ mainloop(void) processImInternal(); +#ifdef HAVE_LIBSYSTEMD + if (g_bRecordQueue) { + if (runConf->pMsgQueue != NULL) { + sd_journal_print(LOG_NOTICE, "main queue size information: current QueueSize=%d MaxQueueSize=%d\n", + runConf->pMsgQueue->iQueueSize, runConf->pMsgQueue->iMaxQueueSize); + } else { + sd_journal_print(LOG_NOTICE, "main queue size information: pMsgQueue is NULL!\n"); + } + g_bRecordQueue = 0; + } +#endif + if(bFinished) break; /* exit as quickly as possible */ -- 2.27.0
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