Add monit monitoring

This commit is contained in:
phil 2023-06-10 18:30:09 +02:00
parent a8e8382eca
commit 04be772437
4 changed files with 31 additions and 5 deletions

View file

@ -1,19 +1,24 @@
---
- name: reload apache2
service:
ansible.builtin.service:
name: apache2
state: reloaded
- name: reload php-fpm
service:
ansible.builtin.service:
name: "php{{ php_version.stdout }}-fpm"
state: reloaded
- name: stop php-fpm-socket
command: systemctl stop php-fpm@*.socket
ansible.builtin.command: systemctl stop php-fpm@*.socket
- name: stop php-fpm-service
command: systemctl stop php-fpm@*.service
ansible.builtin.command: systemctl stop php-fpm@*.service
- name: start php-fpm-socket
command: systemctl start php-fpm@*.socket --all
ansible.builtin.command: systemctl start php-fpm@*.socket --all
- name: reload monit
ansible.builtin.service:
name: monit
state: reloaded

View file

@ -18,3 +18,8 @@
- name: User tasks
ansible.builtin.import_tasks: user.yml
tags: never, user
- name: Monitoring tasks
ansible.builtin.import_tasks: monitoring.yml
tags: monitoring

8
tasks/monitoring.yml Normal file
View file

@ -0,0 +1,8 @@
---
- name: "Monitoring | Enable Monit monitoring"
ansible.builtin.template:
src: monit.j2
dest: /etc/monit/conf-enabled/phpfpm
mode: "0644"
when: '"monit" in ansible_facts.packages'
notify: reload monit

8
templates/monit.j2 Normal file
View file

@ -0,0 +1,8 @@
# {{ ansible_managed }}
check process php-fpm with pidfile /run/php/php{{ php_version.stdout }}.pid
group webserver
start program = "/usr/sbin/service php{{ php_version.stdout }}-fpm start"
stop program = "/usr/sbin/service php{{ php_version.stdout }}-fpm stop"
if failed unixsocket /run/php/{{ php_version.stdout }}-fpm.sock for 3 cycles then restart
if 3 restarts within 5 cycles then timeout