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-queue-full.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 queue full V-2: add macro control for systemd/sd-journal.h Signed-off-by: wangshouping <wangshouping@huawei.com> Signed-off-by: pengyi37 <pengyi37@huawei.com> --- runtime/queue.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/runtime/queue.c b/runtime/queue.c index 3083fb9..6974173 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -47,6 +47,9 @@ #include <errno.h> #include <inttypes.h> #include <sys/vfs.h> +#ifdef HAVE_LIBSYSTEMD +#include <systemd/sd-journal.h> +#endif #include "rsyslog.h" #include "queue.h" @@ -116,6 +119,16 @@ rsRetVal qqueueSetSpoolDir(qqueue_t *pThis, uchar *pszSpoolDir, int lenSpoolDir) /* some constants for queuePersist () */ #define QUEUE_CHECKPOINT 1 #define QUEUE_NO_CHECKPOINT 0 +#ifdef HAVE_LIBSYSTEMD +#define TIME_OUT 300 +#define TIMEOUT_ENQUEUE_ZERO 1 +#define TIMEOUT_ENQUEUE_NONZERO 2 + +struct timespec g_lastTime = { + .tv_sec = 0, + .tv_nsec = 0, +}; +#endif /* tables for interfacing with the v6 config system */ static struct cnfparamdescr cnfpdescr[] = { @@ -3008,7 +3021,27 @@ finalize_it: RETiRet; } +#ifdef HAVE_LIBSYSTEMD +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; + } +} +#endif /* enqueue a single data object. * Note that the queue mutex MUST already be locked when this function is called. * rgerhards, 2009-06-16 @@ -3105,12 +3138,18 @@ 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); +#ifdef HAVE_LIBSYSTEMD + PrintQueueFullLog(pThis, TIMEOUT_ENQUEUE_ZERO); +#endif 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); +#ifdef HAVE_LIBSYSTEMD + PrintQueueFullLog(pThis, TIMEOUT_ENQUEUE_NONZERO); +#endif if(glbl.GetGlobalInputTermState()) { DBGOPRINT((obj_t*) pThis, "doEnqSingleObject: queue FULL, discard due to " "FORCE_TERM.\n"); -- 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