1
0
Fork 0
forked from infra/ansible

Zabbix: move Memcached from Nagios

Signed-off-by: Greg Sutcliffe <fedora@emeraldreverie.org>
This commit is contained in:
Greg Sutcliffe 2026-06-11 13:34:10 +01:00
commit 182bd82802
Signed by: gwmngilfen
SSH key fingerprint: SHA256:dNHcz65ApR68w2TkCIAXDBdt4oNL62Fyx48U7dXWuk0
6 changed files with 125 additions and 13 deletions

View file

@ -0,0 +1 @@
UserParameter=memcached.stats,echo stats | nc 127.0.0.1 11211

View file

@ -0,0 +1,10 @@
module zabbix_memcached 1.1;
require {
type zabbix_agent_t;
type memcache_port_t;
class tcp_socket name_connect;
}
#============= zabbix_agent_t ==============
allow zabbix_agent_t memcache_port_t:tcp_socket name_connect;

View file

@ -0,0 +1,51 @@
zabbix_export:
version: '7.0'
template_groups:
- uuid: a333cbd6a3ad44baaa4eee4b0c0b1bec
name: Fedora
templates:
- uuid: 7b80ad99266c446c84fa860176c6a4e7
template: 'Memcached checks'
name: 'Memcached checks'
groups:
- name: Fedora
items:
- uuid: 8950fe78e9444d0086bb685c01917839
name: 'Memcached stats'
type: ZABBIX_ACTIVE
key: memcached.stats
history: 1d
value_type: TEXT
trends: '0'
preprocessing:
- type: CHECK_NOT_SUPPORTED
parameters:
- '-1'
error_handler: CUSTOM_VALUE
error_handler_params: failed
tags:
- tag: application
value: memcached
triggers:
- uuid: 49c1aaa412fc4f159bc39c716d380c84
expression: 'last(/Memcached checks/memcached.stats)="failed"'
name: 'Failed to get memcached stats'
priority: AVERAGE
tags:
- tag: scope
value: availability
- uuid: 6ccdd65abc4f47c78ad91c401a9a9aa8
name: 'Memcached procs'
type: ZABBIX_ACTIVE
key: 'proc.num[,,,/usr/bin/memcached]'
tags:
- tag: application
value: memcached
triggers:
- uuid: 846e74c46343420d9c92847c60bf3b3e
expression: 'last(/Memcached checks/proc.num[,,,/usr/bin/memcached])=0'
name: 'Memcached is not running'
priority: AVERAGE
tags:
- tag: scope
value: processes

View file

@ -33,3 +33,66 @@
notify:
- Reload systemd
when: ansible_distribution == 'RedHat' and ansible_distribution_major_version|int == 7
# Zabbix monitoring tasks
- name: Copy Memcached Zabbix SELinux module
ansible.builtin.copy:
src: zabbix-selinux.te
dest: /usr/local/share/zabbix/zabbix_memcached.te
owner: root
group: root
mode: '0644'
register: selinux_zabbix_file
tags:
- memcached
- 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_memcached
when: selinux_zabbix_file.changed # noqa: no-handler
tags:
- memcached
- selinux
- zabbix_agent
- name: Install Zabbix agent config drop-in
ansible.builtin.copy:
src: zabbix-agent-dropin
dest: /etc/zabbix/zabbix_agentd.d/postfix.conf
mode: '0644'
notify:
- Restart zabbix agent
tags:
- memcached
- 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
- zabbix_agent
block:
- name: Import Memcached Zabbix template file
community.zabbix.zabbix_template:
template_yaml: "{{ lookup('file', 'zabbix-template.yml') }}"
state: present
run_once: true
- name: Add self to Memcached template in Zabbix
community.zabbix.zabbix_host:
host_name: "{{ inventory_hostname }}"
host_groups: Postfix servers
link_templates: Postfix Mail Queue
force: false

View file

@ -1,12 +0,0 @@
define service {
hostgroup_name memcached
service_description Check for the presence of the memcached daemon
check_command check_by_nrpe!check_memcache
use defaulttemplate
}
define service {
hostgroup_name memcached
service_description Check for connectivity to the memcached daemon
check_command check_by_nrpe!check_memcache_connect
use defaulttemplate
}

View file

@ -208,7 +208,6 @@
- name: Copy /etc/nagios/services (internal files)
ansible.builtin.copy: src=nagios/services/{{ item }} dest=/etc/nagios/services/{{ item }}
with_items:
- memcached.cfg
- nagios.cfg
- pagure_redis.cfg
- procs.cfg