Skip to content

Commit 6a7f677

Browse files
Update based on the feedback in Icinga#4956 and Icinga#4818
1 parent 8f614db commit 6a7f677

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

doc/12-icinga2-api.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -901,13 +901,14 @@ are disabled.
901901

902902
Send a `POST` request to the URL endpoint `/v1/actions/acknowledge-problem`.
903903

904-
Parameter | Type | Description
905-
----------|-----------|--------------
906-
author | string | **Required.** Name of the author, may be empty.
907-
comment | string | **Required.** Comment text, may be empty.
908-
expiry | timestamp | **Optional.** If set, the acknowledgement will vanish after this timestamp.
909-
sticky | boolean | **Optional.** If `true`, the default, the acknowledgement will remain until the service or host fully recovers.
910-
notify | boolean | **Optional.** If `true`, a notification will be sent out to contacts to indicate this problem has been acknowledged. The default is false.
904+
Parameter | Type | Description
905+
-----------|-----------|--------------
906+
author | string | **Required.** Name of the author, may be empty.
907+
comment | string | **Required.** Comment text, may be empty.
908+
expiry | timestamp | **Optional.** If set, the acknowledgement will vanish after this timestamp.
909+
sticky | boolean | **Optional.** If `true`, the default, the acknowledgement will remain until the service or host fully recovers.
910+
notify | boolean | **Optional.** If `true`, a notification will be sent out to contacts to indicate this problem has been acknowledged. The default is false.
911+
persistent | boolean | **Optional.** If `true`, the comment will remain after the acknowledgement either recovers or expires.
911912

912913
In addition to these parameters a [filter](12-icinga2-api.md#icinga2-api-filters) must be provided. The valid types for this action are `Host` and `Service`.
913914

lib/icinga/apiactions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Dictionary::Ptr ApiActions::AcknowledgeProblem(const ConfigObject::Ptr& object,
202202
if (params->Contains("notify"))
203203
notify = true;
204204
if (params->Contains("persistent"))
205-
persistent = (Convert::ToLong(HttpUtility::GetLastParameter(params, "persistent")) > 0 ? true : false );
205+
persistent = HttpUtility::GetLastParameter(params, "persistent");
206206
if (params->Contains("expiry"))
207207
timestamp = HttpUtility::GetLastParameter(params, "expiry");
208208
else

lib/icinga/checkable-comment.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ void Checkable::RemoveAllComments(void)
3838
void Checkable::RemoveCommentsByType(int type)
3939
{
4040
for (const Comment::Ptr& comment : GetComments()) {
41-
if (comment->GetEntryType() == type && comment->GetPersistent() == false)
41+
/* Do not remove comments set as persistent when it originates from an Acknowledgement */
42+
if (comment->GetEntryType() == CommentAcknowledgement && comment->GetPersistent())
43+
continue;
44+
45+
if (comment->GetEntryType() == type)
4246
Comment::RemoveComment(comment->GetName());
4347
}
4448
}

lib/icinga/comment.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,12 @@ void Comment::CommentsExpireTimerHandler(void)
248248
}
249249

250250
for (const Comment::Ptr& comment : comments) {
251+
/* Do not remove comments set as persistent when it originates from an Acknowledgement */
252+
if (comment->GetEntryType() == CommentAcknowledgement && comment->IsActive() && comment->IsExpired() && comment->GetPersistent())
253+
continue;
254+
251255
/* Only remove comment which are activated after daemon start. */
252-
if (comment->IsActive() && comment->IsExpired() && comment->GetPersistent() == false)
256+
if (comment->IsActive() && comment->IsExpired())
253257
RemoveComment(comment->GetName());
254258
}
255259
}

lib/icinga/comment.ti

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Comment : ConfigObject < CommentNameComposer
8787
};
8888
[config, required] String author;
8989
[config, required] String text;
90-
[config] int persistent;
90+
[config] bool persistent;
9191
[config] Timestamp expire_time;
9292
[state] int legacy_id;
9393
};

0 commit comments

Comments
 (0)