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

Feature/icingaweb module graphite #199

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions doc/role-icingaweb2/module-graphite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
## Module Graphite

This module only configures the module in Icinga Web and not the graphite backend itself.

## Variables

### Module Configuration File

The general module parameter like `enabled` and `source` can be applied here.

For the **config** file, create a dictionary with sections as keys and the parameters as values.

Example:

```
icingaweb2_modules:
graphite:
enabled: true
source: package
config:
graphite: # This is the section
url: 127.0.0.1:9000
user: graphite
password: graphitepw
ui:
default_time_range: 6

```

#### Section graphite

| Variable | Type | Example |
|----------|--------|------------------|
| url | string | "127.0.0.1:9000" |
| user | string | "graphite" |
| password | string | "password" |
| insecure | number | "1" |

#### Section ui

| Variable | Type | Example |
|-------------------------|--------|---------|
| default_time_range | number | "1" |
| defautl_time_range_unit | string | "hours" |
| disable_no_graphs_found | bool | "0"/"1" |


#### Section icinga

| Variable | Type | Example |
|---------------------------------------|--------|----------------------|
| graphite_writer_host_name_template | string | "$host.template$" |
| graphite_writer_service_name_template | string | "$service.template$" |
| customvar_obscured_check_command | string | "customvar" |


### Custom Template Files

Custom templates are good to enhance the graphite basic template library. To include own
graphs and modifications.

To copy them into the templates folder please use the `custom_template_files` dictionary.

The `src_path` will search within any `files/` directory in the Ansible environment.


```
icingaweb2_modules:
graphite:
enabled: true
source: package
custom_template_files:
- name: mygraph.ini
src_path: graphite_templates/mygraph.ini
- name: myothergraph.ini
src_path: graphite_templates/myothergraph.ini
```
48 changes: 48 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,54 @@
- name: Converge
hosts: all
vars:
icingaweb2_modules:
graphite:
enabled: true
custom_template_files:
- name: test.ini
src_path: graphite_templates/test.ini
config:
graphite:
url: 127.0.0.1:9000
ui:
default_time_range: 6
director:
enabled: true
source: package
import_schema: false
run_kickstart: false
kickstart:
config:
endpoint: icinga-default
host: 127.0.0.1
username: root
password: root
config:
db:
resource: director_db
icingadb:
enabled: true
source: package
commandtransports:
instance01:
transport: api
host: 127.0.0.1
username: root
password: root
config:
icingadb:
resource: icingadb
redis:
tls: '0'
redis:
redis1:
host: "127.0.0.1"
monitoring:
enabled: false
backends:
icinga2_ido_mysql:
type: ido
resource: icinga_ido
icingaweb2_db:
type: mysql
name: icingaweb
Expand Down
30 changes: 30 additions & 0 deletions molecule/default/files/graphite_templates/test.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[hostalive-rta.graph]
check_command = "hostalive"

[hostalive-rta.metrics_filters]
rta.value = "$host_name_template$.perfdata.rta.value"

[hostalive-rta.urlparams]
areaAlpha = "0.5"
areaMode = "all"
min = "0"
yUnitSystem = "none"

[hostalive-rta.functions]
rta.value = "alias(color(scale($metric$, 1000), '#1a7dd7'), 'Round trip time (ms)')"


[hostalive-pl.graph]
check_command = "hostalive"

[hostalive-pl.metrics_filters]
pl.value = "$host_name_template$.perfdata.pl.value"

[hostalive-pl.urlparams]
areaAlpha = "0.5"
areaMode = "all"
min = "0"
yUnitSystem = "none"

[hostalive-pl.functions]
pl.value = "alias(color($metric$, '#1a7dd7'), 'Packet loss (%)')"
39 changes: 39 additions & 0 deletions roles/icingaweb2/tasks/modules/graphite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
- name: Module Graphite | Ensure config directory
ansible.builtin.file:
state: directory
dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}"
owner: "{{ icingaweb2_httpd_user }}"
group: "{{ icingaweb2_group }}"
mode: "2770"

- name: Module Graphite | Ensure templates directory
ansible.builtin.file:
state: directory
dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}/templates"
owner: "{{ icingaweb2_httpd_user }}"
group: "{{ icingaweb2_group }}"
mode: "2770"

- name: Module Graphite | Manage config files
ansible.builtin.include_tasks: manage_module_config.yml
loop: "{{ _files }}"
loop_control:
loop_var: _file
when: vars['icingaweb2_modules'][_module][_file] is defined
vars:
_module: "{{ item.key }}"
_files:
- config

- name: Module Graphite | Copy custom templates
ansible.builtin.copy:
owner: "{{ icingaweb2_httpd_user }}"
group: "{{ icingaweb2_group }}"
src: "files/{{ _file.src_path }}"
dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}/templates/{{ _file.name }}"
when: vars['icingaweb2_modules'][_module]['custom_template_files'] is defined
loop: "{{ vars['icingaweb2_modules'][_module]['custom_template_files'] }}"
loop_control:
loop_var: _file
vars:
_module: "{{ item.key }}"
1 change: 1 addition & 0 deletions roles/icingaweb2/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
icingaweb2_module_packages:
icingadb: icingadb-web
director: icinga-director
graphite: icinga-graphite-web
x509: icinga-x509
businessprocess: icinga-businessprocess