Skip to content

Commit

Permalink
Update based on the feedback in #4956 and #4818
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFlyingCorpse committed Feb 9, 2017
1 parent 8f614db commit 6a7f677
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
15 changes: 8 additions & 7 deletions doc/12-icinga2-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -901,13 +901,14 @@ are disabled.

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

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

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`.

Expand Down
2 changes: 1 addition & 1 deletion lib/icinga/apiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Dictionary::Ptr ApiActions::AcknowledgeProblem(const ConfigObject::Ptr& object,
if (params->Contains("notify"))
notify = true;
if (params->Contains("persistent"))
persistent = (Convert::ToLong(HttpUtility::GetLastParameter(params, "persistent")) > 0 ? true : false );
persistent = HttpUtility::GetLastParameter(params, "persistent");
if (params->Contains("expiry"))
timestamp = HttpUtility::GetLastParameter(params, "expiry");
else
Expand Down
6 changes: 5 additions & 1 deletion lib/icinga/checkable-comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ void Checkable::RemoveAllComments(void)
void Checkable::RemoveCommentsByType(int type)
{
for (const Comment::Ptr& comment : GetComments()) {
if (comment->GetEntryType() == type && comment->GetPersistent() == false)
/* Do not remove comments set as persistent when it originates from an Acknowledgement */
if (comment->GetEntryType() == CommentAcknowledgement && comment->GetPersistent())
continue;

if (comment->GetEntryType() == type)
Comment::RemoveComment(comment->GetName());
}
}
Expand Down
6 changes: 5 additions & 1 deletion lib/icinga/comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@ void Comment::CommentsExpireTimerHandler(void)
}

for (const Comment::Ptr& comment : comments) {
/* Do not remove comments set as persistent when it originates from an Acknowledgement */
if (comment->GetEntryType() == CommentAcknowledgement && comment->IsActive() && comment->IsExpired() && comment->GetPersistent())
continue;

/* Only remove comment which are activated after daemon start. */
if (comment->IsActive() && comment->IsExpired() && comment->GetPersistent() == false)
if (comment->IsActive() && comment->IsExpired())
RemoveComment(comment->GetName());
}
}
2 changes: 1 addition & 1 deletion lib/icinga/comment.ti
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Comment : ConfigObject < CommentNameComposer
};
[config, required] String author;
[config, required] String text;
[config] int persistent;
[config] bool persistent;
[config] Timestamp expire_time;
[state] int legacy_id;
};
Expand Down

0 comments on commit 6a7f677

Please sign in to comment.