From 7516de601e3466c5fc60c02efbecd036017a8248 Mon Sep 17 00:00:00 2001 From: Greg Sutcliffe Date: Wed, 3 Jun 2026 15:25:37 +0100 Subject: [PATCH] Zabbix: Move Copr-fe CDN check from Nagios Signed-off-by: Greg Sutcliffe --- .../frontend/files/zabbix/agent-copr-fe.conf | 1 + .../files/zabbix/template-copr-fe.yml | 38 ++++++++++++++++ roles/copr/frontend/tasks/main.yml | 8 +++- roles/copr/frontend/tasks/monitoring.yml | 44 +++++++++++++++++++ .../files/nagios/services/copr.cfg | 7 --- .../zabbix_server/tasks/configure_users.yml | 3 ++ 6 files changed, 93 insertions(+), 8 deletions(-) create mode 100644 roles/copr/frontend/files/zabbix/agent-copr-fe.conf create mode 100644 roles/copr/frontend/files/zabbix/template-copr-fe.yml create mode 100644 roles/copr/frontend/tasks/monitoring.yml diff --git a/roles/copr/frontend/files/zabbix/agent-copr-fe.conf b/roles/copr/frontend/files/zabbix/agent-copr-fe.conf new file mode 100644 index 0000000000..113e0b8ccc --- /dev/null +++ b/roles/copr/frontend/files/zabbix/agent-copr-fe.conf @@ -0,0 +1 @@ +UserParameter=copr.cdn,/usr/bin/copr-cdn-check.py diff --git a/roles/copr/frontend/files/zabbix/template-copr-fe.yml b/roles/copr/frontend/files/zabbix/template-copr-fe.yml new file mode 100644 index 0000000000..b20c8a1e59 --- /dev/null +++ b/roles/copr/frontend/files/zabbix/template-copr-fe.yml @@ -0,0 +1,38 @@ +zabbix_export: + version: '7.0' + template_groups: + - uuid: a333cbd6a3ad44baaa4eee4b0c0b1bec + name: Fedora + templates: + - uuid: 21645ff5fead4d55ad10997123dee18d + template: 'Copr FE checks' + name: 'Copr FE checks' + description: 'Checks from the COPR frontends' + groups: + - name: Fedora + items: + - uuid: 6561e5e7bb814f8792913dd270d299b9 + name: 'CDN check' + type: ZABBIX_ACTIVE + key: copr.cdn + delay: 5m + value_type: TEXT + trends: '0' + description: 'Gathered by a python script on-disk' + tags: + - tag: application + value: cdn + - tag: team + value: copr + triggers: + - uuid: 2b463c658f7d4af1a2241ae3a7f0e4da + expression: 'last(/Copr FE checks/copr.cdn)<>"Copr''s CDN (https://download.copr.fedorainfracloud.org/) is UP"' + name: 'COPR CDN Check failed' + tags: + - tag: scope + value: availability + - tag: team + value: copr + tags: + - tag: team + value: copr diff --git a/roles/copr/frontend/tasks/main.yml b/roles/copr/frontend/tasks/main.yml index 2cd4d51e86..1368ea3e32 100644 --- a/roles/copr/frontend/tasks/main.yml +++ b/roles/copr/frontend/tasks/main.yml @@ -247,7 +247,7 @@ ansible.builtin.template: dest: "/usr/bin/copr-cdn-check.py" src: "copr-cdn-check.py.j2" - group: "nagios" + group: "zabbix" mode: "0750" vars: api_key: "{{ copr_uptimerobot_api_key_ro | default('not-configured') }}" @@ -257,3 +257,9 @@ ansible.builtin.copy: src=gai.conf dest=/etc notify: - Reload httpd + +- name: Configure COPR FE monitoring in Zabbix + ansible.builtin.include_tasks: monitoring.yml + tags: + - zabbix_agent + - zabbix_api diff --git a/roles/copr/frontend/tasks/monitoring.yml b/roles/copr/frontend/tasks/monitoring.yml new file mode 100644 index 0000000000..e68d032cba --- /dev/null +++ b/roles/copr/frontend/tasks/monitoring.yml @@ -0,0 +1,44 @@ +# Zabbix monitoring of the COPR FE status + +- name: Install Zabbix agent config drop-in + ansible.builtin.copy: + src: zabbix/agent-copr-fe.conf + dest: /etc/zabbix/zabbix_agentd.d/copr-fe.conf + mode: '0644' + notify: + - Restart zabbix agent + tags: + - 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 + block: + - name: Import COPR FE template file + community.zabbix.zabbix_template: + template_yaml: "{{ lookup('file', 'zabbix/template-copr-fe.yml') }}" + state: present + run_once: true + + - name: Ensure COPR Zabbix hostgroup is present + community.zabbix.zabbix_group: + host_groups: + - Copr Hosts + state: present + run_once: true + + - name: Add self to COPR FE template in Zabbix + community.zabbix.zabbix_host: + host_name: "{{ inventory_hostname }}" + host_groups: Copr Hosts + link_templates: Copr FE checks + force: false diff --git a/roles/nagios_server/files/nagios/services/copr.cfg b/roles/nagios_server/files/nagios/services/copr.cfg index 89e79cdcb2..da8b82bfb2 100644 --- a/roles/nagios_server/files/nagios/services/copr.cfg +++ b/roles/nagios_server/files/nagios/services/copr.cfg @@ -5,13 +5,6 @@ define service { use defaulttemplate } -define service { - hostgroup_name copr_front_aws, copr_front_dev_aws - service_description The copr cdn status - check_command check_by_nrpe!check_copr_cdn - use defaulttemplate -} - define service { hostgroup_name copr_dist_git_aws service_description http-copr-be.aws.fedoraproject.org diff --git a/roles/zabbix/zabbix_server/tasks/configure_users.yml b/roles/zabbix/zabbix_server/tasks/configure_users.yml index b8c048d431..b9980705dd 100644 --- a/roles/zabbix/zabbix_server/tasks/configure_users.yml +++ b/roles/zabbix/zabbix_server/tasks/configure_users.yml @@ -107,9 +107,12 @@ operator: "equals" value: "team" value2: "copr" + formulaid: A - type: "host_group" operator: "equals" value: "Copr Hosts" + formulaid: B + formula: A or B operations: - type: send_message media_type: "Matrix"