add phpfpm exporter
This commit is contained in:
parent
7677eb47b7
commit
bca9798942
@ -13,7 +13,7 @@ Role variables
|
||||
--------------
|
||||
|
||||
| Variable | Type | Choices | Default | Comment |
|
||||
|----------------------------------------------|---------|--------------------------------------|-------------|-----------------|
|
||||
|----------------------------------------------|---------|----------------------------------------------|-------------|-----------------|
|
||||
| prometheus_server_enable | string | true / false | | |
|
||||
| prometheus_server_version | string | | latest | |
|
||||
| prometheus_server_monitor | string | | | |
|
||||
@ -22,7 +22,7 @@ Role variables
|
||||
| prometheus_server_job_name | string | | prometheus | |
|
||||
| prometheus_server_scrape_interval | string | | 5 | |
|
||||
| prometheus_server_scrape_timeout | string | | 5 | |
|
||||
| prometheus_exporter_packages | list | node / mysqld / postgresql / mongodb | | |
|
||||
| prometheus_exporter_packages | list | node / mysqld / postgresql / mongodb /phpfpm | | |
|
||||
| prometheus_node_exporter_targets | list | | | |
|
||||
| prometheus_mysqld_exporter_targets | list | | | |
|
||||
| prometheus_mongodb_exporter_targets | list | | | |
|
||||
|
@ -10,6 +10,8 @@ prometheus_mongodb_exporter_database: "admin"
|
||||
prometheus_mongodb_exporter_host: "localhost"
|
||||
prometheus_mongodb_exporter_port: 27017
|
||||
|
||||
prometheus_phpfpm_sockets_directory: "/run/php/"
|
||||
|
||||
prometheus_postgres_exporter_host: "/var/run/postgresql/"
|
||||
prometheus_postgres_exporter_sslmode: "disable"
|
||||
prometheus_postgres_exporter_user: "postgres"
|
||||
|
@ -33,3 +33,9 @@
|
||||
enabled: yes
|
||||
tags: ['prometheus']
|
||||
|
||||
- name: 'prometheus | phpfpm exporter | restart service'
|
||||
systemd:
|
||||
name: prometheus-phpfpm-exporter.service
|
||||
state: restarted
|
||||
enabled: yes
|
||||
tags: ['prometheus']
|
||||
|
@ -29,3 +29,8 @@
|
||||
include_tasks: 'postgresql_exporter.yml'
|
||||
when:
|
||||
- "'postgresql' in prometheus_exporter_packages"
|
||||
|
||||
- name: 'prometheus | PHP Fpm exporter'
|
||||
include_tasks: 'phpfpm_exporter.yml'
|
||||
when:
|
||||
- "'phpfpm' in prometheus_exporter_packages"
|
||||
|
51
tasks/phpfpm_exporter.yml
Normal file
51
tasks/phpfpm_exporter.yml
Normal file
@ -0,0 +1,51 @@
|
||||
---
|
||||
- name: 'prometheus | phpfpm exporter | get latest release from GitHub'
|
||||
shell: curl --silent "https://api.github.com/repos/Lusitaniae/phpfpm_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
|
||||
args:
|
||||
warn: false
|
||||
register: prometheus_phpfpm_exporter_latest_version
|
||||
run_once: true
|
||||
|
||||
- name: 'prometheus | phpfpm exporter | download'
|
||||
get_url:
|
||||
url: https://github.com/Lusitaniae/phpfpm_exporter/releases/download/v{{ prometheus_phpfpm_exporter_version|default(prometheus_phpfpm_exporter_latest_version.stdout) }}/phpfpm_exporter-{{ prometheus_phpfpm_exporter_version|default(prometheus_phpfpm_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
||||
dest: /tmp
|
||||
|
||||
- name: 'prometheus | phpfpm exporter | unarchive'
|
||||
unarchive:
|
||||
remote_src: yes
|
||||
src: /tmp/phpfpm_exporter-{{ prometheus_phpfpm_exporter_version|default(prometheus_phpfpm_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
||||
dest: /tmp
|
||||
|
||||
- name: 'prometheus | phpfpm exporter | move to /usr/local/bin'
|
||||
copy:
|
||||
src: /tmp/phpfpm_exporter-{{ prometheus_phpfpm_exporter_version|default(prometheus_phpfpm_exporter_latest_version.stdout) }}.linux-amd64/phpfpm_exporter
|
||||
dest: /usr/local/bin/prometheus-phpfpm-exporter
|
||||
remote_src: yes
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
notify:
|
||||
- 'prometheus | phpfpm exporter | restart service'
|
||||
|
||||
- name: 'prometheus | phpfpm exporter | install startup script'
|
||||
template:
|
||||
src: scripts/prometheus-phpfpm-exporter-script.sh.j2
|
||||
dest: /usr/local/bin/prometheus-phpfpm-exporter-script.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0600
|
||||
|
||||
- name: 'prometheus | phpfpm exporter | install unit file to systemd'
|
||||
template:
|
||||
src: systemd/prometheus-phpfpm-exporter.service.j2
|
||||
dest: /etc/systemd/system/prometheus-phpfpm-exporter.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0600
|
||||
|
||||
- name: 'prometheus | phpfpm exporter | configure systemd to use service'
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
enabled: yes
|
||||
name: prometheus-phpfpm-exporter.service
|
@ -74,3 +74,14 @@ scrape_configs:
|
||||
- {{ target }}:9187
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if prometheus_phpfpm_exporter_targets is defined %}
|
||||
- job_name: phpfpm
|
||||
scrape_interval: 30s
|
||||
scrape_timeout: 10s
|
||||
static_configs:
|
||||
- targets:
|
||||
{% for target in prometheus_phpfpm_exporter_targets %}
|
||||
- {{ target }}:9253
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
/usr/local/bin/prometheus-phpfpm-exporter $(ls -1 {{ prometheus_phpfpm_sockets_directory }} | awk '{print "--phpfpm.socket-paths {{ prometheus_phpfpm_sockets_directory }}" $1}' |head -c -1)
|
@ -4,7 +4,7 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/prometheus-phpfpm-exporter
|
||||
ExecStart=/bin/bash /usr/local/bin/prometheus-phpfpm-exporter-script.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
x
Reference in New Issue
Block a user