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

Add functionality to place agent in downtime #96

Open
william-sy opened this issue Jul 20, 2022 · 6 comments
Open

Add functionality to place agent in downtime #96

william-sy opened this issue Jul 20, 2022 · 6 comments
Assignees
Labels
feature New feature or request

Comments

@william-sy
Copy link

It would be great to add a feature where a host with all its services or just one service gets placed into downtime for X amount minutes.
This would be great for if the server is not ready yet with all its services while its being setup causing alerts / pages.
Also great for patching or other events that ansible will do with certain services that are monitored like upgrading said service.

@mkayontour
Copy link
Member

Hi do you mean to set downtimes via the API for hosts and services?

@william-sy
Copy link
Author

Hi,
Yes normally you could do something like this:

curl -k  -u user:password -H 'Accept: application/json' \
 -X POST 'https://icinga.internal:5665/v1/actions/schedule-downtime' \
 -d '{ "type": "Service", "filter": "host.name==\"server.internal\" && service.name==\"ping4\"", "start_time": 1592856490, "end_time": 1592866490, "all_services": true, "author": "ansible", "comment": "Patching!", "pretty": true }'

Which works in ansible if you put all kinds of variables there but is not very elegant!

It would be great if there were:

- name: "Place agent into downtime"
  icinga2_downtime:
     host: {{ inventory_hostname }}
     start: {{ some form of date and time }}
     end: {{ some form of date and time }}
     all_service: True/False 
     service: ping4
     comment: "Patching"
     type: flexible/fixed
     child_hosts: None/triggered/non-triggered 
  when: XX
  with_items: XX

@mkayontour
Copy link
Member

I've done something likes this in the past, maybe I can provide an additional module to handle downtimes. But I think it needs some rewriting. If can excerpt the module and provide it in an separate repository before adding it to the collection.

https://github.com/mkayontour/icinga2_ansible_collection/blob/master/plugins/modules/icinga2_downtimes.py

@mkayontour mkayontour added the feature New feature or request label Jul 31, 2022
@william-sy
Copy link
Author

Thanks for that link, Looks like you have done quite a bit!

I spot a few todo's with the same subject: Rewrite filter and make second request for single services or multiple
Anything else you had an idea of rewriting ?

I guess a branch in this repo will do for the dev. of this module ?

@mkayontour
Copy link
Member

Thanks, I need to get myself updated on this module. But I remember that I had problems with removing downtimes, because the API call always removes all downtimes. I'll put this in a branch.

@william-sy
Copy link
Author

Ah that is a good feature to be aware of, Looking forward to a branch to colab on!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants