Skip to content

Commit 4b67e2c

Browse files
mkayontourDonien
andauthored
Feature/icingaweb module graphite (#199)
* Add support for Icinga Web 2 module Graphite --------- Co-authored-by: Donien <[email protected]>
1 parent a9af180 commit 4b67e2c

File tree

6 files changed

+200
-0
lines changed

6 files changed

+200
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
3+
minor_changes:
4+
- "Add Icinga Web 2 module :code:`Graphite`."
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
## Module Graphite
2+
3+
This module only configures the module in Icinga Web and not the graphite backend itself.
4+
5+
## Variables
6+
7+
### Module Configuration File
8+
9+
The general module parameter like `enabled` and `source` can be applied here.
10+
11+
For the **config** file, create a dictionary with sections as keys and the parameters as values.
12+
13+
Example:
14+
15+
```
16+
icingaweb2_modules:
17+
graphite:
18+
enabled: true
19+
source: package
20+
config:
21+
graphite: # This is the section
22+
url: 127.0.0.1:9000
23+
user: graphite
24+
password: graphitepw
25+
ui:
26+
default_time_range: 6
27+
28+
```
29+
30+
#### Section graphite
31+
32+
| Variable | Type | Example |
33+
|----------|--------|------------------|
34+
| url | string | "127.0.0.1:9000" |
35+
| user | string | "graphite" |
36+
| password | string | "password" |
37+
| insecure | number | "1" |
38+
39+
#### Section ui
40+
41+
| Variable | Type | Example |
42+
|-------------------------|--------|---------|
43+
| default_time_range | number | "1" |
44+
| defautl_time_range_unit | string | "hours" |
45+
| disable_no_graphs_found | bool | "0"/"1" |
46+
47+
48+
#### Section icinga
49+
50+
| Variable | Type | Example |
51+
|---------------------------------------|--------|----------------------|
52+
| graphite_writer_host_name_template | string | "$host.template$" |
53+
| graphite_writer_service_name_template | string | "$service.template$" |
54+
| customvar_obscured_check_command | string | "customvar" |
55+
56+
57+
### Custom Template Files
58+
59+
Custom templates are good to enhance the graphite basic template library. To include own
60+
graphs and modifications.
61+
62+
To copy them into the templates folder please use the `custom_template_files` dictionary.
63+
64+
The `src_path` will search within any `files/` directory in the Ansible environment.
65+
66+
67+
```
68+
icingaweb2_modules:
69+
graphite:
70+
enabled: true
71+
source: package
72+
custom_template_files:
73+
- name: mygraph.ini
74+
src_path: graphite_templates/mygraph.ini
75+
- name: myothergraph.ini
76+
src_path: graphite_templates/myothergraph.ini
77+
```

molecule/default/converge.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,55 @@
33
- name: Converge
44
hosts: all
55
vars:
6+
icingaweb2_modules:
7+
graphite:
8+
enabled: true
9+
source: package
10+
custom_template_files:
11+
- name: test.ini
12+
src_path: graphite_templates/test.ini
13+
config:
14+
graphite:
15+
url: 127.0.0.1:9000
16+
ui:
17+
default_time_range: 6
18+
director:
19+
enabled: true
20+
source: package
21+
import_schema: false
22+
run_kickstart: false
23+
kickstart:
24+
config:
25+
endpoint: icinga-default
26+
host: 127.0.0.1
27+
username: root
28+
password: root
29+
config:
30+
db:
31+
resource: director_db
32+
icingadb:
33+
enabled: true
34+
source: package
35+
commandtransports:
36+
instance01:
37+
transport: api
38+
host: 127.0.0.1
39+
username: root
40+
password: root
41+
config:
42+
icingadb:
43+
resource: icingadb
44+
redis:
45+
tls: '0'
46+
redis:
47+
redis1:
48+
host: "127.0.0.1"
49+
monitoring:
50+
enabled: false
51+
backends:
52+
icinga2_ido_mysql:
53+
type: ido
54+
resource: icinga_ido
655
icingaweb2_db:
756
type: mysql
857
name: icingaweb
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[hostalive-rta.graph]
2+
check_command = "hostalive"
3+
4+
[hostalive-rta.metrics_filters]
5+
rta.value = "$host_name_template$.perfdata.rta.value"
6+
7+
[hostalive-rta.urlparams]
8+
areaAlpha = "0.5"
9+
areaMode = "all"
10+
min = "0"
11+
yUnitSystem = "none"
12+
13+
[hostalive-rta.functions]
14+
rta.value = "alias(color(scale($metric$, 1000), '#1a7dd7'), 'Round trip time (ms)')"
15+
16+
17+
[hostalive-pl.graph]
18+
check_command = "hostalive"
19+
20+
[hostalive-pl.metrics_filters]
21+
pl.value = "$host_name_template$.perfdata.pl.value"
22+
23+
[hostalive-pl.urlparams]
24+
areaAlpha = "0.5"
25+
areaMode = "all"
26+
min = "0"
27+
yUnitSystem = "none"
28+
29+
[hostalive-pl.functions]
30+
pl.value = "alias(color($metric$, '#1a7dd7'), 'Packet loss (%)')"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
- name: Module Graphite | Ensure config directory
2+
ansible.builtin.file:
3+
state: directory
4+
dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}"
5+
owner: "{{ icingaweb2_httpd_user }}"
6+
group: "{{ icingaweb2_group }}"
7+
mode: "2770"
8+
9+
- name: Module Graphite | Ensure templates directory
10+
ansible.builtin.file:
11+
state: directory
12+
dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}/templates"
13+
owner: "{{ icingaweb2_httpd_user }}"
14+
group: "{{ icingaweb2_group }}"
15+
mode: "2770"
16+
17+
- name: Module Graphite | Manage config files
18+
ansible.builtin.include_tasks: manage_module_config.yml
19+
loop: "{{ _files }}"
20+
loop_control:
21+
loop_var: _file
22+
when: icingaweb2_modules[_module][_file] is defined
23+
vars:
24+
_module: "{{ item.key }}"
25+
_files:
26+
- config
27+
28+
- name: Module Graphite | Copy custom templates
29+
ansible.builtin.copy:
30+
owner: "{{ icingaweb2_httpd_user }}"
31+
group: "{{ icingaweb2_group }}"
32+
src: "files/{{ _file.src_path }}"
33+
dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}/templates/{{ _file.name }}"
34+
when: icingaweb2_modules[_module].custom_template_files is defined
35+
loop: "{{ icingaweb2_modules[_module].custom_template_files }}"
36+
loop_control:
37+
loop_var: _file
38+
vars:
39+
_module: "{{ item.key }}"

roles/icingaweb2/vars/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
icingaweb2_module_packages:
33
icingadb: icingadb-web
44
director: icinga-director
5+
graphite: icinga-graphite-web
56
x509: icinga-x509
67
businessprocess: icinga-businessprocess
78
kubernetes: icinga-kubernetes-web

0 commit comments

Comments
 (0)