Skip to content

Commit fac7fb6

Browse files
Aramacktruthbk
authored andcommitted
[php-fpm] Add a parameter for ping_reply (#417)
* [php-fpm] Add a parameter for ping_reply * [php-fpm] Fix syntax error in test (#417)
1 parent 47a783d commit fac7fb6

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

manifests/integrations/php_fpm.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# $ping_url
1010
# URL to get a reliable check of the FPM pool. Default: http://localhost/ping
1111
#
12+
# $ping_reply
13+
# Expected response from ping_url. Default: pong
14+
#
1215
# $tags
1316
# Optional array of tags
1417
#
@@ -23,6 +26,7 @@
2326
class datadog_agent::integrations::php_fpm(
2427
$status_url = 'http://localhost/status',
2528
$ping_url = 'http://localhost/ping',
29+
$ping_reply = 'pong',
2630
$http_host = undef,
2731
$tags = [],
2832
$instances = undef
@@ -34,6 +38,7 @@
3438
'http_host' => $http_host,
3539
'status_url' => $status_url,
3640
'ping_url' => $ping_url,
41+
'ping_reply' => $ping_reply,
3742
'tags' => $tags,
3843
}]
3944
} else {

spec/classes/datadog_agent_integrations_php_fpm_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,30 @@
3131
context 'with default parameters' do
3232
it { should contain_file(conf_file).with_content(/status_url: http:\/\/localhost\/status/) }
3333
it { should contain_file(conf_file).with_content(/ping_url: http:\/\/localhost\/ping/) }
34+
it { should contain_file(conf_file).with_content(/ping_reply: pong/) }
3435
end
3536

3637
context 'with parameters set' do
3738
let(:params) {{
3839
status_url: 'http://localhost/fpm_status',
3940
ping_url: 'http://localhost/fpm_ping',
41+
ping_reply: 'success',
4042
}}
4143
it { should contain_file(conf_file).with_content(/status_url: http:\/\/localhost\/fpm_status/) }
4244
it { should contain_file(conf_file).with_content(/ping_url: http:\/\/localhost\/fpm_ping/) }
45+
it { should contain_file(conf_file).with_content(/ping_reply: success/) }
4346
end
4447

4548
context 'with http_host set' do
4649
let(:params) {{
4750
status_url: 'http://localhost/fpm_status',
4851
ping_url: 'http://localhost/fpm_ping',
52+
ping_reply: 'success',
4953
http_host: 'php_fpm_server',
5054
}}
5155
it { should contain_file(conf_file).with_content(/http_host: php_fpm_server/) }
5256
it { should contain_file(conf_file).with_content(/status_url: http:\/\/localhost\/fpm_status/) }
57+
it { should contain_file(conf_file).with_content(/ping_reply: success/) }
5358
it { should contain_file(conf_file).with_content(/ping_url: http:\/\/localhost\/fpm_ping/) }
5459
end
5560

@@ -63,13 +68,16 @@
6368
{
6469
'status_url' => 'http://localhost/b/fpm_status',
6570
'ping_url' => 'http://localhost/b/fpm_ping',
71+
'ping_reply' => 'success',
6672
},
6773
]
6874
}}
6975
it { should contain_file(conf_file).with_content(/status_url: http:\/\/localhost\/a\/fpm_status/) }
7076
it { should contain_file(conf_file).with_content(/ping_url: http:\/\/localhost\/a\/fpm_ping/) }
77+
it { should contain_file(conf_file).with_content(/ping_reply: pong/) }
7178
it { should contain_file(conf_file).with_content(/status_url: http:\/\/localhost\/b\/fpm_status/) }
7279
it { should contain_file(conf_file).with_content(/ping_url: http:\/\/localhost\/b\/fpm_ping/) }
80+
it { should contain_file(conf_file).with_content(/ping_reply: success/) }
7381
end
7482
end
7583
end

templates/agent-conf.d/php_fpm.yaml.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ instances:
1010
# Get a reliable service check of your FPM pool with that one
1111
ping_url: <%= instance['ping_url'] %>
1212
# Set the expected reply to the ping.
13-
ping_reply: pong
13+
ping_reply: <%= instance['ping_reply'] ? instance['ping_reply'] : 'pong' %>
1414
<%- if instance['http_host'] -%>
1515
# Set http host header
1616
http_host: <%= instance['http_host'] %>

0 commit comments

Comments
 (0)