From 68e5a4d37788621f91d350a54682b22ccd167340 Mon Sep 17 00:00:00 2001 From: Ramil Valitov Date: Sat, 18 Jan 2020 22:38:35 +0300 Subject: [PATCH] [add,fix] more info how to use zabbix_get, correct command syntax for php-fpm.discover --- README.md | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index db24fbc..1f83967 100644 --- a/README.md +++ b/README.md @@ -511,40 +511,51 @@ Then check the Zabbix server log, for Debian/Ubuntu it's located at `/var/log/za ## Test with `zabbix_get` Please, use the [`zabbix_get`](https://www.zabbix.com/documentation/4.4/manual/concepts/get) utility from your Zabbix Server to test that you can get the data from the Zabbix Agent (host). + +### Installation Please, install this utility first, because usually it's not installed automatically: ```console apt-get install zabbix-get ``` -Example how to discover PHP-FPM pools: +### Command examples +In the examples below we use the following parameter names: -```console -root@server:/# zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover POOL_PATH -{"data":[{"{#POOLNAME}":"www","{#POOLSOCKET}":"/run/php/php7.3-fpm.sock"},{"{#POOLNAME}":"www2","{#POOLSOCKET}":"localhost:9001"}]} -``` - -To get status of the required pool, use the following command: - -```console -zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover.status[POOL_URL,POOL_PATH] -``` - -In the above examples we use the following values: - -- `127.0.0.1` is the IP address of the host where the Zabbix Agent is installed and where the PHP-FPM is running -- `10050` is the port of the Zabbix Agent +- `ZABBIX_HOST_IP` is the IP address of the host where the Zabbix Agent is installed and where the PHP-FPM is running, for example `127.0.0.1` +- `ZABBIX_HOST_PORT` is the port of the Zabbix Agent, for example `10050` - `POOL_URL` is the socket of the pool or IP and port combination, example: `/var/lib/php7.3-fpm/web1.sock` or `127.0.0.1:9000` - `POOL_PATH` is the status path of PHP-FPM that you set in [`pm.status_path`](https://github.com/rvalitov/zabbix-php-fpm#16-adjust-php-fpm-pools-configuration), the default value is `/php-fpm-status`. -Example: +All commands should return valid JSON data. If any error happens then it will be displayed. + +#### 1. Discover PHP-FPM pools +Command syntax: + +``` +zabbix_get -s ZABBIX_HOST_IP -p ZABBIX_HOST_PORT -k php-fpm.discover["POOL_URL"] +``` + +Command output example: +```console +root@server:/# zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"] +{"data":[{"{#POOLNAME}":"www","{#POOLSOCKET}":"/run/php/php7.3-fpm.sock"},{"{#POOLNAME}":"www2","{#POOLSOCKET}":"localhost:9001"}]} +``` + +#### 2. Get status of required pool +Command syntax: + +```console +zabbix_get -s ZABBIX_HOST_IP -p ZABBIX_HOST_PORT -k php-fpm.discover.status["POOL_URL","POOL_PATH"] +``` + +Command output example: ```console root@server:/# zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.status["localhost:9001","/php-fpm-status"] {"pool":"www2","process manager":"static","start time":1578093850,"start since":149,"accepted conn":3,"listen queue":0,"max listen queue":0,"listen queue len":511,"idle processes":4,"active processes":1,"total processes":5,"max active processes":1,"max children reached":0,"slow requests":0} ``` -All commands should return valid JSON data. If any error happens then it will be displayed. Most common problems of testing the `php-fpm.discover` key: - The resulting JSON data is empty, but the discovery script started manually works. Then it's a problem of insufficient privileges of Zabbix agent. Please, check again section "Root privileges" of this document.