Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[monit] Adding patch to enhance syslog error message generation for monit alert action when status is failed. #5720

Merged
merged 6 commits into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions src/monit/patch/0002-change_monit_alert_log_error.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From 97a5defc6a7fcc6a00f691bb5314ceb8fb7704e9 Mon Sep 17 00:00:00 2001
From: Abhishek Dosi <[email protected]>
Date: Mon, 26 Oct 2020 11:40:02 -0700
Subject: [PATCH] Patch on top of commit Patch is addressing these changes:-

a) Make sure error message is loggged if state is changed to fail first time based on fault tolerance condition
or we have repeat clause enable for alert.

b) Enable repeat keyword for alert action. Using this we can log
syslog error message for persistent failures in repeat window.

c) Make sure log and error message are different string so that we do not rate
limit error message with log message.

Signed-off-by: Abhishek Dosi <[email protected]>

---
src/event.c | 6 +++++-
src/p.y | 8 +++++++-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/event.c b/src/event.c
index ed363ee..969568f 100644
--- a/src/event.c
+++ b/src/event.c
@@ -336,8 +336,12 @@ static void _handleEvent(Service_T S, Event_T E) {
if (E->state != State_Init || E->state_map & 0x1) {
if (E->state == State_Succeeded || E->state == State_ChangedNot || E->id == Event_Instance || E->id == Event_Action)
LogInfo("'%s' %s\n", S->name, E->message);
- else
+ /* Send Error log if state change to failed for 1st time or if we have repeat clause then do periodically */
+ else if ((E->state_changed) || (E->state == State_Failed && E->action->failed->repeat && E->count % E->action->failed->repeat == 0))
LogError("'%s' %s\n", S->name, E->message);
jleveque marked this conversation as resolved.
Show resolved Hide resolved
+ else
+ /* Here we are making log message different so that we do not rate-limit Err and Info in same bucket*/
+ LogInfo("'%s' %s for information\n", S->name, E->message);
jleveque marked this conversation as resolved.
Show resolved Hide resolved
}
if (E->state == State_Init)
return;
diff --git a/src/p.y b/src/p.y
index a57807d..b46b1a1 100644
--- a/src/p.y
+++ b/src/p.y
@@ -2250,9 +2250,12 @@ repeat : /* EMPTY */ {
}
;

-action : ALERT {
+action : ALERT repeat{
$<number>$ = Action_Alert;
}
+ | ALERT {
+ $<number>$ = Action_Alert;
+ }
| EXEC argumentlist repeat {
$<number>$ = Action_Exec;
}
@@ -2281,6 +2284,9 @@ action1 : action {
repeat = 0;
command1 = command;
command = NULL;
+ } else if ($<number>1 == Action_Alert) {
+ repeat1 = repeat;
+ repeat = 0;
}
}
;
--
2.17.1

1 change: 1 addition & 0 deletions src/monit/patch/series
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# This series applies on GIT commit dc9bc1c949125140d967edfc598dfad47eedc552
0001-used_system_memory_sysdep-Use-MemAvailable-value-if-.patch
0002-change_monit_alert_log_error.patch