Skip to content

Commit 68f22bd

Browse files
committed
Document how to use
1 parent 88401e3 commit 68f22bd

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

README.md

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,96 @@ This POSIX compliant sh script gets php-fpm status page using `cgi-fcgi` tool, p
99
### Download
1010

1111
```sh
12-
curl -L -o /usr/local/bin/php-fpm-healthcheck \
13-
https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck
12+
wget -O /usr/local/bin/php-fpm-healthcheck \
13+
https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck \
14+
&& chmod +x /usr/local/bin/php-fpm-healthcheck
1415
```
1516

1617
### Update
1718

1819
```sh
19-
curl -L -o $(which php-fpm-healthcheck) \
20-
https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck
20+
wget -O $(which php-fpm-healthcheck) \
21+
https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck \
22+
&& chmod +x $(which php-fpm-healthcheck)
2123
```
2224

2325
### Manually
2426

2527
You can always of course manually [download](https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck) and maintain the file, as long as you follow the [MIT License](./LICENSE)
2628

29+
## Usage
30+
31+
### Ping mode
32+
33+
If you're aiming only to make sure php-fpm is alive and answering to requests you can:
34+
35+
```console
36+
$ php-fpm-healthcheck
37+
$ echo $?
38+
0
39+
```
40+
41+
Or with `verbose` to see php-fpm status output:
42+
43+
```console
44+
$ php-fpm-healthcheck -v
45+
Trying to connect to php-fpm via: localhost:9000
46+
php-fpm status output:
47+
pool: www
48+
process manager: dynamic
49+
start time: 11/Sep/2018:10:47:06 +0000
50+
start since: 436
51+
accepted conn: 1
52+
listen queue: 0
53+
max listen queue: 0
54+
listen queue len: 0
55+
idle processes: 1
56+
active processes: 1
57+
total processes: 2
58+
max active processes: 1
59+
max children reached: 0
60+
slow requests: 0
61+
$ echo $?
62+
0
63+
```
64+
65+
### Metric mode
66+
67+
Let's say you want to fail our healthcheck after your fpm has handled more than `3000` requests:
68+
69+
```console
70+
$ php-fpm-healthcheck --accepted-conn=3000
71+
$ echo $?
72+
0
73+
```
74+
75+
And you can also check if you have more than `10` processes in the queue:
76+
77+
```console
78+
$ php-fpm-healthcheck --accepted-conn=3000 --listen-queue-len=10
79+
$ echo $?
80+
0
81+
```
82+
83+
#### How a failing metric looks like
84+
85+
```console
86+
$ php-fpm-healthcheck --accepted-conn=1
87+
'accepted conn' value '6' is greater than expected '1'
88+
$ echo $?
89+
1
90+
```
91+
92+
### Connection via socket or another host
93+
94+
You can simply specify `FCGI_CONNECT` variable with your connection uri:
95+
96+
```console
97+
$ FCGI_CONNECT=/var/run/php-fpm.sock php-fpm-healthcheck
98+
$ echo $?
99+
0
100+
```
101+
27102
## Why POSIX sh
28103

29104
Most of the containers contain limited software installed, using POSIX sh aims to be compatible with most of the OS images around.

0 commit comments

Comments
 (0)