sensu-plugins-php-fpm-boutetnico 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +1 -0
- data/LICENSE +22 -0
- data/README.md +50 -0
- data/bin/check-php-fpm.rb +117 -0
- data/bin/metrics-php-fpm.rb +78 -0
- data/lib/sensu-plugins-php-fpm.rb +1 -0
- data/lib/sensu-plugins-php-fpm/version.rb +9 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d2258a7af2fba0d1c551c3d4689e52507f4c9057
|
4
|
+
data.tar.gz: 01ea3e0a383505477cb05cde69ea262dfd36e173
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 02f754e41cf6beb9449fee267aaffa01cea607572ca0c5445960ffbfc8386967eadc844d85daa7e654ce80b72ee4ad9d1d6b454be929912685e0ea4c73dc8be0
|
7
|
+
data.tar.gz: 5db7d60d1808f4f383e2e02927b3386940f1fb4c5f5aa1f89102c5606487849c52bd24b5ecb41babd257f639b8133a88c392067c83ca04a07d6d01c5a9c99c42
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Can be found at [https://github.com/boutetnico/sensu-plugins-php-fpm/releases](https://github.com/boutetnico/sensu-plugins-php-fpm/releases).
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sensu-Plugins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
## Sensu-Plugins-php-fpm
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-php-fpm-boutetnico.svg)](https://badge.fury.io/rb/sensu-plugins-php-fpm-boutetnico.svg)
|
4
|
+
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/boutetnico/sensu-plugins-php-fpm)
|
5
|
+
|
6
|
+
## This is an unofficial fork
|
7
|
+
|
8
|
+
This fork is automatically tested, built and published to [RubyGems](https://rubygems.org/gems/sensu-plugins-php-fpm-boutetnico/) and [Bonsai](https://bonsai.sensu.io/assets/boutetnico/sensu-plugins-php-fpm).
|
9
|
+
|
10
|
+
## Files
|
11
|
+
* bin/check-php-fpm.rb
|
12
|
+
* bin/metrics-php-fpm.rb
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Make sure you adjust the `fastcgi_pass` socket to whatever you are using:
|
17
|
+
|
18
|
+
```
|
19
|
+
location ~ "/fpm-(status|ping)" {
|
20
|
+
include /etc/nginx/fastcgi_params;
|
21
|
+
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
22
|
+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
23
|
+
access_log off;
|
24
|
+
allow 127.0.0.1;
|
25
|
+
deny all;
|
26
|
+
}
|
27
|
+
```
|
28
|
+
|
29
|
+
Alternatively, but keep in mind that "ifs are evil":
|
30
|
+
|
31
|
+
```
|
32
|
+
set $pool "php5-fpm";
|
33
|
+
if ($arg_pool) {
|
34
|
+
set $pool $arg_pool;
|
35
|
+
}
|
36
|
+
location ~ "/fpm-(status|ping)" {
|
37
|
+
include /etc/nginx/fastcgi_params;
|
38
|
+
fastcgi_pass unix:/var/run/$pool.sock;
|
39
|
+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
40
|
+
access_log off;
|
41
|
+
allow 127.0.0.1;
|
42
|
+
deny all;
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
46
|
+
## Installation
|
47
|
+
|
48
|
+
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
49
|
+
|
50
|
+
## Notes
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Check PHP-FPM
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# DESCRIPTION:
|
7
|
+
# This plugin retrives php-fpm status, parse the default "pong response"
|
8
|
+
#
|
9
|
+
# PLATFORMS:
|
10
|
+
# all
|
11
|
+
#
|
12
|
+
# DEPENDENCIES:
|
13
|
+
# sensu-plugin Ruby gem
|
14
|
+
# php-fpm ping configuration
|
15
|
+
#
|
16
|
+
# USAGE:
|
17
|
+
# ./check-php-fpm.rb --host ${hostname}
|
18
|
+
#
|
19
|
+
# For hosts with a CA-signed SSL certificate
|
20
|
+
# ./check-php-fpm.rb --host ${hostname} --port 443 --ssl
|
21
|
+
#
|
22
|
+
# For hosts with a self-signed SSL certificate
|
23
|
+
# ./check-php-fpm.rb --host ${hostname} --port 443 --ssl --insecure
|
24
|
+
#
|
25
|
+
#
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
|
29
|
+
require 'sensu-plugin/check/cli'
|
30
|
+
require 'net/http'
|
31
|
+
require 'net/https'
|
32
|
+
require 'uri'
|
33
|
+
require 'socket'
|
34
|
+
|
35
|
+
class CheckPHPFpm < Sensu::Plugin::Check::CLI
|
36
|
+
option :hostname,
|
37
|
+
short: '-h HOSTNAME',
|
38
|
+
long: '--host HOSTNAME',
|
39
|
+
description: 'Nginx hostname',
|
40
|
+
default: 'localhost'
|
41
|
+
|
42
|
+
option :port,
|
43
|
+
short: '-p PORT',
|
44
|
+
long: '--port PORT',
|
45
|
+
description: 'Nginx port',
|
46
|
+
default: '80'
|
47
|
+
|
48
|
+
option :path,
|
49
|
+
short: '-q PATH',
|
50
|
+
long: '--path PATH',
|
51
|
+
description: 'Path to your fpm ping',
|
52
|
+
default: 'fpm-ping'
|
53
|
+
|
54
|
+
option :pool,
|
55
|
+
short: '-P ?pool=POOL',
|
56
|
+
long: '--pool ?pool=POOL',
|
57
|
+
description: 'Name of your pool, if you are dynamically mapping pools based on args in Nginx'
|
58
|
+
|
59
|
+
option :scheme,
|
60
|
+
description: 'Request scheme to use',
|
61
|
+
short: '-s SCHEME',
|
62
|
+
long: '--scheme SCHEME',
|
63
|
+
default: 'http://'
|
64
|
+
|
65
|
+
option :response,
|
66
|
+
description: 'Expected response',
|
67
|
+
short: '-r RESPONSE',
|
68
|
+
long: '--response RESPONSE',
|
69
|
+
default: 'pong'
|
70
|
+
|
71
|
+
option :ssl,
|
72
|
+
short: '-l',
|
73
|
+
long: '--ssl',
|
74
|
+
boolean: true,
|
75
|
+
description: 'Enabling SSL connections',
|
76
|
+
default: false
|
77
|
+
|
78
|
+
option :insecure,
|
79
|
+
short: '-k',
|
80
|
+
long: '--insecure',
|
81
|
+
boolean: true,
|
82
|
+
description: 'Enabling insecure connections',
|
83
|
+
default: false
|
84
|
+
|
85
|
+
def run
|
86
|
+
if config[:pool]
|
87
|
+
config[:path] = config[:path] + config[:pool]
|
88
|
+
end
|
89
|
+
|
90
|
+
config[:url] = config[:scheme] + config[:hostname].to_s + ':' + config[:port].to_s + '/' + config[:path].to_s
|
91
|
+
config[:fqdn] = Socket.gethostname
|
92
|
+
uri = URI.parse(config[:url])
|
93
|
+
|
94
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
95
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
96
|
+
|
97
|
+
if config[:ssl]
|
98
|
+
http.use_ssl = true
|
99
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if config[:insecure]
|
100
|
+
end
|
101
|
+
|
102
|
+
response = http.request(request)
|
103
|
+
|
104
|
+
if response.code == '200'
|
105
|
+
if response.body == config[:response]
|
106
|
+
ok config[:response].to_s
|
107
|
+
else
|
108
|
+
critical "#{response.body} instead of #{config[:response]}"
|
109
|
+
end
|
110
|
+
else
|
111
|
+
critical "Error, http response code: #{response.code}"
|
112
|
+
end
|
113
|
+
|
114
|
+
# be safe
|
115
|
+
critical 'unknown error'
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Pull php-fpm metrics from php-fpm status page
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# Copyright 2014 Ilari Makela ilari at i28.fi
|
7
|
+
#
|
8
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
9
|
+
# for details.
|
10
|
+
|
11
|
+
require 'sensu-plugin/metric/cli'
|
12
|
+
require 'net/https'
|
13
|
+
require 'uri'
|
14
|
+
|
15
|
+
class PhpfpmMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
16
|
+
option :url,
|
17
|
+
short: '-u URL',
|
18
|
+
long: '--url URL',
|
19
|
+
description: 'Full URL to php-fpm status page, example: http://yoursite.com/php-fpm-status',
|
20
|
+
required: true
|
21
|
+
|
22
|
+
option :scheme,
|
23
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
24
|
+
short: '-s SCHEME',
|
25
|
+
long: '--scheme SCHEME',
|
26
|
+
default: "#{Socket.gethostname}.php_fpm"
|
27
|
+
|
28
|
+
option :agent,
|
29
|
+
description: 'User Agent to make the request with',
|
30
|
+
short: '-a USERAGENT',
|
31
|
+
long: '--agent USERAGENT',
|
32
|
+
default: 'Sensu-Agent'
|
33
|
+
|
34
|
+
def run
|
35
|
+
found = false
|
36
|
+
attempts = 0
|
37
|
+
# #YELLOW
|
38
|
+
until found || attempts >= 10
|
39
|
+
attempts += 1
|
40
|
+
url = config[:url]
|
41
|
+
if url
|
42
|
+
uri = URI.parse(url)
|
43
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
44
|
+
if uri.scheme == 'https'
|
45
|
+
http.use_ssl = true
|
46
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
47
|
+
end
|
48
|
+
request = Net::HTTP::Get.new(uri.request_uri, 'User-Agent' => config[:agent].to_s)
|
49
|
+
response = http.request(request)
|
50
|
+
if response.code == '200'
|
51
|
+
found = true
|
52
|
+
elsif !response.header['location'].nil?
|
53
|
+
url = response.header['location']
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end # until
|
57
|
+
|
58
|
+
critical "Unable to load url #{config[:url]}" if response.nil? || response.code != '200'
|
59
|
+
|
60
|
+
stat = %w[start_since
|
61
|
+
accepted_conn
|
62
|
+
listen_queue
|
63
|
+
max_listen_queue
|
64
|
+
listen_queue_len
|
65
|
+
idle_processes
|
66
|
+
active_processes
|
67
|
+
total_processes
|
68
|
+
max_active_processes
|
69
|
+
max_children_reached
|
70
|
+
slow_requests]
|
71
|
+
response.body.each_line do |line|
|
72
|
+
k, v = line.split(':').map(&:strip)
|
73
|
+
k.tr! ' ', '_'
|
74
|
+
output "#{config[:scheme]}.#{k}", v if stat.include? k
|
75
|
+
end
|
76
|
+
ok
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'sensu-plugins-php-fpm/version'
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-php-fpm-boutetnico
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sensu-Plugins and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sensu-plugin
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: codeclimate-test-reporter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: github-markup
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.13'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '13.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '13.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: redcarpet
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.5'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.5'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.9'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.9'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.85.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.85.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: yard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.9.25
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.9.25
|
153
|
+
description: Sensu plugins for php-fpm
|
154
|
+
email: "<sensu-users@googlegroups.com>"
|
155
|
+
executables:
|
156
|
+
- check-php-fpm.rb
|
157
|
+
- metrics-php-fpm.rb
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- CHANGELOG.md
|
162
|
+
- LICENSE
|
163
|
+
- README.md
|
164
|
+
- bin/check-php-fpm.rb
|
165
|
+
- bin/metrics-php-fpm.rb
|
166
|
+
- lib/sensu-plugins-php-fpm.rb
|
167
|
+
- lib/sensu-plugins-php-fpm/version.rb
|
168
|
+
homepage: https://github.com/boutetnico/sensu-plugins-php-fpm
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata:
|
172
|
+
maintainer: "@tas50"
|
173
|
+
development_status: active
|
174
|
+
production_status: unstable - testing recommended
|
175
|
+
release_draft: 'false'
|
176
|
+
release_prerelease: 'false'
|
177
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
178
|
+
in /etc/default/sensu
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 2.4.0
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.6.14.4
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: Sensu plugins for php-fpm
|
198
|
+
test_files: []
|