Skip to content

Commit

Permalink
Merge pull request #25 from tjespers/fix-queue-len-not-working-as-exp…
Browse files Browse the repository at this point in the history
…ected

Fix queue-len related options
  • Loading branch information
renatomefi authored Sep 13, 2019
2 parents bbf2d50 + 0c87505 commit fff8b9d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ $ echo $?
And you can also check if you have more than `10` processes in the queue:

```console
$ php-fpm-healthcheck --accepted-conn=3000 --listen-queue-len=10
$ php-fpm-healthcheck --accepted-conn=3000 --listen-queue=10
$ echo $?
0
```
Expand Down Expand Up @@ -155,7 +155,7 @@ More and more people are looking for health checks on kubernetes for php-fpm, he
exec:
command:
- php-fpm-healthcheck
- --listen-queue-len=10 # fails if there are more than 10 processes waiting in the fpm queue
- --listen-queue=10 # fails if there are more than 10 processes waiting in the fpm queue
- --accepted-conn=5000 # fails after fpm has served more than 5k requests, this will force the pod to reset, use with caution
initialDelaySeconds: 0
periodSeconds: 10
Expand Down
2 changes: 1 addition & 1 deletion php-fpm-healthcheck
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ get_fpm_status() {
check_fpm_health_by() {
OPTION=$(echo "$1" | sed 's/--//g; s/-/ /g;')
VALUE_EXPECTED="$2";
VALUE_ACTUAL=$(echo "$FPM_STATUS" | grep "^$OPTION" | cut -d: -f2 | sed 's/ //g')
VALUE_ACTUAL=$(echo "$FPM_STATUS" | grep "^$OPTION:" | cut -d: -f2 | sed 's/ //g')

if test "$VERBOSE" = 1; then printf "'%s' value '%s' and expected is less than '%s'\\n" "$OPTION" "$VALUE_ACTUAL" "$VALUE_EXPECTED"; fi;

Expand Down
8 changes: 8 additions & 0 deletions test/testinfra/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ def test_metric_accepted_conn(host):
assert "Trying to connect to php-fpm via:" in cmd.stdout
assert "status output:" in cmd.stdout
assert "pool:" in cmd.stdout

@pytest.mark.php_fpm
def test_listen_queue_len_and_listen_queue_vars_are_parsed_correctly(host):
cmd = host.run("php-fpm-healthcheck --verbose --listen-queue=5 --listen-queue-len=256")
assert cmd.rc == 0
assert "Trying to connect to php-fpm via:" in cmd.stdout
assert "'listen queue' value '0' and expected is less than '5" in cmd.stdout
assert "'listen queue len' value '128' and expected is less than '256'" in cmd.stdout

0 comments on commit fff8b9d

Please sign in to comment.