forked from infra/ansible
Zabbix: Add RabbitMQ monitoring
Signed-off-by: Greg Sutcliffe <fedora@emeraldreverie.org>
This commit is contained in:
parent
9586313f2b
commit
2f89694058
5 changed files with 1698 additions and 0 deletions
10
roles/rabbitmq/files/zabbix/selinux_rabbitmq.te
Normal file
10
roles/rabbitmq/files/zabbix/selinux_rabbitmq.te
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
module zabbix_rabbitmq 1.0;
|
||||
|
||||
require {
|
||||
type amqp_port_t;
|
||||
type zabbix_agent_t;
|
||||
class tcp_socket name_connect;
|
||||
}
|
||||
|
||||
#============= zabbix_agent_t ==============
|
||||
allow zabbix_agent_t amqp_port_t:tcp_socket name_connect;
|
||||
1600
roles/rabbitmq/files/zabbix/template-rabbitmq.yml
Normal file
1600
roles/rabbitmq/files/zabbix/template-rabbitmq.yml
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -19,3 +19,11 @@
|
|||
- name: Start rabbitmq
|
||||
service: name=rabbitmq-server state=started enabled=yes
|
||||
tags: rabbitmq
|
||||
|
||||
- name: Configure RabbitMQ monitoring in Zabbix
|
||||
ansible.builtin.include_tasks: monitoring.yml
|
||||
tags:
|
||||
- rabbitmq
|
||||
- selinux
|
||||
- zabbix_agent
|
||||
- zabbix_api
|
||||
|
|
|
|||
77
roles/rabbitmq/tasks/monitoring.yml
Normal file
77
roles/rabbitmq/tasks/monitoring.yml
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
### Monitoring config
|
||||
# Custom SELinux requirements for Zabbix to execute monitoring binaries
|
||||
- name: Ensure a directory exists for RabbitMQ Zabbix selinux module
|
||||
ansible.builtin.file:
|
||||
path: /usr/local/share/zabbix
|
||||
state: directory
|
||||
mode: '0755'
|
||||
tags:
|
||||
- rabbitmq
|
||||
- selinux
|
||||
- zabbix_agent
|
||||
|
||||
- name: Copy RabbitMQ Zabbix SELinux module
|
||||
ansible.builtin.copy:
|
||||
src: zabbix/selinux_rabbitmq.te
|
||||
dest: /usr/local/share/zabbix/zabbix_rabbitmq.te
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
register: selinux_zabbix_file
|
||||
tags:
|
||||
- rabbitmq
|
||||
- selinux
|
||||
- zabbix_agent
|
||||
|
||||
- name: Compile and install SELinux module
|
||||
ansible.builtin.include_tasks: "{{ tasks_path }}/compile-selinux.yml"
|
||||
vars:
|
||||
selinux_module_dir: /usr/local/share/zabbix
|
||||
selinux_module_name: zabbix_rabbitmq
|
||||
when: selinux_zabbix_file.changed
|
||||
tags:
|
||||
- rabbitmq
|
||||
- selinux
|
||||
- zabbix_agent
|
||||
|
||||
- name: Install Zabbix agent config drop-in
|
||||
ansible.builtin.template:
|
||||
src: zabbix/agent-rabbitmq.conf.j2
|
||||
dest: /etc/zabbix/zabbix_agentd.d/rabbitmq.conf
|
||||
mode: '0600'
|
||||
owner: zabbix
|
||||
tags:
|
||||
- rabbitmq
|
||||
- zabbix_agent
|
||||
notify:
|
||||
- Restart zabbix agent
|
||||
|
||||
- name: Zabbix API Block
|
||||
vars:
|
||||
ansible_zabbix_auth_key: "{{ zabbix_auth_key }}"
|
||||
ansible_network_os: "{{ zabbix_network_os }}"
|
||||
ansible_connection: "{{ zabbix_connection }}"
|
||||
ansible_httpapi_port: "{{ zabbix_httpapi_port }}"
|
||||
ansible_httpapi_use_ssl: "{{ zabbix_httpapi_use_ssl }}"
|
||||
ansible_httpapi_validate_certs: "{{ zabbix_httpapi_validate_certs }}"
|
||||
ansible_host: "{{ zabbix_server }}"
|
||||
ansible_zabbix_url_path: "{{ zabbix_url_path }}"
|
||||
tags:
|
||||
- zabbix_api
|
||||
- rabbitmq
|
||||
block:
|
||||
- name: Import RabbitMQ template file
|
||||
community.zabbix.zabbix_template:
|
||||
template_yaml: "{{ lookup('file', 'zabbix/template-rabbitmq.yml') }}"
|
||||
state: present
|
||||
- name: Ensure RabbitMQ hostgroup is present
|
||||
community.zabbix.zabbix_group:
|
||||
host_groups:
|
||||
- RabbitMQ servers
|
||||
state: present
|
||||
- name: Add self to RabbitMQ in Zabbix
|
||||
community.zabbix.zabbix_host:
|
||||
host_name: "{{ inventory_hostname }}"
|
||||
host_groups: RabbitMQ servers
|
||||
link_templates: RabbitMQ Monitoring
|
||||
force: false
|
||||
3
roles/rabbitmq/templates/zabbix/agent-rabbitmq.conf.j2
Normal file
3
roles/rabbitmq/templates/zabbix/agent-rabbitmq.conf.j2
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
UserParameter=rabbitmq.get_node_overview,curl -s -u "nagios-monitoring:{{ (env == 'production')|ternary(rabbitmq_monitoring_password_production, rabbitmq_monitoring_password_staging) }}" http://localhost:15672/api/overview
|
||||
UserParameter=rabbitmq.get_queues,curl -s -u "nagios-monitoring:{{ (env == 'production')|ternary(rabbitmq_monitoring_password_production, rabbitmq_monitoring_password_staging) }}" http://localhost:15672/api/queues
|
||||
UserParameter=rabbitmq.get_nodes,curl -s -u "nagios-monitoring:{{ (env == 'production')|ternary(rabbitmq_monitoring_password_production, rabbitmq_monitoring_password_staging) }}" http://localhost:15672/api/nodes/rabbit@rabbitmq01.stg.rdu3.fedoraproject.org?memory=true
|
||||
Loading…
Add table
Add a link
Reference in a new issue