Skip to content

Commit

Permalink
php-fpm: Add netdata collectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
JGoutin committed Aug 16, 2024
1 parent 84b0d0a commit 1c4cb94
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
8 changes: 7 additions & 1 deletion roles/nginx/templates/nginx-site.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ server {
allow 127.0.0.1;
deny all;
}
{%- endif %}
{% if nginx_php_fpm -%}
location = /fpm_status {
# Ensure PHP-FPM status page is not reachable from Nginx
access_log off;
deny all;
}
{%- endif %}{%- endif %}

# Starting Extra security configuration
# =====================================
Expand Down
4 changes: 4 additions & 0 deletions roles/php_fpm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
name: php-fpm
enabled: true

- name: Netdata configuration
ansible.builtin.include_tasks: netdata.yml
when: common_netdata_enable | bool

- name: Ensure PHP-FPM "rpmnew" and "rpmsave" files are absent
ansible.builtin.file:
path: "{{ item }}"
Expand Down
19 changes: 19 additions & 0 deletions roles/php_fpm/tasks/netdata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

- name: Ensure Netdata configuration directory is present
ansible.builtin.file:
path: /etc/netdata/go.d
state: directory
mode: '0755'

- name: Ensure Netdata collectors are configured
ansible.builtin.template:
src: netdata_phpfpm.conf.j2
dest: /etc/netdata/go.d/phpfpm.conf
mode: '0644'

- name: Ensure Systemd Netdata service is restarted
ansible.builtin.systemd:
name: netdata
state: restarted
changed_when: false
4 changes: 4 additions & 0 deletions roles/php_fpm/templates/netdata_phpfpm.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jobs:
- name: local
socket: /var/run/php-fpm/{{ php_fpm_site }}.sock
fcgi_path: /fpm_status
4 changes: 4 additions & 0 deletions roles/php_fpm/templates/php-fpm.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ pm.max_spare_servers = 18
pm.max_requests = {{ php_fpm_max_requests }}
request_terminate_timeout = {{ php_fpm_request_terminate_timeout }}

{% if common_netdata_enable is defined -%}
pm.status_path = /fpm_status
{%- endif %}

env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
Expand Down

0 comments on commit 1c4cb94

Please sign in to comment.