diff --git a/defaults/main.yml b/defaults/main.yml index 03a613a..d321a7f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,3 @@ --- +apache_check_memory_limit: 500.0 MB dhparams_path: /etc/ssl/dhparams.pem diff --git a/handlers/main.yml b/handlers/main.yml index f9cf09b..be0c87b 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -13,3 +13,8 @@ ansible.builtin.service: name: munin-node state: restarted + +- name: reload monit + ansible.builtin.service: + name: monit + state: reloaded diff --git a/tasks/monitoring.yml b/tasks/monitoring.yml index 81527b4..49b975f 100644 --- a/tasks/monitoring.yml +++ b/tasks/monitoring.yml @@ -24,7 +24,7 @@ mode: 0644 notify: restart munin-node -- name: "Mpnitoring | Enable Munin plugins" +- name: "Monitoring | Enable Munin plugins" ansible.builtin.file: src: "/usr/share/munin/plugins/{{ item }}" dest: "/etc/munin/plugins/{{ item }}" @@ -34,3 +34,10 @@ - apache_processes - apache_volume notify: restart munin-node + +- name: "Monitoring | Enable Monit configuration" + ansible.builtin.template: + src: monit.conf + dest: /etc/monit/conf-enabled/apache2 + mode: 0644 + notify: reload monit diff --git a/templates/monit.conf b/templates/monit.conf new file mode 100644 index 0000000..84264cb --- /dev/null +++ b/templates/monit.conf @@ -0,0 +1,11 @@ +# Ansible managed + +check process apache with pidfile /run/apache2/apache2.pid + group webserver + start program = "/usr/sbin/service apache2 start" with timeout 60 seconds + stop program = "/usr/sbin/service apache2 stop" + if cpu > 60% for 2 cycles then alert + if cpu > 80% for 5 cycles then restart + if totalmem > {{ apache_check_overrides.memory_limit | default(apache_check_memory_limit) }} for 3 cycles then restart + if children > 250 then restart + if 3 restarts within 5 cycles then timeout