forked from outlyerapp/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp-fpm.py
More file actions
executable file
·43 lines (33 loc) · 925 Bytes
/
php-fpm.py
File metadata and controls
executable file
·43 lines (33 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
"""
1. edit /etc/php5/fpm/pool.d/www.conf and uncomment pm.status_path to enable it
2. add the following block to nginx
location ~ ^/(www-status)$ {
access_log off;
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
3. restart nginx and php-fpm
"""
import sys
import requests
HOST = 'localhost'
PORT = 80
URL = "http://%s:%s/www-status" % (HOST, PORT)
excludes = ['pool', 'process_manager', 'start_time']
try:
resp = requests.get(URL, timeout=60).content.split('\n')
except:
print "Plugin Failed!"
sys.exit(2)
result = "OK | "
for metric in resp:
if len(metric) > 0:
key = metric.split(':')[0].replace(' ', '_').lower().strip()
if not any(x in key.lower() for x in excludes):
value = metric.split(':')[1].strip()
result += key + "=" + str(value) + ";;;; "
print result
sys.exit(0)