For the monitoring of our systems, we make extensive use of Icinga, its director, and the business process monitoring module. We also make broad use of automation (at least we try to!). In this talk we would like to tell you how we automated the monitoring of our services using our self-written Ansible collections. We will cover how we developed the Ansible components and how we use them. We’ll also show you what we plan to do with them in the future.
5. What we did with our architecture
Central kubernetes cluster with icinga instances
at least 45 Icinga instances
Page 5 / 22
6. What problems we faced with our code
No exsisting upstream modules
instead use Ansible uri-Tasks
Page 6 / 22
7. What we did with our Ansible code
- name: create service template if it does not exist
uri:
headers:
Accept: application/json
url: "{{ icinga_host }}/director/service"
method: POST
user: "{{ icinga_user }}"
password: "{{ icinga_pass }}"
body: '{"check_command":"{{ item.item.check_command }}",
"object_name":"{{ item.item.name }}",
"object_type": "template", "use_agent":{{ item.item.use_agent }}}'
body_format: json
return_content: yes
register: service_template_created
with_items: "{{ service_template_presence.results }}"
when: "'error' in item.content"
changed_when: service_template_created.status == 201
failed_when: service_template_created.status != 201
Page 7 / 22
8. What we're doing now with the code
- name: Create servicetemplate with event command
t_systems_mms.icinga_director.icinga_service_template:
state: present
url: "{{ icinga_url }}"
url_username: "{{ icinga_user }}"
url_password: "{{ icinga_pass }}"
object_name: apache_check_servicetemplate
use_agent: false
event_command: restart_httpd
notes: "example note"
notes_url: "'http://url1' 'http://url2'"
Page 8 / 22
9. What we accomplished
Date Feature
04/2020 internal development started
05/2020 Modules on Github in v1.0.0
05/20 - 12/20 command_template, host_template, zones and endpoints, service
01/21 inclusion into Ansible
02/21 facts/info modules for all objects
03/21 usergroups, timeperiod_template
07/21 inventory-plugin
Page 9 / 22
15. Let's talk about the Business Processes Plugin (BP)
Optional Icinga2 module
Build custom process-based dashboards
Get visualized Overview over your monitored objects
Page 15 / 22
17. Collection development
First things first: manually play around with every feature
Check the requests made by the extension (we need those for the upload or
check part f.e)
Our first draft was a Ansible role:
{% if node.operator == 'or' -%}
{{ node.name }} = {{ checks|join(' | ') }}
{% elif node.operator == 'not' -%}
{{ node.name }} = {{ checks|join(' ! ') }}
{% elif node.operator == 'and' -%}
{{ node.name }} = {{ checks|join(' & ') }}
{% elif node.operator is defined -%}
{{ node.name }} = {{ node.operator }}: {{ checks|join(' + ') }}
{% endif %}
Page 17 / 22
19. The future
At this time all functionalities are already implemented
Create service templates as check commands to integrate monitoring-alerts
- service_apply_object:
- "check_bpm"
imports:
- domon-business-process
assign_filter: 'host.name="pseudo-host"'
vars:
config: $bpm_servive_name
process: $bpm_process
Page 19 / 22