Why does this script not work on FreeBSD? I ran the script on Centos and Debian, all was fine. On FreeBSD (10.2) I encounter the following error:
awk: syntax error at source line 1
context is
match($0, "^listen >>> queue:[[:space:]]+(.*)", <<<
awk: bailing out at source line 1
-0.9902
As an example, here is some output of php-form status:
pool: www
process manager: ondemand
start time: 29/Feb/2016:15:18:54 +0200
start since: 2083770
accepted conn: 1467128
listen queue: 0
max listen queue: 129
listen queue len: 128
idle processes: 1
active processes: 2
total processes: 3
max active processes: 64
max children reached: 1
slow requests: 0
On Centos and Debian, when I run:
/path/to/script/php-fpm-check.sh "idle processes" http://127.0.0.1/status
I get 1
, but on FreeBSD the error mentioned above.
Note: to avoid having to get above script working, here is a quick script which replicates the problem:
echo 'listen queue: 0' | awk '
match($0, "^listen queue:[[:space:]]+(.*)", a) {
print a[1]
}'
The 3-argument form of match
is a GNU awk extension (docs). You'll have to find another way to capture the match (perhaps using the RSTART and RLENGTH variables set as a side-effect of match()), or install gawk on your freebsd system.